Comments (5)
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 extra
how you call it), to write that feature of a text Chat with a public room, and associated private chats. And its signaling server is simple enough to emulate it in another programming language and framework.
So, there is the question: you can add this extra
metadata to DataChannel, without complicating also its signaling server too much and you to give too much effort? 😄
Eventually, I can help a bit, but I am not a JS Guru, to be honest.
PS. Also channel.openOrJoin('room-id');
is a very nice feature to have... 🥇
from datachannel.
RTCMultiConnection and this library (DataChannel) both are using similar API.
RTCMultiConnection supports this: http://www.rtcmulticonnection.org/docs/extra/
You an set connection.extra
object before starting or joining room. You can set this object anytime during a live session a well.
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 onopen
, onmessage
, onclose
etc.) will pass event
object. That event object looks like this:
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 event.extra
object.
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
```
from datachannel.
I'll add extra
object in the next commit.
openOrJoin
relies on checkPresence
. Presence detection relies totally on server. Presence detection is not reliable if we handle it inside the browser i.e.
- Sent presence detection request to room owner
- Wait about 5 seconds for his response; if he doesn't replies then consider room "NOT Available"
- If room owner replies under 5 seconds, then simply join the room
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.
from datachannel.
Well, the 5 seconds waiting time was an workaround... 😏
After all, the DataChannel has this magic checkPresence()
today?
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
from datachannel.
Another thing...
Is there a way in the DataChannel to customize the used ICE servers?
from datachannel.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datachannel.