Sha256: 60ace83912804fe10a7fda1a94c4b43afcd6c41607aedc987f4209f265028f3d
Contents?: true
Size: 809 Bytes
Versions: 4
Compression:
Stored size: 809 Bytes
Contents
#!/usr/bin/env falcon serve --concurrency 1 -c require 'async/websocket/server' require 'async/actor' require 'set' bus = Async::Actor::Bus::Redis.new class Room def initialize @connections = Set.new end def connect connection @connections << connection end def disconnect connection @connections.delete(connection) end def each(&block) @connections.each(&block) end end bus.supervise(:room) do Room.new end run lambda {|env| room = bus[:room] Async::WebSocket::Server.open(env) do |connection| begin room.connect(connection) while message = connection.next_message room.each do |connection| connection.send_message(message) end end rescue room.disconnect(connection) end end Async::Task.current.sleep(0.1) [200, {}, ["Hello World"]] }
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
async-websocket-0.8.0 | examples/chat/config.ru |
async-websocket-0.7.0 | examples/chat/config.ru |
async-websocket-0.6.1 | examples/chat/config.ru |
async-websocket-0.6.0 | examples/chat/config.ru |