Sha256: 0cbc3433c5574c0314c596c1302833b8388ecda959aa16005d66ffb949c8ed8e
Contents?: true
Size: 552 Bytes
Versions: 10
Compression:
Stored size: 552 Bytes
Contents
module EchoServer def self.start WebSocket::EventMachine::Server.start(:host => "0.0.0.0", :port => self.port) do |ws| @channel = EM::Channel.new ws.onopen do sid = @channel.subscribe do |mes| ws.send mes # echo to client end ws.onmessage do |msg| @channel.push msg end ws.onclose do @channel.unsubscribe sid end end end end def self.port (ENV['WS_PORT'] || 18080).to_i end def self.url "ws://localhost:#{self.port}" end end
Version data entries
10 entries across 10 versions & 1 rubygems