I've wrote a simple app and tested in Chrome. All works fine! Now I'm testing with qupzilla, but when I trigger the .emit function, nothing happens! From chrome i wrote a thing, the object is updated and sent to server, server does a broadcast. All fine (qupzilla receives the update too). But, if I write something on qupzilla, this update isn't sent to server (No logs in node)
Here's some code.
Server side:
var io = require('socket.io').listen(8080);
io.set("log level", 1);
var dataStored = [];
io.sockets.on('connection', function (socket) {
socket.emit('event', dataStored);
socket.on('update', function (data) {
console.log(data);
dataStored = data;
socket.broadcast.emit("event", data);
});
});
And client side:
$scope.things = [];
$scope.pushingObj = "";
// socket
var socket = io.connect("http://localhost:8080", {
'connect timeout': 500,
reconnect: true,
'reconnection delay': 500,
'reopen delay': 500,
'max reconnection attempts': 10000
});
socket.on("event", function(data) {
$scope.things = data;
$scope.$apply();
});
//
$scope.pushObj = function() {
//console.log($scope.pushingObj);
$scope.things.push($scope.pushingObj);
socket.emit("update", $scope.things);
$scope.pushingObj = "";
}