2

Ok so sockets connects and everything. I can debugg the controller but when it gets to line return res.ok() it breaks. I also had a res.json({message: "hello"}). but i get the same error.

 /*** SocketController
 *
 * @description :: Server-side logic for managing Sockets
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

module.exports = {
  AddFolder: function(req, res) {
    // a socket request
    if (req.isSocket) {
      sails.log("Test");
      return res.ok();
    } else {
      return res.badRequest();
    }
  }
};

and this is how i call it.

var socketIOClient = require('socket.io-client');
var sailsIOClient = require('sails.io.js');

// Instantiate the socket client (`io`)
// (for now, you must explicitly pass in the socket.io client when using this library from Node.js)
var io = sailsIOClient(socketIOClient);

// Set some options:
// (you have to specify the host and port of the Sails backend when using this library from Node.js)
io.sails.url = 'http://localhost:1337';

io.socket.get('/Socket/AddFolder', function serverResponded (body, JWR) {
  // body === JWR.body
  console.log('Sails responded with: ', body);
  console.log('with headers: ', JWR.headers);
  console.log('and with status code: ', JWR.statusCode);

  // ...
  // more stuff
  // ...


  // When you are finished with `io.socket`, or any other sockets you connect manually,
  // you should make sure and disconnect them, e.g.:
  io.socket.disconnect();

  // (note that there is no callback argument to the `.disconnect` method)
});

The error that i get is:

TypeError: Right-hand side of 'instanceof' is not callable
index.js:31
    at _hasBinary (d:\Test\TestProject\backend\node_modules\has-binary\index.js:31:30)
    at hasBinary (d:\Test\TestProject\backend\node_modules\has-binary\index.js:58:10)
    at Object.socketIOClientCallback (d:\Test\TestProject\backend\node_modules\socket.io\lib\socket.js:369:16)
    at MockServerResponse._clientCallback (d:\Test\TestProject\backend\node_modules\sails-hook-sockets\lib\receive-incoming-sails-io-msg.js:219:17)
    at MockClientResponse.<anonymous> (d:\Test\TestProject\backend\node_modules\sails\lib\router\res.js:59:18)
    at MockClientResponse.emit (events.js:164:20)
    at finishMaybe (_stream_writable.js:616:14)
    at endWritable (_stream_writable.js:624:3)
    at MockClientResponse.Writable.end (_stream_writable.js:575:5)
    at MockServerResponse.onend (_stream_readable.js:598:10)
    at Object.onceWrapper (events.js:254:19)
    at MockServerResponse.emit (events.js:164:20)
    at endReadableNT (_stream_readable.js:1062:12)
    at process._tickCallback (internal/process/next_tick.js:152:19)

Can anybody help with this? I dont know why this is failing.

Thank you in advance.

user933306
  • 51
  • 5

1 Answers1

3

Ok i figured out what was the problem. If you have a model with name File.js this error occurs.

user933306
  • 51
  • 5