Parse.com OpenTok Integration Error
I'm building an app using this tutorial (using using parse.com and OpenTok). When I initiate a call, the following delegate method -- session:(OTSession *)session streamCreated:(OTStream *)stream delegate method never gets called. I have searched around and it seems others have had this error but no one seems to have found a solution.
The cloud code module deployed on the parse servers seems to execute fine without errors and give no issues. But the video stream is never initiated.
The streamCreated method looks like this:
-(void)session:(OTSession *)session streamCreated:(OTStream *)stream {
NSLog(@"session: didReceiveStream:");
NSLog(@"- connection.connectionId: %@", stream.connection.connectionId);
NSLog(@"- connection.creationTime: %@", stream.connection.creationTime);
NSLog(@"- session.sessionId: %@", stream.session.sessionId);
NSLog(@"- streamId: %@", stream.streamId);
NSLog(@"- creationTime %@", stream.creationTime);
NSLog(@"- name %@", stream.name);
NSLog(@"- hasAudio %@", (stream.hasAudio ? @"YES" : @"NO"));
NSLog(@"- hasVideo %@", (stream.hasVideo ? @"YES" : @"NO"));
if ( (subscribeToSelf && [stream.connection.connectionId isEqualToString: _session.connection.connectionId])
||
(!subscribeToSelf && ![stream.connection.connectionId isEqualToString: _session.connection.connectionId])
) {
if (!_subscriber) {
_subscriber = [[OTSubscriber alloc] initWithStream:stream delegate:self];
_subscriber.subscribeToAudio = self.bAudio;
_subscriber.subscribeToVideo = self.bVideo;
}
NSLog(@"subscriber.session.sessionId: %@", _subscriber.session.sessionId);
NSLog(@"- stream.streamId: %@", _subscriber.stream.streamId);
NSLog(@"- subscribeToAudio %@", (_subscriber.subscribeToAudio ? @"YES" : @"NO"));
NSLog(@"- subscribeToVideo %@", (_subscriber.subscribeToVideo ? @"YES" : @"NO"));
}
}
Does anyone have any ideas at all? I'm new to OpenTok and would appreciate any advice. Thanks in advance.
For the complete project code, see the linked tutorial. I have not modified the code in any way with the exception of implementing the API secret for OpenTok and my Parse credentials. I have also hosted the .h and .m files on this dropbox page.
You never call [session publish:publisher error:&error];
. There will be no streamCreated event if no stream is ever published.
I did not read the entire tutorial, but I did take a look at the linked .m file from your DropBox. From the portion of the tutorial that I did read, I found plenty of misinformation and the explanations are more complicated than they should be. I suggest going directly to the OpenTok Tutorials and following the iOS sections.
In terms of how to integrate Parse (not covered in the tutorials), the most important thing you need to know is that Parse is just responsible for serving the appropriate apiKey
, sessionId
, and token
; nothing else. The apiKey
should always be the same. The sessionId
should be the same if the clients need to be able to communicate with each other. Lastly, each client should get a unique token
(this is one of the places where the blog post you linked is incorrect, and you should not store just one publisherToken
for the entire session). The Parse cloud code module can help you generate new sessionId
s when you want and new token
s for each client. For a better explained example, see a blog post I wrote on the official blog some time ago. Some of the information in it is old, but its still accurate.