Class: Rubyception::WebsocketServer
- Inherits:
-
Object
- Object
- Rubyception::WebsocketServer
- Defined in:
- lib/rubyception/websocket_server.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ WebsocketServer
constructor
A new instance of WebsocketServer.
Constructor Details
#initialize ⇒ WebsocketServer
Returns a new instance of WebsocketServer.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubyception/websocket_server.rb', line 18 def initialize Thread.new do = { host: '0.0.0.0', port: 3030 } while defined?(Thin) && !EventMachine.reactor_running? sleep 1 end EventMachine::WebSocket.start() do |ws| ws.onopen do Rubyception::WebsocketServer.sockets << ws end end end end |
Class Method Details
.send_all(*args) ⇒ Object
12 13 14 15 16 |
# File 'lib/rubyception/websocket_server.rb', line 12 def self.send_all(*args) self.sockets.each do |socket| socket.send(*args) end end |
.start(event) ⇒ Object
7 8 9 10 |
# File 'lib/rubyception/websocket_server.rb', line 7 def self.start(event) self.current_entry = Rubyception::Entry.new(event) self.send_all self.current_entry.to_json end |