Trying to publish a stream with custom name
using documentation:
session = OT.initSession(partnerId, sessionId); session.connect(token, error => { if (error) alert(error.message); else { const publisher = OT.initPublisher('mobile', { name: 'myCustomName', width: 720, height: 1280 // tried resolution: "720x1280" without luck }); session.publish(publisher); } });
Source: https://tokbox.com/developer/sdks/js/reference/Session.html#publish
I need this property to identify a publisher server-side and perform required actions in database.
Though I get Tokbox callback response in NodeJS but name
is always empty:
What’s wrong with the code and where to find the actual version?
Also how can one set custom names to streams/sessions for identifying purposes?
Advertisement
Answer
OpenTok Developer Advocate here.
Are you getting any callbacks with event: 'streamCreated'
or event: 'streamDestroyed'
?
Those events will contain a stream
object that will contain the name
property for that stream.
You can see the actual JSON payloads for each callback at https://tokbox.com/developer/guides/session-monitoring/#monitoring-streams
If you’d like to see the name data in the connectionCreated
and connectionDestroyed
callbacks then you could pass in the name when you generate the token for the user. Then the connection
object would contain the name within its data
property.
You can find a NodeJS example for generating the token with the name data at https://tokbox.com/developer/sdks/node/#generating-tokens