WebRTC Opentok in Ruby On Rails for Text chat

17 March 2016 by Pandurang Waghulde No comments

This post will take you through adding text chat functionality using Opentok (a WebRTC platform) in Ruby on Rails. OpenTok is a WebRTC platform for embedding live video, voice, and messaging into your websites and mobile apps. Opentok has its own signalling server. We will be using the OpenTok signaling API.
First, we will make the basic setup for using Opentok service. Here we will be using ‘opentok’ ruby gem.

1) Add opentok gem to your Gemfile.

gem ‘opentok’

 

2) Then create a session that will attempt to transmit streams directly between clients.

Store session id and token somewhere in the database, so that you can use it later on.
Here token gets expired in 30 days(default value). You will need to regenerate after 30 days.

3) Now it’s time to connect to session that we have created above, Add this to your HTML page,

A signal is sent using the signal() method of the Session object. One can receive a signal by listening to a signal event dispatched by session object.
So, All clients who are connected to the same session and listening to same signal type(‘text_chat’ here) will receive a message as soon as someone publishes to channel ‘text_chat’.

Pandurang Waghulde

Follow me on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

More Reads

We learn, We share

Top 5 Hacks to Get the Best from your Indian Offshore Team

Getting the best out of an offshore team in India is always a challenging task, inspite of the obvious cost advantages. Timezone differences, communication challenges, project management, quality of the code delivered, are all real issues that clients face. The solution however is surprisingly simple. Having delivered quite a few offshoring projects successfully, we have put … Continue reading "Top 5 Hacks to Get the Best from your Indian Offshore Team"

A 5-Point Guide to Hiring the Right UX/UI Design Firm

Hiring the right UX/UI design team for your Mobile and Web development is never easy. What you see as an outstanding portfolio of work, may not guarantee a great end-product for you. You need to be aware of your product design needs, the constraints and the UX team’s strengths. And spend some time with the … Continue reading "A 5-Point Guide to Hiring the Right UX/UI Design Firm"

Next up home

Contact

Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)