Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource Management with Websockets in Node.js

I'm currently using express-static to serve static content, and express-resource to handle all of the ajax requests coming from my backbone models. I want my site to feel alive, so obviously it's time to throw some websockets (socket.io) at the problem!

While doing that, I've noticed a lot of redundancy in my code, and am not convinced I need all these ajax calls anymore. I've been contemplating replacing my ajax requests with websockets entirely!

Seems pretty straightforward, replace the default backbone.sync with socket.emit calls. ezpz

My question is, are there any thoughts on the proper way to do resource management (like in express-resource) with websockets?

My best thought is to have urls that include the "action" (new, create, show, edit, update, destroy), such as "show/resourceName/resourceId" or "destroy/resourceName/resourceId".

Any thoughts? All opinions welcome! (As a note, I'm ok with the fact that this won't work for some mobile carriers, ancient versions of IE, and other constraints that are frustrating to us developers)

like image 342
user1161657 Avatar asked Jan 01 '26 21:01

user1161657


1 Answers

Not sure if you've already seen this or not, but there's a project which is an override of Backbone.sync and a server-side component using socket.io:

https://github.com/scttnlsn/backbone.io

If its not directly usable for you, it certainly contains some ideas and guidance.

like image 148
Edward M Smith Avatar answered Jan 03 '26 09:01

Edward M Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!