Class: Wocket::Server
- Inherits:
-
Object
- Object
- Wocket::Server
- Includes:
- Celluloid::IO, Bindable
- Defined in:
- lib/wocket/server.rb
Constant Summary collapse
- DEFAULT_HOST =
"127.0.0.1"
- DEFAULT_PORT =
9292
Instance Method Summary collapse
- #available_bindings ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #start ⇒ Object
Methods included from Bindable
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 19 |
# File 'lib/wocket/server.rb', line 13 def initialize( = {}) @options = @host = [:host] || DEFAULT_HOST @port = [:port] || DEFAULT_PORT @callbacks = {} end |
Instance Method Details
#available_bindings ⇒ Object
21 22 23 |
# File 'lib/wocket/server.rb', line 21 def available_bindings [:onopen, :onclose, :onerror, :onmessage, :onping, :onpong] end |
#run ⇒ Object
31 32 33 |
# File 'lib/wocket/server.rb', line 31 def run loop { async.handle_connection @server.accept } end |
#start ⇒ Object
25 26 27 28 29 |
# File 'lib/wocket/server.rb', line 25 def start @server = TCPServer.new(@host, @port) async.run puts end |