Module: ESM::Command::Base::Migration
- Extended by:
- ActiveSupport::Concern
- Included in:
- ESM::Command::Base
- Defined in:
- lib/esm/command/base/migration.rb
Overview
V1
Instance Method Summary collapse
-
#deliver!(command_name: nil, timeout: 30, **parameters) ⇒ Object
V1: Send a request to the DLL.
-
#discord ⇒ Object
deprecated
Deprecated.
Use on_execute instead
-
#from_server(response) ⇒ Object
V1: This is called when the message is received from the server.
- #load_v1_code! ⇒ Object
- #on_response ⇒ Object deprecated Deprecated.
- #server ⇒ Object deprecated Deprecated.
- #v1_code_needed? ⇒ Boolean
- #v2_target_server? ⇒ Boolean
Instance Method Details
#deliver!(command_name: nil, timeout: 30, **parameters) ⇒ Object
V1: Send a request to the DLL
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/esm/command/base/migration.rb', line 54 def deliver!(command_name: nil, timeout: 30, **parameters) raise ESM::Exception::CheckFailure, "Command does not have an associated server" if target_server.nil? # Build the request request = ESM::Websocket::Request.new( command: self, command_name: command_name, user: current_user, channel: current_channel, parameters: parameters, timeout: timeout ) # Send it to the dll ESM::Websocket.deliver!(target_server.server_id, request) end |
#discord ⇒ Object
Deprecated.
Use on_execute instead
V1
24 25 |
# File 'lib/esm/command/base/migration.rb', line 24 def discord end |
#from_server(response) ⇒ Object
V1: This is called when the message is received from the server
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/esm/command/base/migration.rb', line 40 def from_server(response) load_v1_code! if v1_code_needed? # Event is always an array. 90% of the time, event size will only be 1 # This just makes typing a little easier when writing commands @response = (response.size == 1) ? response.first : response # Trigger the callback on_response end |
#load_v1_code! ⇒ Object
18 19 20 |
# File 'lib/esm/command/base/migration.rb', line 18 def load_v1_code! extend(self.class::V1) # Overwrites V2 logic end |
#on_response ⇒ Object
Deprecated.
V1
34 35 |
# File 'lib/esm/command/base/migration.rb', line 34 def on_response end |
#server ⇒ Object
Deprecated.
V1
29 30 |
# File 'lib/esm/command/base/migration.rb', line 29 def server end |
#v1_code_needed? ⇒ Boolean
14 15 16 |
# File 'lib/esm/command/base/migration.rb', line 14 def v1_code_needed? defined?(self.class::V1) && !v2_target_server? end |
#v2_target_server? ⇒ Boolean
72 73 74 |
# File 'lib/esm/command/base/migration.rb', line 72 def v2_target_server? !!target_server&.v2? end |