jueves, noviembre 24, 2011

RedisStore and rooms with Socket.IO

Here is my base code I used at my startup PeopleRooms, using RedisStore instead of MemoryStore in Socket.IO. So that the application is capable to scale. And the also the "rooms" feature of Socket.io

9 comentarios:

Ranu dijo...

Yes, you can. But this code only is to join multiple rooms. And you can leave rooms when event disconnect is raised. If understood correctly your question.

olaf dijo...

hi, very cool example!! i have one question though:
I don't see any '.publish(...)' or '.subscribe(...)' - commands, is that just not covered by this is example or is socket.io taking care of that itself now?
In other words: does this line 'io.set('store', new RedisStore({redisPub:pub, redisSub:sub, redisClient:store}));' take care of the redis-part?! i do not have to say '.publish(...)' on every event myself?

cheers
olaf

Ranu dijo...

Yes Olaf, in the line: io.set('store', new RedisStore({redisPub:pub, redisSub:sub, redisClient:store}));' You are sending a publisher and a subscriber to Socket.io that it will use. So that work is made by socket.io.

hope it helps
Ranu

jspot dijo...

hi ranu, te hablo de colombia, he estado tratando de correr y entender este ejemplo pero aun tengo algunas dudas, por ejemplo no pude hacerlo correr con redis, recibo algunos errores al momento de iniciar el server, podrias aclararme algunas dudas con respecto a este ejemplo ?

Ranu dijo...

jspot,
claro que si. Decime cual es tu duda.

Anónimo dijo...

Hi, I'm sorry to bother you, but can you tell me where in the code we're actually subscribing each of the sockets to the specified Room, because I'm not really sure I understand how the messages can be sent from one user to the other if the user's connections are not subscribed to certain rooms.
Thank you

Ranu dijo...

Hi,
I don't understand your question. But where I call the function "join", is to the user to join a Room. And when I call the function broadcast.to(Room) is to send a message to a room. Here you can find more information https://github.com/learnboost/socket.io , read the section rooms.

Regards

Stephane Eybert dijo...

Hola Ranu !

I'm Stephane from France. Nice article you have here. I'm currently learning socket.io and it's fun.

I went to have a look at your start-up at peoples room and I liked it. Specially the cartoon animation. Did you use some software to make that cartoon ? Your website is super cool !

Hope to see your start up succeed !

Ranu dijo...

Stephane,
thanks for your comments. The video was made by: http://mambostudio.com.ar

Regards