Skip to content Skip to sidebar Skip to footer

Future Of Socket Programming And Html5 Websocket And Rest Combined

I have created simple Socket Server in PHP and Make Chat Application with that. Socket server working on some port e.g. 127.0.0.1:9999 All clients connect with that IP:PORT and Sha

Solution 1:

I guess what you might have in mind is something like this:

Browser | +----> REST/HTTP ---> Web Server (REST) | | | (*) | | | v +-<--- WebSocket <--- WebSocket Server

The browser does REST/HTTP requests, and at the same time maintains a WebSocket connection to receive real-time notifications.

The browser does REST/CRUD requests to your Web/REST server, and when the REST server performs a CRUD operation, it not only answers to the requestor, but also sends out notification to others via WebSocket.

There are 2 important aspects:

First, WebSocket isn't enough, since it is only raw point-to-point messaging). You likely want some "Publish & Subscribe" schema on top of WebSocket, so that the CRUD operation on a given resource can send out a notification only to those browser/WebSocket clients that are interested and allowed to receive notification for the respective resource.

Second, depending on the technology of your Web server, you want to make the () as easy as possible (e.g. doing () by a simple HTTP request from your Web server to the WebSocket server).

Both of above is provided e.g. by Crossbar.io:

  • Crossbar.io is a WAMP router, and WAMP ("The Web Application Messaging Protocol") provides "publish & subscribe" over WebSocket.
  • Crossbar.io has a builtin HTTP-to-WAMP bridge that allows you to publish by doing a plain old HTTP request.

Please see here for an example.

Disclosure: I am affiliated with WAMP and Crossbar.io.

Post a Comment for "Future Of Socket Programming And Html5 Websocket And Rest Combined"