I am really struggling with opening a socket connection using sails.io and android. What I'm trying to achieve at the moment is just to print socketid in the sails.js server console.
Android side:
I am using the nkzwa library socket.io.client (compile 'com.github.nkzawa: socket.io-client: 0.4.2')
This is the code I use in android inside AsyncTask:
private Socket mSocket; { try { mSocket = IO.socket("http://192.168.0.80:3000/batches/"); } catch (URISyntaxException e) {} } @Override protected Void doInBackground(Void... params) { mSocket.connect(); mSocket.emit("getSocketID"); }
and my batch controller looks like this:
module.exports = { getSocketID: function(req, res) { if (!req.isSocket) return res.badRequest(); var socketId = sails.sockets.id(req.socket);
When completing the task, I thought that I would get a console log displayed in my sail instance.
Can anyone see what I'm doing wrong?
source share