Class: Undead::Server
- Inherits:
-
Object
- Object
- Undead::Server
- Defined in:
- lib/undead/server.rb
Instance Attribute Summary collapse
-
#fixed_port ⇒ Object
readonly
Returns the value of attribute fixed_port.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(fixed_port = nil, timeout = nil) ⇒ Server
constructor
A new instance of Server.
- #port ⇒ Object
- #restart ⇒ Object
- #send(command) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(fixed_port = nil, timeout = nil) ⇒ Server
8 9 10 11 12 |
# File 'lib/undead/server.rb', line 8 def initialize(fixed_port = nil, timeout = nil) @fixed_port = fixed_port @timeout = timeout start end |
Instance Attribute Details
#fixed_port ⇒ Object (readonly)
Returns the value of attribute fixed_port.
6 7 8 |
# File 'lib/undead/server.rb', line 6 def fixed_port @fixed_port end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
6 7 8 |
# File 'lib/undead/server.rb', line 6 def socket @socket end |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/undead/server.rb', line 6 def timeout @timeout end |
Instance Method Details
#port ⇒ Object
14 15 16 |
# File 'lib/undead/server.rb', line 14 def port @socket.port end |
#restart ⇒ Object
30 31 32 33 |
# File 'lib/undead/server.rb', line 30 def restart stop start end |
#send(command) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/undead/server.rb', line 35 def send(command) receive_timeout = nil # default if command.name == 'visit' command.args.push(timeout) # set the client set visit timeout parameter receive_timeout = timeout + 5 # Add a couple of seconds to let the client timeout first end @socket.send(command.id, command., receive_timeout) or raise Undead::DeadClient.new(command.) end |
#start ⇒ Object
22 23 24 |
# File 'lib/undead/server.rb', line 22 def start @socket = Undead::WebSocketServer.new(fixed_port, timeout) end |
#stop ⇒ Object
26 27 28 |
# File 'lib/undead/server.rb', line 26 def stop @socket.close end |