I'm triying to develop a simple Hello World Websocket using Sails framework V0.12. I need to connect an external Basic Front-End (HTML,CSS,JS) to that Sails WebSocket server. Send a simple event and retrieving 'Hello World!!' I'm using Sails API sails.io.js.
I have tried this in Front-End
<!doctype html>
<html>
<head>
<script type="text/javascript" src="js/dependencies/sails.io.js"></script>
<script type="text/javascript">
window.onload = function() {
io.sails.url = 'http://localhost:1337';
io.socket.get('http://localhost:1337/helloworld', function(body, sailsResponseObject) {
console.log('Sails responded with: ', body);
console.log('with headers: ', sailsResponseObject.headers);
console.log('and with status code: ', sailsResponseObject.statusCode);
});
};
</script>
</head>
<body>
<ul id='messages'></ul>
<button onclick="pagar()">Click me</button>
</body>
</html>
I know that is connecting to Sails, but I I'm not able to get WebSocket response. Sails response is 404 (Not found). How can i create that WebSocket Using Sails Socket. Thanks a lot!