The Sails hook behaves identical to the SocketIo hook, except for the implementation. The big callout here is that
you need to install both the
socket.io-client and the
sails.io.js package (that takes the socket.io client as
an argument). You also need to set the URL immediately after creating this object, as it will try to call out to
the server. Alternatively, you can set
io.sails.url.authConnect = false. I'm still playing with this implementation
a bit, but am leaning towards that solution (so that it doesn't make ANY server calls until you tell it to).
The other thing to point out is the
dispatch implementation. For the most part Sails used a message structure
data fields, but sometimes replaces
previous when it comes to updated and
deleted data. So the parse method has been modified to convert everything into a verb/data structure.
var _ = ;var WebSocketConnection = WebSocketConnection;var io = ;var SailsIOClient = ;var SOCKET_VERBS =CREATED: 'created'UPDATED: 'updated'DESTROYED: 'destroyed'ADDED_TO: 'addedTo';moduleexports = WebSocketConnection;