Class: Orator::Server
- Inherits:
-
Object
- Object
- Orator::Server
- Defined in:
- lib/orator/server.rb
Overview
Handles the server connections and passing stuff to the event handler.
Instance Attribute Summary collapse
-
#clients ⇒ Set<Client>
readonly
The list of clients that are connected.
-
#event_handler ⇒ EventHandler
readonly
The event handler that is duplicated for every client.
-
#options ⇒ Hash
readonly
The options defined for the server.
Instance Method Summary collapse
-
#initialize(options) ⇒ void
constructor
Initialize the server.
-
#run(&block) ⇒ Object
Runs the server with the given options.
Constructor Details
#initialize(options) ⇒ void
Initialize the server.
25 26 27 28 |
# File 'lib/orator/server.rb', line 25 def initialize() @options = @clients = Set.new end |
Instance Attribute Details
#clients ⇒ Set<Client> (readonly)
The list of clients that are connected.
14 15 16 |
# File 'lib/orator/server.rb', line 14 def clients @clients end |
#event_handler ⇒ EventHandler (readonly)
The event handler that is duplicated for every client. This is to reduce the overhead of reinitializing the event handler for every client.
20 21 22 |
# File 'lib/orator/server.rb', line 20 def event_handler @event_handler end |
#options ⇒ Hash (readonly)
The options defined for the server.
9 10 11 |
# File 'lib/orator/server.rb', line 9 def @options end |
Instance Method Details
#run(&block) ⇒ Object
Runs the server with the given options.
31 32 33 34 |
# File 'lib/orator/server.rb', line 31 def run(&block) @event_handler = EventHandler.new(&block) EM::WebSocket.start(@options, &method(:handle_socket)) end |