I have problem with emiting data by android application to node.js server.
node.js server:
var app = require('http').createServer()
var io = require('socket.io')(app);
app.listen(1000);
app.on('connection', function (client) {
client.name = client.remoteAddress + ':' + client.remotePort;
console.log(client.name + ' connected!');
client.on('sensorChanged', function (data) {
console.log(data);
});
});
and it's Android application
private TextView txtView;
private SocketIO socket;
try {
socket = new SocketIO("http://localhost:1000");
socket.connect(this);
} catch (MalformedURLException e1) {
txtView.setText(e1.getMessage());
}
socket.emit("sensorChanged", "asd");
When I start application, server sees my phone, but when I emit event, server dont respond.
Do you have any idea where is the problem?
Copyright Notice:Content Author:「QueUe」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/25587339/socket-io-emit-data-by-android-application-to-node-js-server