Module: PusherFake::Server
- Defined in:
- lib/pusher-fake/server.rb,
lib/pusher-fake/server/application.rb,
lib/pusher-fake/server/chain_trap_handlers.rb
Overview
Socket and web server manager.
Defined Under Namespace
Modules: ChainTrapHandlers Classes: Application
Class Method Summary collapse
-
.start ⇒ Object
Start the servers.
-
.start_socket_server ⇒ Object
Start the WebSocket server.
-
.start_web_server ⇒ Object
Start the web server.
Class Method Details
.start ⇒ Object
Start the servers.
14 15 16 17 18 19 20 21 |
# File 'lib/pusher-fake/server.rb', line 14 def start chain_trap_handlers EventMachine.run do start_web_server start_socket_server end end |
.start_socket_server ⇒ Object
Start the WebSocket server.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pusher-fake/server.rb', line 24 def start_socket_server EventMachine::WebSocket.start(configuration.) do |socket| socket.onopen do connection = Connection.new(socket) connection.establish socket. { |data| connection.process(data) } socket.onclose { Channel.remove(connection) } end end end |
.start_web_server ⇒ Object
Start the web server.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pusher-fake/server.rb', line 37 def start_web_server = configuration..dup host = .delete(:host) port = .delete(:port) Thin::Logging.silent = true Thin::Server.new(host, port, Application).tap do |server| .each do |key, value| server.__send__(:"#{key}=", value) end server.start! end end |