How to communicate with streams in Ruby?

I am creating a realtime game, mostly chat based, and I need many of these chats to run concurrently, receiving and sending data over websockets.

I was told that instead of creating one process per game, I should have one process with one thread per game (perhaps using an Event Machine).

I'm using Juggernaut for the sockets part, it allows data to be sent to all players in a game using a publish / subscribe system: each player joins one game. But how can I send data from each player to that particular game?

I thought I could send the game id or channel id from the client to the server and then send it to the appropriate stream.

But how can I send anything to the stream?

+3


source to share


1 answer


To send data to a stream, you can use Ruby Queue:



http://www.ruby-doc.org/stdlib-1.9.3/libdoc/thread/rdoc/Queue.html

+4


source







All Articles