Class: Pantry::Commands::RegisterClient
- Inherits:
-
Pantry::Command
- Object
- Pantry::Command
- Pantry::Commands::RegisterClient
- Defined in:
- lib/pantry/commands/register_client.rb
Instance Method Summary collapse
-
#initialize(client_info = nil) ⇒ RegisterClient
constructor
A new instance of RegisterClient.
-
#perform(message) ⇒ Object
Take note that a Client has connected and registered itself with this Server.
- #to_message ⇒ Object
Methods inherited from Pantry::Command
command, #finished, #finished?, message_type, #prepare_message, #receive_client_response, #receive_response, #receive_server_response, #send_request, #send_request!, #server_or_client, #server_or_client=, #wait_for_finish
Constructor Details
#initialize(client_info = nil) ⇒ RegisterClient
Returns a new instance of RegisterClient.
6 7 8 |
# File 'lib/pantry/commands/register_client.rb', line 6 def initialize(client_info = nil) @client_info = client_info end |
Instance Method Details
#perform(message) ⇒ Object
Take note that a Client has connected and registered itself with this Server.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pantry/commands/register_client.rb', line 22 def perform() details = .body[0] @client_info = Pantry::ClientInfo.new( identity: .from, application: details[:application], environment: details[:environment], roles: details[:roles] ) self.server.register_client(@client_info) end |
#to_message ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/pantry/commands/register_client.rb', line 10 def = super << { application: @client_info.application, environment: @client_info.environment, roles: @client_info.roles } end |