I want to make public WebSocket API with sails.js. So I'd like to use native WebSockets instead of the built-in socket.io but with Sails.js controllers and models. Is it possible? Maybe I can implement custom transport or something else. Thanks for any help.
Asked
Active
Viewed 2,044 times
9
-
What is the reason for not using built-in socket.io.?? – Mahammad Adil Azeem Jul 04 '14 at 06:34
-
API will be public and I don't want to make users use socket.io protocol. They can make their own clients on any platform and there may be no socket.io implementation. – kmakarychev Jul 04 '14 at 06:42
-
But if there is no socket.io implementation on the other side how would you be communicating on sockets..?? – Mahammad Adil Azeem Jul 04 '14 at 06:43
-
3Socket.io and WebSocket are different things. For example there is no socket.io implementation in QT but there is WebSocket. – kmakarychev Jul 04 '14 at 06:51
-
You can refer to this question.. I hope it will be of great help.. http://stackoverflow.com/questions/16392260/which-websocket-library-to-use-with-node-js – Mahammad Adil Azeem Jul 04 '14 at 06:55
-
2I read that post. My question is how to connect native WebSocket or [ws](https://github.com/einaros/ws) to sails.js. – kmakarychev Jul 04 '14 at 09:10
-
2@akshob I wrote custom hook: https://github.com/provectus/sails-userhooks-ws – kmakarychev Nov 26 '14 at 11:47
-
@kmakarychev Can you add that as an answer? It seems like others have the same question and would find it useful. – Aaron Dufour Jun 01 '15 at 16:48
2 Answers
3
I implemented WebSockets support for Sails.js as a custom hook: https://github.com/provectus/sails-userhooks-ws

kmakarychev
- 731
- 4
- 14