0

I am trying to create session using openTok Nodejs. I don't get any error but the session isn't created.

var OpenTok = require('opentok'),
opentok = new OpenTok(vc_config.ot_api_key,  vc_config.ot_secret);

opentok.createSession({mediaMode:"routed"}, function(err, session) {
if (err) { return console.log(err); }
console.log(session);
this.session_id = session.sessionId;
});

thanks

1 Answer 1

0

The problem was a Promise issue, I solved this with:

       var opentok = new OpenTok(ot_api_key, ot_secret);

       await(opentok.createSession({mediaMode:"routed"}, function(error, session) {
       if (error) { return console.log(error); }
       return OtSessionDatum.findOne({ where: { id: modelId }}).then(function (ot_session_datum) {
         return ot_session_datum.update({session_id: session.sessionId,
                                         subscriber_token: session.generateToken({role: 'subscriber'}),
                                         publisher_token: session.generateToken({role: 'publisher'}),
                                         moderator_token: session.generateToken({role: 'moderator'}),
                                         watch_token: session.generateToken({role: 'moderator',data:'watch'})});

     }));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.