Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async _initSignal(Janus, session){
- let textPlugin;
- let stingId = Janus.randomString(5);
- let opaqueId = Number(new Date());
- let onSuccess = (pluginHandle) =>{
- textPlugin = pluginHandle;
- pluginHandle.send({
- message: {
- request: 'setup'
- }
- });
- };
- let onMessage = (msg, jsep) => {
- let error = msg.error;
- if (error){
- this.trigger('exception', error);
- }
- if (jsep){
- let answer = {
- jsep,
- media: {
- audio: false,
- video: false,
- data: true
- },
- success: (jsep) => {
- textPlugin.send({
- jsep,
- message: {
- request: 'ack'
- }
- });
- },
- error: this.onError.bind(this)
- };
- textPlugin.createAnswer(answer);
- }
- };
- let onDataOpen = (/*data*/) => {
- Janus.log("The DataChannel is available!");
- let transaction = Janus.randomString(12);
- let register = {
- textroom: 'join',
- transaction: transaction,
- room: this.textRoomId,
- username: stingId,
- display: stingId
- };
- textPlugin.data({
- text: JSON.stringify(register),
- error: this.onError.bind(this)
- });
- };
- let onData = (data) =>{
- let json = JSON.parse(data);
- let eventName = json["textroom"];
- if (eventName === 'success'){
- exempleResolveFunction()
- }
- if (eventName === 'message'){
- exampleGetMessage(json);
- }
- };
- session.attach({
- plugin: "janus.plugin.textroom",
- opaqueId: opaqueId,
- success: onSuccess,
- error: this.onError.bind(this),
- onmessage: onMessage,
- ondataopen: onDataOpen,
- ondata: onData
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement