Categories : Article, Mobile Application, Phonegap
Adding websockets to the mix would be a great solution to create mobile apps that can work in every browser irrespective of the mobile device. Websockets can termed as protocols which allow bi-directional persistent communication between client (browser) and server. With an open websocket connection, client and browser can exchange messages between them at any time until the connection is closed.
The main feature of a chat application is the real time communication for which you need websockets. However, the websockets require a backend application to communicate with server and hence, it is required to develop node.js based server for the purpose. We use the NodeJS server to support HTML5 websockets. However, the websockets are supported by all browsers or servers. So, a compatibility test is done initially for the purpose which again requires socket.io. Socket.io is the websocket API that is used to test the websocket compatibility to find out if the connection will be established with the websocket or not. It provides an API for NodeJS which is very much similar to the client side API. The main purpose of using socket.io is to enable chat or communication where every person who connects with the client can send or push messages to the server and in turn the server pushes back the replies to all the connected clients. Hence, socket.io enables sending messages back and forth between the client device and server and therefore is required to enable continuous two way communication between client user and server that hosts the app’s services.
Therefore, with the advent of technologies like PhoneGap framework, Node.JS and WebSockets, chat app development for mobile devices is no longer a tedious and time consuming task.