Class: Gt06Server::Server
- Inherits:
-
Object
- Object
- Gt06Server::Server
- Includes:
- Celluloid::IO
- Defined in:
- lib/gt06_server/server.rb
Defined Under Namespace
Classes: RunError
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#sessions ⇒ Object
readonly
Returns the value of attribute sessions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, port, handler, options: {}) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(host, port, handler, options: {}) ⇒ Server
Returns a new instance of Server.
32 33 34 35 36 37 38 39 40 |
# File 'lib/gt06_server/server.rb', line 32 def initialize(host, port, handler, options: {}) @logger = .fetch(:logger, Logger.new(STDOUT)) @host = host @port = port @sessions = Concurrent::Map.new sessions_sweeper_run(@sessions, ) async.run handler end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/gt06_server/server.rb', line 12 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/gt06_server/server.rb', line 12 def port @port end |
#sessions ⇒ Object (readonly)
Returns the value of attribute sessions.
12 13 14 |
# File 'lib/gt06_server/server.rb', line 12 def sessions @sessions end |
Class Method Details
.run(host, port, options: {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gt06_server/server.rb', line 21 def self.run(host, port, options: {}, &block) if Celluloid::Actor['Gt06Server']&.alive? raise RunError, 'Attempt to run more than one the Gt06Server' end Gt06Server::Server.supervise( as: 'Gt06Server', args: [host, port, block, options: { logger: Logger.new(STDOUT) }.merge()] ) end |