Yaron Vazana

NLP, Algorithms, Machine Learning, Data Science, tutorials, tips and more

  • About
  • Blog
  • Projects
  • Medium

Contact Me

yaronv99 [at] gmail.com

Powered by Genesis

You are here: Home / Web Development / Web-RTC Live Video Chat Room

Web-RTC Live Video Chat Room

January 8, 2015 by Yaron Leave a Comment

This project shows how to use Web-RTC technology and create a live video chat room based on the new tomcat 7 Websockets API and HTML5 Web-RTC. The server runs a single page where many users can login and chat with one another. Each user sees the same page with the videos of all other participants.

THIS IS NOT A FULL DIY TUTORIAL, IF YOU NEED HELP CONTACT ME

people chat

WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs.

The server code is written in Java and the client is written in Javascript (with some third parties like jQuery etc…). In order to use the WebSockets API, I used tomcat version 7.0.57, the WebSockets API was added to tomcat 7.0.X where X is between 1 and 57 (:
I can’t really remember the exact version.

The Client Side Code

ASSUMING YOU HAVE A TOMCAT SERVER UP AND RUNNING

Setting up a websocket server on the client side – this is the websocket which handles all the messaging between the users. I’ll use a separate websocket server for the video streams.

  • Create new WebSocket instance
  • Bind a message receive handler which executes each time a message arrives from the server
  • Define a send message function to send messages from the client
  • Define a close connection function – should be called when the user closes the window or exits

The video streams socket works almost the same with a few adjustments

To Summarize

I defined two websockets. One is for controlling the messaging between clients (chat messages, join room requests etc) and one for streaming the video between the peers. I could have done it with only one socket, but due to performance issues I chose to separate  them so each socket is doing less job.

The Server Side Code

This code is in charge of the chat room creation and users management. Each user sends a join request to the room admin, the admin send an approve or decline answer back to the user. The Server holds an Object with all the rooms and for each room, a list of the current participants. Video streams are passed from a client to a client directly, where all other messages are passed from a client to a client through the server.

The End

In this tutorial I tried to show the basic concepts and ideas for creating a live video chat rooms, those chat rooms can be extended to many other purposes (online games, chats, online help etc). I chose to publish only the major key classes and functionality so don’t expect to just Ctrl-C Ctrl-V (:

However, I’m always available for questions and clarifications.

Cheers

Filed Under: Web Development Tagged With: Chat, Javascript, Tomcat, Video, Web-RTC, Websockets

I am a data science team lead at Darrow and NLP enthusiastic. My interests range from machine learning modeling to solving challenging data related problems. I believe sharing ideas is where we all become better in what we do. If you’d like to get in touch, feel free to say hello through any of the social platforms. More About Yaron…

SUBSCRIBE TO BLOG

Subscribe to Blog

Subscribe to get the latest posts to your inbox

Recent Posts

  • Training an AutoEncoder to Generate Text Embeddings
  • Using Dockers for your Data Science Dev Environment
  • Identifying Real Estate Opportunities using Machine Learning
  • How to Create a Simple WhatsApp Chatbot in Python using Doc2vec
  • Average Word Vectors – Generate Document / Paragraph / Sentence Embeddings
  • Visualizing Vectors using TensorBoard
  • Training a Doc2Vec Model with Gensim
 

Loading Comments...