Today I had the idea of ββthe following setup. Create a nodejs
server along with express
and socket.io
. Using an expression, I create a RESTful API that connects to mongo. BackboneJS or similar will connect the client to this REST API.
Now every time mongodb changes (i.e., data is interested in it), socket.io fires an event for the client, which moves the cursor to the changed data. The client then runs the appropriate AJAX requests in REST to retrieve new data where necessary.
So socket.io connection will behave like a synchronization trigger. He will be present throughout the visit and can also manage sessions. All payload will be sent via http.
Pros:
- REST API for use with clients other than web
- Auth can be done completely through socket.io. Only send token along with REST requests.
- Take advantage of REST.
- Would also play well with a pub / support service like Redis'
Minuses:
- Greater overhead than using pure socket.io.
Do you think there are any big flaws that I did not think about?
bijan source share