Class: CelluloidPubsub::ClientConnection
- Inherits:
-
Celluloid::WebSocket::Client::Connection
- Object
- Celluloid::WebSocket::Client::Connection
- CelluloidPubsub::ClientConnection
- Includes:
- Helper
- Defined in:
- lib/celluloid_pubsub/client_connection.rb
Instance Method Summary collapse
-
#actor_died(actor, reason) ⇒ void
method called when the actor is exiting.
-
#initialize(url, handler) ⇒ ClientConnection
constructor
A new instance of ClientConnection.
- #run ⇒ Object
-
#shutdown ⇒ void
the method will terminate the current actor.
-
#shutting_down? ⇒ Boolean
the method will return true if the actor is shutting down.
Methods included from Helper
action_subscribe?, #actor_dead?, #cell_actor, fetch_gem_version, filtered_error?, find_loaded_gem, find_loaded_gem_property, get_parsed_version, log_debug, #own_self, parse_options, setup_celluloid_exception_handler, setup_celluloid_logger, setup_log_file, #succesfull_subscription?, verify_gem_version
Constructor Details
#initialize(url, handler) ⇒ ClientConnection
Returns a new instance of ClientConnection.
11 12 13 14 |
# File 'lib/celluloid_pubsub/client_connection.rb', line 11 def initialize(url, handler) @shutting_down = false super(url, handler) end |
Instance Method Details
#actor_died(actor, reason) ⇒ void
This method returns an undefined value.
method called when the actor is exiting
52 53 54 55 |
# File 'lib/celluloid_pubsub/client_connection.rb', line 52 def actor_died(actor, reason) @shutting_down = true log_debug "Oh no! #{actor.inspect} has died because of a #{reason.class}" end |
#run ⇒ Object
16 17 18 19 20 |
# File 'lib/celluloid_pubsub/client_connection.rb', line 16 def run super rescue EOFError, Errno::ECONNRESET, StandardError @client.emit(:close, ::WebSocket::Driver::CloseEvent.new(1001, 'server closed connection')) end |
#shutdown ⇒ void
This method returns an undefined value.
the method will terminate the current actor
38 39 40 41 42 |
# File 'lib/celluloid_pubsub/client_connection.rb', line 38 def shutdown @shutting_down = true log_debug "#{self.class} tries to 'shutdown'" terminate end |
#shutting_down? ⇒ Boolean
the method will return true if the actor is shutting down
28 29 30 |
# File 'lib/celluloid_pubsub/client_connection.rb', line 28 def shutting_down? @shutting_down == true end |