var React = require('react-native')
window.navigator.userAgent = "react-native";
var socketIOClient = require('socket.io-client/socket.io');
its working but if i add
var sailsIOClient = require('sails.io.js/sails.io.js');
var io = sailsIOClient(socketIOClient);
io.sails.url = 'http://localhost:1337';
i have error unable to resolve module request
npm install request --save
Error again unable to resolve module http (core module). Trouble
Hi @udanpe! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.
Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.
_If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]._
How to use socket.io without sails.io
var socket = io('localhost:1337?__sails_io_sdk_version=0.13.6');
socket.on('connect', function(){
socket.emit('get', {"method":"get","headers":{},"data":{},"url":"/hello"});
socket.on('message', function(data){
console.log(data);
})
console.log('connected');
})
sails.sockets.join(req, 'room', function(err) {
// sails.sockets.broadcast('room', {message: 'broadcast'});
});
sails.io.emit('message', 'emit');
End Error!
When send string (not object) using broadcast message not sending and no error!
Hi @udanpe! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.
Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.
_If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]._
@udanpe we had the same issue internally, we had to create a version of sails.io.js with the require request stuff removed and some other things, try our version: https://gist.github.com/Salakar/54933dc90049202e4290a989decab433
See lines 497 - 511 for the code that caused the issues. Will probably do a pull request for this sometime to replace 'request' with a multi platform compatible lib such as fetch 'fetch' or axios;
Other changes:
@mikermcneil

@udanpe should probably also create any new issues for this on the sails.io.js repo -https://github.com/balderdashy/sails.io.js
Hi @udanpe. If you care to open this in the sails.io.js repo, and provide a _full repo we can use to reproduce the problem_, we'll take a closer look!
I've found this repo but there is not so much informations on how it works.
From this answer you just have to do :
io.sails.useCORSRouteToGetCookie = false
Most helpful comment
@udanpe we had the same issue internally, we had to create a version of sails.io.js with the require request stuff removed and some other things, try our version: https://gist.github.com/Salakar/54933dc90049202e4290a989decab433
See lines 497 - 511 for the code that caused the issues. Will probably do a pull request for this sometime to replace 'request' with a multi platform compatible lib such as fetch 'fetch' or
axios;Other changes:
@mikermcneil

@udanpe should probably also create any new issues for this on the sails.io.js repo -https://github.com/balderdashy/sails.io.js