React Native Video Calling App – Part 2

Welcome to the second part of React Native Video Calling App. If you have directly come to this page, you can check out small introduction about the app in the first part here :

In this part we will code a simple node server using node express library and make a simple client server communication. This client server communication will be the base of complete Video calling app we are going to do. We will code a dummy web based client which will help us to test the server, and also, same js code of web client we will use for our React Native Video Call App with some small modifications. So lets start.

First create a directory callingapp with mkdir command like this :

Now, create three files package.json, server.js and index.html in the director. Add the code below in the package.json file

Now, from the calling app directory run the command npm install like this

npm install command creates a directory node_modules and install the node js default libraries as well as packages listed under dependencies in package.json file.

Now, copy the code below in the server.js file

In the above code we have created a simple node js server. The server is listening at the port 4443 of localhost. When a new user/client gets connected it logs a ‘user connected’ message and when a client gets disconnected it logs ‘user disconnected’ message. Also, when client sends a message, it receives the message and send it back to the client ( which later we can use as acknowledgement for message received or forward it to another client).

Now, add the code below to the index.html file

In the above code we have created a html document and linked a socket.io.js. When the user opens the html page the client gets connected to the server. We have create a text box and a button. When the user enters some text and press the button it is sent to the server and server sends it back to the client which is then getting logged in the console.

So, here we conclude this part of tutorial and now we have a client and server which can communicated with each other. In the next part we will have multiple clients communicating with each other. To stay tuned subscribe to our news letter as well as our Youtube channel.

 

2 thoughts on “React Native Video Calling App – Part 2”

Leave a Reply

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