Socket Client (
There are also a handful of community projects implementing Sails/Socket.io clients for native iOS, Android, and Windows Phone.
The Sails socket client (
sails.io.js) is a tiny browser library that is bundled by default in new Sails apps. It is a lightweight wrapper that sits on top of the Socket.IO client whose purpose is to make sending and receiving messages from your Sails backend as simple as possible.
The main responsibility of
sails.io.js is to provide a familiar ajax-like interface for communicating with your Sails app using WebSockets/Socket.io. That basically means providing
.delete() methods that let you take advantage of realtime features while still reusing the same backend routes you're using for the rest of your app. In other words, running
io.socket.post('/user') in your browser will be routed within your Sails app exactly the same as an HTTP POST request to the same route.
Can I use this with...
Yes. The Sails socket client can be used to great effect with any front-end framework-- no matter whether it's angular, backbone, ember, knockout, etc.
Do I have to use this?
No. The Sails socket client is extremely helpful when building realtime/chat features in a browser-based UI, but like the rest of the
assets/ directory, it is probably not particularly useful if you are building a native Android app, or an API with no user interface.
Fortunately, like every other boilerplate file and folder in Sails, the socket client is completely optional. To remove it, just delete
Is something missing?
If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.
- Blueprint API
- Command Line Interface
- Response (`res`)
- Waterline (ORM)
- Resourceful PubSub
- Socket Client
We wrote a book!
Get early access to the book
with promotion code: mcneildoc