class Undead::Server
Attributes
fixed_port[R]
socket[R]
timeout[R]
Public Class Methods
new(fixed_port = nil, timeout = nil)
click to toggle source
# File lib/undead/server.rb, line 8 def initialize(fixed_port = nil, timeout = nil) @fixed_port = fixed_port @timeout = timeout start end
Public Instance Methods
port()
click to toggle source
# File lib/undead/server.rb, line 14 def port @socket.port end
restart()
click to toggle source
# File lib/undead/server.rb, line 30 def restart stop start end
send(command)
click to toggle source
# 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.message, receive_timeout) or raise Undead::DeadClient.new(command.message) end
start()
click to toggle source
# File lib/undead/server.rb, line 22 def start @socket = Undead::WebSocketServer.new(fixed_port, timeout) end
stop()
click to toggle source
# File lib/undead/server.rb, line 26 def stop @socket.close end
timeout=(sec)
click to toggle source
# File lib/undead/server.rb, line 18 def timeout=(sec) @timeout = @socket.timeout = sec end