How to connect to user's stream in TokBox

旧街凉风 提交于 2020-01-06 02:56:09

问题


I'm making a 1 on 1 video call app using TokBox. I'm opening a session using this code:

[_session connectWithApiKey:kApiKey token:kToken];

after getting the didConnect message i'm publishing a stream on one user device using this code:

    _publisher = [[OTPublisher alloc] initWithDelegate:self];
    [_publisher setName:@"PublishName"];
    [_session publish:_publisher];
    [self.view addSubview:_publisher.view];
    [_publisher.view setFrame:CGRectMake(0, 0, widgetWidth, widgetHeight)];

What do I need to transfer to the other user in order for him to see what the first user publishes? I tried going through the docs but It's really unclear to me. Do I need a session ID? Publish ID?

Thanks.


回答1:


Think of sessions as rooms. People connected to the same session will be in the same room so they are able to see each other. Lets say you have 2 iPhones, A and B. After iPhone A calls [_session publish...], iPhone B will get a stream created event with A's video stream. Simply subscribe to that stream and B should be able to see As video.

You probably want to have a streamCreated delegate. In your streamCreated delegate, simply call [session subscribe...] to subscribe to the publishing stream.

For an example, check out the OpenTok HelloWorld Tutorial. Its a simple group video chat where everybody is publishing and subscribing to each other.



来源:https://stackoverflow.com/questions/22736569/how-to-connect-to-users-stream-in-tokbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!