Class: Marvin::Distributed::Client
- Inherits:
-
AbstractClient
- Object
- AbstractClient
- Marvin::Distributed::Client
- Defined in:
- lib/marvin/distributed/client.rb
Defined Under Namespace
Classes: EMConnection, RemoteClientProxy
Instance Attribute Summary collapse
-
#em_connection ⇒ Object
Returns the value of attribute em_connection.
-
#remote_client_host ⇒ Object
Returns the value of attribute remote_client_host.
-
#remote_client_nick ⇒ Object
Returns the value of attribute remote_client_nick.
Attributes inherited from AbstractClient
#channels, #connection_config, #disconnect_expected, #nickname, #nicks, #pass, #port, #server
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(em_connection) ⇒ Client
constructor
A new instance of Client.
- #remote_client ⇒ Object
- #reset! ⇒ Object
- #reset_handlers ⇒ Object
- #setup_handlers ⇒ Object
Methods inherited from AbstractClient
#action, #command, configuration=, configure, #default_channels, #default_channels=, #handle_client_connected, #handle_incoming_error, #handle_incoming_join, #handle_incoming_numeric, #handle_incoming_ping, #handle_nick_taken, #handle_welcome, #host_with_port, #join, #msg, #nick, #part, #pong, #pre_dispatching, #process_connect, #process_development, #process_disconnect, #quit, #receive_line, setup, setup?
Constructor Details
#initialize(em_connection) ⇒ Client
Returns a new instance of Client.
164 165 166 |
# File 'lib/marvin/distributed/client.rb', line 164 def initialize(em_connection) @em_connection = em_connection end |
Instance Attribute Details
#em_connection ⇒ Object
Returns the value of attribute em_connection.
10 11 12 |
# File 'lib/marvin/distributed/client.rb', line 10 def em_connection @em_connection end |
#remote_client_host ⇒ Object
Returns the value of attribute remote_client_host.
10 11 12 |
# File 'lib/marvin/distributed/client.rb', line 10 def remote_client_host @remote_client_host end |
#remote_client_nick ⇒ Object
Returns the value of attribute remote_client_nick.
10 11 12 |
# File 'lib/marvin/distributed/client.rb', line 10 def remote_client_nick @remote_client_nick end |
Class Method Details
.run ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/marvin/distributed/client.rb', line 189 def run logger.info "Preparing to start distributed client" EventMachine.kqueue EventMachine.epoll EventMachine.run do opts = Marvin::Settings.distributed || Marvin::Nash.new opts = opts.client || Marvin::Nash.new host = opts.host || "0.0.0.0" port = (opts.port || 8943).to_i EMConnection.connect(host, port, opts) end end |
.stop ⇒ Object
202 203 204 205 206 |
# File 'lib/marvin/distributed/client.rb', line 202 def stop logger.info "Stopping distributed client..." EMConnection.stopping = true EventMachine.stop_event_loop end |
Instance Method Details
#remote_client ⇒ Object
168 169 170 |
# File 'lib/marvin/distributed/client.rb', line 168 def remote_client @remote_client ||= RemoteClientProxy.new(@em_connection, @remote_client_host, @remote_client_nick) end |
#reset! ⇒ Object
172 173 174 175 176 177 |
# File 'lib/marvin/distributed/client.rb', line 172 def reset! @remote_client = nil @remote_client_nick = nil @remote_client_host = nil reset_handlers end |
#reset_handlers ⇒ Object
183 184 185 |
# File 'lib/marvin/distributed/client.rb', line 183 def reset_handlers self.class.handlers.each { |h| h.client = nil if h.respond_to?(:client=) } end |
#setup_handlers ⇒ Object
179 180 181 |
# File 'lib/marvin/distributed/client.rb', line 179 def setup_handlers self.class.handlers.each { |h| h.client = remote_client if h.respond_to?(:client=) } end |