Skip to content

Commit

Permalink
Fix server implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 21, 2019
1 parent 2c6ea86 commit 1210a6b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions examples/chat/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

require 'async/websocket/server'

require 'async/actor'
# require 'async/actor'
require 'set'

bus = Async::Actor::Bus::Redis.new
# bus = Async::Actor::Bus::Redis.new

class Room
def initialize
Expand All @@ -25,24 +25,24 @@ class Room
end
end

bus.supervise(:room) do
Room.new
end
# bus.supervise(:room) do
# Room.new
# end

$room = Room.new

run lambda {|env|
room = bus[:room]

Async::WebSocket::Server.open(env) do |connection|
begin
room.connect(connection)
$room.connect(connection)

while message = connection.next_message
room.each do |connection|
$room.each do |connection|
connection.send_message(message)
end
end
rescue
room.disconnect(connection)
$room.disconnect(connection)
end
end

Expand Down

0 comments on commit 1210a6b

Please sign in to comment.