Integrate opentok video conferencing into parse.co

2019-03-16 21:56发布

问题:

This question is not only aimed at code but my app design as well.

I have an iphone app that requires opentok to handle the video/audio sessions. I have gone through basic samples but what I am confused about is session management.

For example, if my iphone app wants to call a user from a mapview, how do I do that if all I have is this user's location (coordinates)?

How do I ensure that the session I am publishing gets to that particular user somehow and that user subscribes to it? Currently I don't have any backend in my app. All I may have is location data of N users, who can possibly talk with each other through my iphone app, via opentok session. Let's just assume currently only 2 users per session is my requirement.

I also know there is some integration between opentok and parse but I simply can't gather everything in a neat pack and build it. I mean to ask, what should I store in Parse? What should I expect it to do automatically with opentok? And so on.

Any help or any code example where someone has opentok video integrated will be highly appreciated. If anyone uses parse for handling opentok sessions it would be the thing I want.

Update:

OK, I have parse set up and also have data under data tab. From this point, I wonder what all I need to do for the ability to incorporate opentok video? Broadcast tutorial is a starting point but does not put things quite in context, I still feel disconnected. Some more practical example is needed.

回答1:

I strongly felt that the tokbox tutorial was quite basic, accomplished the requirement but had steeper learning curve. So I ended up wrote out my own app-cum-tutorial:

I feel compelled to post it here: How To write your first iPhone Video Chat App using parse and opentok(tokbox)



回答2:

Whenever a person connects to Opentok, they need two things: session id and token

You can think of session ids as room ids. People who connect to the same session ids are able to talk to everyone else in the same session.

Tokens are just passwords to get into the session.

In your app, this may be the best flow:

  1. Two people using your app want to communicate with each other.
  2. Your app signals your server that they want to talk to each other.
  3. Your server will ask our server for a session id.
  4. Your server will generate a valid token that works for the session id.
  5. Your server will relay the session id and token to your two people.
  6. Both users will connect to the session using the session id and token, and then they will be able to talk to each other

If you can individually tackle each of those steps, it shouldn't be too hard.

It is up to your app implementation on how you will communicate that two users will want to start a session with each other. After that, you can follow the OpenTok documentations on how to do the rest of the steps (3-4 and 6)

References:

  • How to generate a session
  • How to generate a token

Please note that generating a session and a token should be done server-side, so the client does not see your api secret.