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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gt06_server/server.rb', line 34 def initialize(host, port, handler, options: {} ) @logger = .fetch(:logger, Logger.new(STDOUT)) @host = host @port = port @sessions = Concurrent::Map.new sweeper = SessionSweeper.new( @sessions, .fetch(:session_timeout, nil), interval: .fetch(:sweep_interval, nil), logger: @logger ) sweeper.run async.run handler end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/gt06_server/server.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/gt06_server/server.rb', line 11 def port @port end |
#sessions ⇒ Object (readonly)
Returns the value of attribute sessions.
11 12 13 |
# File 'lib/gt06_server/server.rb', line 11 def sessions @sessions end |
Class Method Details
.run(host, port, options: {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gt06_server/server.rb', line 21 def self.run(host, port, options: {}, &block) actor = Celluloid::Actor['Gt06Server'] if actor&.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 |