A quickstart guide for adding OpenTok functionality to your Hackathon application
The OpenTok platform, developed by TokBox, makes it easy to embed high-quality real-time interactive video, voice, messaging, and screen sharing into web and mobile apps.
The platform includes client-side libraries for web, iOS and Android, as well as server-side SDKs and a REST API.
In addition to adding real-time audio/video chat to web and mobile apps, the OpenTok platform provides a wide variety of features that can be used to develop innovative use-cases in almost any industry.
Here are just a few ways companies around the world are using OpenTok:
Here are some ideas of what you build during your Hackathon:
To see an example of OpenTok in action, you can check out our video conferencing demo below:
Sessions & Tokens
Every OpenTok video chat occurs within a session. You can think of a session as a “chat room” where clients (browser or mobile app) can publish and subscribe to one another's streams. Sessions are hosted on the OpenTok cloud, and each session is associated with a unique session ID. To allow multiple clients to chat with one another, you would simply have them connect to the same session ID.
A token is your “key” to the session and is generated for a specific Session ID. Each user should have his/her own token to connect to the session. These tokens expire after a certain period of time (specified by the developer), whereas the session does not.
Session IDs and Tokens are usually created using the server-side component of an OpenTok application, but if you’re just building a demo or proof of concept you can generate them in your Account - just go to your Project Overview page and scroll down to Project Tools.
Connections, Publishers & Subscribers
Once a client has a session ID and a token, it can establish a connection to the session using code from the client-side SDKs (see below). This connection dispatches an event to the session and any clients who are already connected. Once connected, the client can publish an audio/video stream from its camera and microphone
When a client publishes a stream, events are dispatched to all clients connected to the session. Upon receiving the event, the clients can subscribe to the newly published stream.
For more info on sessions, tokens, streams, and more, check out our Video API Basics page.
The client-side of an OpenTok app provides most of the functionality in an OpenTok application. The client uses the Session ID and token (see above) to connect the user to a session from a web browser or mobile app.
Basic video chat
To see how to set up the most basic client-side code on the web, check out our Hello World. For mobile development, you can clone or download our client-side sample apps for iOS Swift, iOS Objective-C and Android on Github.
Accelerator sample apps + extras
These sample apps include basic audio/video chat functionality along with user controls, built-in text-chat and some starter code for setting up screen sharing and archiving. For more info on setup and advanced features for these sample apps, view their READMEs on Github. You can customize the UI for these samples as much as you like using CSS.
Additional mobile samples
For more info on setting up the client-side code for your OpenTok application, check out our Developer Guides.
The server-side component of an OpenTok app is used to generate Session IDs and Tokens for application users. If you’re just building a demo or proof of concept, you might not need a server-side component - you can generate Session IDs and Tokens in the Project Overview page of your project in your TokBox Account (just open or create a project then scroll down to ' `Project Tools').
For more info on setting up server-side code, check out our Developer Guides.
In addition to basic video chat, OpenTok can be used for a variety of more advanced features. Our Accelerator sample apps above include code some of this functionality (screen sharing, archiving and text chat), but here are some helpful guides with some more information about setting up advanced features:
The Accelerator sample apps above include the starter code for screen sharing functionality, but you should also check out our screen sharing guides for Web, iOS, and Android. Usually, screen sharing on the web requires you to create a custom browser extension, but if you’re only using localhost to demo your app you can use this pre-made extension.
If you have a question or need help building your app, there are a few ways to reach us for a quick response: