Question

I am also creating a chat-application in nodejs. And it is very simple just for fun. I am using backbonejs in client side. Each of my chat-message is a model, which gets created, destroyed, edited by Backbone apis : fetch, destroy, save. I have the endpoints on server for each of this work.

I now want that two people can communicate with each other. I now need to push messages down from one user to another user. And then i met socket.io. It felt fairly easy to do this chat things in it. I re-coded my application with socketio. Backbone is used for creating views and managing them.

But now i am missing backbone rest api where i could get the message id and then could edit and destroy the message easily. Is there something inbuild in socket.io for this ? or should i create my own events and listen and send them ?

Is there a better way, i can structure my application. Am i using backbone in a wrong way ?

Was it helpful?

Solution

Backbone is a very generic library, so it's not a problem. If you're looking for a way to build your solution around socket.io, I'd suggest to extend from Backbone.Collection and wire it to socket.io connection using callbacks and Backbone events. For example implementation you can check how firebase does it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top