Hacker News new | ask | show | jobs
by gregr401 4843 days ago
Cool, looking forward to watching the projects progress!

Quick question: when demonstrating the socket.io piece, one aspect that differs with meteor is their ddp which only sends data diffs on a per client basis, not the entire subset as your demo showed. How are you planning to tackle that with any decent about of clients or data size?

1 comments

Great question! I'm really pumped about more folks getting involved.

First off, you can manage pubsub as you like using Socket.io. The most important thing to realize about Sails is that we're not trying to be Meteor. This is for real, production projects, with a straightforward fallback to trusted technologies. How you manage publish and subscribe is completely up to you-- but if you're using the API blueprint, here's how it works from a pubsub perspective:

GET /user => the socket who issued this request is subscribed to the class room, and the instance rooms for all models returned (until the socket closes)

POST /user => the model created is "introduced" to the class room, subscribing all sockets connected to the class room, to IT. Then, all of the class room subscribers are notified that the new model has been created.

PUT /user/n => sockets subscribed to the instance room for the model being updated receive a message

DELETE /user/n => sockets subscribed to the instance room for the model being deleted receive a message and become unsubscribed

The "magic" here is actually just a controller- you can take a peek here (https://github.com/balderdashy/sails/blob/master/lib/scaffol...) for more about what's going on in the blueprint.