sails.io.js | Browser SDK for communicating w/ Sails via sockets | Runtime Evironment library
kandi X-RAY | sails.io.js Summary
kandi X-RAY | sails.io.js Summary
[NPM version] . JavaScript SDK for communicating w/ Sails via sockets from Node.js or the browser.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sails.io.js
sails.io.js Key Features
sails.io.js Examples and Code Snippets
Community Discussions
Trending Discussions on sails.io.js
QUESTION
I'm trying to use websockets with sails-js but I can't make it work with native javascript websockets.
the tutorial example use the sails.io.js library and it goes a little bit like this:
...ANSWER
Answered 2021-Jan-21 at 02:08Found a simple solution!
Used the npm package ws: npm i ws
making a new hook: sails generate hook customWebSocket
in the hook :
QUESTION
So, finally my MMORTS game built on Sails is going to Kongregate.
Had few obstacles, like connecting websockets, but solved now.
Probably the last obstacle is to keep authenticated session. I was using frameworks everywhere and i have no idea how does the authentication sessions work under the hood.
The main problem is probably the CSRF or CORS.
I am using Sails v1.0.
So, i start with HTML, which I upload to kongregate. I'm taking the simplest possible example:
ANSWER
Answered 2019-Mar-06 at 12:46Okey, since i had no answers (obviously - the question was bad), answering with my solution which i have solved by my self - so the next time i can read my self. Not sure how good it is, but at least it works.
Sails CORS is taken form Express.js and allows to connect sockets to kongregate if i allow it inside configs. But it does not allow to authenticate in a normal way, by sending sails.sid (authentication token) via cookies.
Chrome does not allow to set cookies with javascript (i dont have backend on Kongregate) to headers at all due to security. So, if i can't send cookies with headers, Sails can't authenticate the requests in a normal way. Even if i allow CORS to accept the 'cookie' header - it's not allowed by browsers to set cookie headers with javascript.
I can make some unique header like "authentication" and set the sails.sid there, extend some core functionality of Sails to take this new header instead of cookie header. But the problem - on Sails backed i was not able to get at all this sails.sid and send it to my external frontend.. Where it is created? How can i get sails.sid on Sails backend? Not sure - can't google it.
So, i just did authentication in a most simple way possible - on account login/register, i just create a session key by my self - with bcrypt hashing user_id+secret_token (taken from sails config secrets). and sending to the frontend { user_id: 'abcd', secret_token: 'a2dw412515...' }
I have made my policies in Sails to authenticate on every POST/GET request - take the request's session_id and user_id, and compare using bcrypt, does the session_id is the same as encrypted user_id+secret_token. I hope its secure enough.
So, it worked. I just had to disable CSRF. Maybe some day i will implement it again, I just have to write it in my way, not leave the Sails defaults.
QUESTION
Currently, I'm exploring web development to see what all the hype is about. Except for following a small 'create your first CRUD app in Node.JS' and some formal training in JavaScript, I have no experience.
I'm new to JavaScript, NodeJS, Sails.JS, and WebSockets.
My current problem is this:
The app I'm trying to develop receives POST calls with a JSON object. This is the input part of the application. These POST calls originate from any random host.
The output is a webpage that updates itself by listening on a Sails.JS powered WebSocket system called sails.io.js.
Basically, each POST from any host should result in an event on the WebSocket.
Since I'm not building a formal REST API, I have to define some parts myself in Sails.JS. I do have blueprints enabled.
First, in the controller that handles the POST call, I can call the code below so existing WebSockets can receive an event of a new ServiceHeartBeatSession being created. All the server side code mentioned here is located in the controller or executed in the console.
...ANSWER
Answered 2018-Aug-08 at 19:17sails.sockets.addRoomMembersToRooms(ServiceHeartBeatSession._classRoom()
, ServiceHeartBeatSession._room(session.id), () => {
ServiceHeartBeatSession.publish([ session.id ], { "verb": "created" });
});
QUESTION
I am developing an application with a sails backend and Angular 5 as the front end app.
I need to use the sails socket feature with the Angular 5 based app. I added a script tag which is
...ANSWER
Answered 2018-Feb-24 at 10:56Create a folder js
in your Angular 5 /src/assets/
directory.
Put the sails.io.js
file in your Angular 5 /src/assets/js/
folder.
Now in your index.html
give path like follow:
It will work fine.
QUESTION
First of all, thanks for clearing my doubt.
I want to use My .css and .js file in layout.ejs file i can do it by http://localhost:1337/js/sample.js but its difficult to load this kind of files in online server's since the port no and domain name changes. How to Use these files in layout file without going by URL method.
I tried with /js/sample.js and /**/js/sample.js Nothing is working and im frustrated.
I tried even pipeline method also
...ANSWER
Answered 2017-Oct-15 at 12:21If your project has the files:
assets/js/myscript.js
assets/styles/mystyle.css
Then the following should work in any served page (straight html resource, or anything returned from a template or view):
If that isn't working, some other process is causing a problem. My guess would be that you are doing sails lift
when you are developing on localhost, but doing sails lift --prod
in the online server.
Is that right? If so, Grunt (which comes with sails by default) may be handling some things differently between the dev and prod lifts. It may be that the files you are looking for are being concatenated and/or minified into some production.js
file, and no longer available one by one.
If this is the case, you will have to delve into the grunt processes (related to the pipeline.js
file, but lots of other too). You can test by doing --prod
lifts on localhost, and if you are free to play with the online server, you can also do non---prod
lifts there to see if things are working in that case.
QUESTION
I'm trying to connect my Angular 2 with sails using angular2-sails using the following line:
...ANSWER
Answered 2017-May-18 at 14:11after this line
add below line, it resolve the problem.
QUESTION
I have done Todo Application. There are 3 function: 1. View 2. Add Todo 3. Delete Todo I try to add the updateTodo function but it doesn't work. Please help to check the code. Please see my code as following: Todo Application HTML Page
index.html
...ANSWER
Answered 2017-Mar-16 at 10:36I don't see updateTodo()
function in app.js which is called in the line
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sails.io.js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page