washo4evr / Socket.io-v1.x-Library

Socket.io Library for Arduino
108 stars 58 forks source link

Connect to a room #58

Closed poengAlex closed 6 years ago

poengAlex commented 6 years ago

Hi

Is it possible to add support for connecting to a room? If it supported, can you please tell me how to use it?

Thanks for a good library!

washo4evr commented 6 years ago

Hi,

can you give me more context please? If possible, I can try to add support for that, but I don't know what it is yet.

Thanks

poengAlex commented 6 years ago

Hi

Room is like chat-rooms, so it is easier to manage the message flow. I added support by adding a variable in the handshake.

String header = F("GET /socket.io/1/?EIO=3&transport=polling&b64=true");
header = header + "&roomId=";
header = header + String(roomId);
header = header + " HTTP/1.1";
client.println(header);

And in the server side (node.js) I extract the roomId variable:

var roomId = socket.handshake['query']['roomId'];