Sails.io.js - nodejs - Resourceful PubSub does not accept model events

I am trying to subscribe to a nodejs application for modeling sail events. Here is my code:

var socketIOClient = require('socket.io-client'), sailsIOClient = require('sails.io.js'); var io = sailsIOClient(socketIOClient); io.sails.url = 'http://localhost:1337'; io.socket.on("agent", function(event) { console.log(event); }) io.socket.get("/agent", function(resData, jwres) {}) 

Here is a link to all the output on the sails server when the client (nodejs) connects:

https://gist.github.com/CiscoKidxx/e5af93ebcc24702ba4f8

I understand that when creating a new agent, it should run console.log (event), which lists the changes. This is not happening. I run "now connected to sails" when I run the script. Any thoughts?

Here is my call to create a new agent in my UserController:

 Agent.create({ syncToken: token, owner: user.id }).exec(function (err, newAgent) { Agent.publishUpdate(newAgent.id, {syncToken: newAgent.syncToken}); 
+8
source share
1 answer

The server side code snippet above does not show the Agent.publishCreate call in the callback, but rather publishUpdate.

From what I understand, the publishCreate function starts automatically when you use drawings, but not for soft calls like your Agent.create above.

Therefore, changing this parameter from publishUpdate to publishCreate can be fixed in your context.

+6
source share

All Articles