Class: Hokaido::Server

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/hokaido/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ Server

Returns a new instance of Server.



51
52
53
54
55
# File 'lib/hokaido/server.rb', line 51

def initialize(host, port)
  @server = TCPServer.new(host, port)

  async.run
end

Instance Method Details

#runObject



61
62
63
64
65
# File 'lib/hokaido/server.rb', line 61

def run
  loop do
    ConnectionHandler.new(@server.accept).link Actor.current
  end
end

#shutdownObject



57
58
59
# File 'lib/hokaido/server.rb', line 57

def shutdown
  @server.close if @server
end