-
Notifications
You must be signed in to change notification settings - Fork 14
User Metadata in the DataChannel logic? #2
Comments
RTCMultiConnection and this library (DataChannel) both are using similar API. RTCMultiConnection supports this: http://www.rtcmulticonnection.org/docs/extra/ You an set var channel = new RTCMultiConnection(); // using RTCMultiConnection
channel.extra = { // using "extra" object
userid: '<?= $user->id; ?>',
username: '<?= $user->username; ?>',
realname: '<?= $user->realname; ?>',
picture: '<?= $user->picture(); ?>'
};
channel.onopen = function(event) {
alert(event.extra.realname);
alert(event.extra.username);
};
channel.onmessage = function(event) {
alert(event.extra.realname);
alert(event.extra.username);
alert(event.data); // the actual chat message
};
// below 3 lines are different comparing DataChannel.js
channel .session = { data: true }; // tell that you need only chat/data connection
channel.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/'; // socket.io signaling
channel.openOrJoin('room-id'); // open and/or join the room Each and every event (whether it is var event = {
userid: 'unique username or userid of the user',
extra: {}, // extra information/metadata
}; Which means that you an access extra information from any event using You can find the documentation here: http://www.rtcmulticonnection.org/ RTCMultiConnection comes with these new events as well: So you have a separate event to listen for all realtime extra metadata (information that are set/updated during live session). You can update metadata during live session using following snippet: channel.extra.picture = 'new picture';
channel.extra.realname = 'new realname';
channel.updateExtraData(); // this line will update changes to all connected users
``` |
Thanks you for your detailed response! What you describe is exactly what I "miss" on DataChannel. BUT, I have a very reason why I want that on DataChannel and not wanting to use RTCMultiConnection instead: Basically, I written a (text) Chat module for the Nova Framework, where I am co-author. It is here: https://github.com/nova-framework/framework/tree/3.0/app/Modules/Chat The screenshot which I shown is made using this Chat module, BTW... So, while for the public examples and tests I intend to use your own signaling servers, made in NodeJS, for the production applications, I want to reserve my ability, well... to have the ability to use a signaling server over WebSocket made in Ratchet PHP, for example. In other hand, the DataChannel's signaling server is simple enough to be ported to Ratchet PHP in reasonable time. And as a bottom line, I do not need all those nice features from RTCMultiConnection, but which make a bit rocket science from its signaling server. 😉 All I need is this DataChannel, with this metadata (or So, there is the question: you can add this Eventually, I can help a bit, but I am not a JS Guru, to be honest. PS. Also |
I'll add
5 seconds waiter isn't a good idea. That's why presence detection should be handled on server side instead. A server can check whether channel/room exist or not. |
Well, the 5 seconds waiting time was an workaround... 😏 After all, the DataChannel has this magic And thanks for you kindness, and for time which you spent on my particular request! BTW, if you want to look in my current JS implementation of that Chat, it is there: https://github.com/nova-framework/framework/blob/3.0/app/Modules/Chat/Views/Chat/Index.php |
Another thing... Is there a way in the DataChannel to customize the used ICE servers? |
First of all, congratulations for this wonderful project! It is ideal for implementing a public and/or private chat.
BUT, what I miss is the ability to send some local user metadata on connection and/or with the messages.
That will permit to have the ability to display some shiny list of user on-line, or message.
I made an implementation sending (back) JSON messages, resulting something like in the folowing screenshot, BUT it complicate a bit the logic.
So, I need to do something like:
IF there would be the ability to specify some metadata for the local User, the code would be greatly simplified and would not be a need to encode in the JSON the messages. For example:
Where to add that User Medata? I think at beginning, something like:
BTW, in the previous snippet, I used a piece from a PHP application.
The text was updated successfully, but these errors were encountered: