TokBox sessions getting destroyed

Viewed 1714

I'm trying to have clients publish a A/V stream, turn them off, and then turn them back on. The first time I tell them to publish and then unpublish, it works fine. However, the next time I tell them to publish (Using the same session ID and token), I get the error "Cannot Connect, the session is already undefined".

Why is the "session" getting destroyed?.. is it the unpublish? My code is pretty much taken from the tutorials:

    clientSession = OT.initSession(apiKey, sessionId);
    clientSession.connect(token, function (error) {
        if (error) {
            handleError(error);
        } else {
        clientPublisher = OT.initPublisher(container, {
        insertMode: 'append',
        width: '100%',
        height: '100%'
        }, handleError);
        }
    });
}

To unpublish:

clientSession.unpublish(clientPublisher);
1 Answers
Related