Open socket.io connection without opening/joining any room
connection.connectSocket(function() { alert('Successfully connected to socket.io server.'); connection.socket.emit('howdy', 'hello'); });
<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script> <script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script> <script> var connection = new RTCMultiConnection(); // this line is VERY_important connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/'; // if you want audio+video conferencing connection.session = { audio: true, video: true }; connection.socketCustomEvent = 'private-secure-chat'; connection.connectSocket(function() { console.info('Successfully connected to socket.io server.'); connection.socket.emit(connection.socketCustomEvent, 'anyone-in-the-house?'); connection.socket.on(connection.socketCustomEvent, function(message) { if (message === 'anyone-in-the-house?') { // because each and every user opened unique-room // their "userid" is always considered "roomid" connection.socket.emit(connection.socketCustomEvent, { joinMe: connection.userid // share room-id so they can join }); return; } if (message.joinMe) { // one can join many rooms connection.join(message.joinMe); } }); // each and every user can open unique room connection.open(connection.userid); }); </script>