Sha256: db7a320c429dacb618c9241fc8bffca5575f3dcec8e8527e4eab39f850fbdf0f
Contents?: true
Size: 538 Bytes
Versions: 3
Compression:
Stored size: 538 Bytes
Contents
require 'em-websocket' require 'json' module StripMem class WebSocket def initialize(channel) @channel = channel @data = [] @channel.subscribe { |msg| @data << msg } end def run! EventMachine::WebSocket.start(:host => 'localhost', :port => 9998) do |ws| ws.onopen do @data.each { |msg| ws.send(JSON.generate(msg)) } sid = @channel.subscribe { |msg| ws.send(JSON.generate(msg)) } ws.onclose { @channel.unsubscribe(sid) } end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stripmem-0.0.3 | lib/stripmem/websocket.rb |
stripmem-0.0.2 | lib/stripmem/websocket.rb |
stripmem-0.0.1 | lib/stripmem/websocket.rb |