add debug logs
This commit is contained in:
parent
df9b15002f
commit
f79364df97
@ -13,7 +13,7 @@ module.exports.init = function(io_ext, config) {
|
|||||||
if (ios) {
|
if (ios) {
|
||||||
// when a new socket connects
|
// when a new socket connects
|
||||||
ios.sockets.on('connection', function(socket) {
|
ios.sockets.on('connection', function(socket) {
|
||||||
console.log("New connection from " + socket.request.connection.remoteAddress + ":" + socket.request.connection.remotePort);
|
console.log('New connection from ' + socket.request.connection.remotePort);
|
||||||
// when it subscribes, make it join the according room
|
// when it subscribes, make it join the according room
|
||||||
socket.on('subscribe', function(topic) {
|
socket.on('subscribe', function(topic) {
|
||||||
if (socket.rooms.length === 1) {
|
if (socket.rooms.length === 1) {
|
||||||
@ -25,6 +25,7 @@ module.exports.init = function(io_ext, config) {
|
|||||||
if (enableMessageBroker) {
|
if (enableMessageBroker) {
|
||||||
// when it requests sync, send him all pending messages
|
// when it requests sync, send him all pending messages
|
||||||
socket.on('sync', function(ts) {
|
socket.on('sync', function(ts) {
|
||||||
|
console.log('Sync requested by ' + socket.request.connection.remotePort);
|
||||||
var rooms = socket.rooms;
|
var rooms = socket.rooms;
|
||||||
if (rooms.length !== 2) {
|
if (rooms.length !== 2) {
|
||||||
socket.emit('insight-error', 'Must subscribe with public key before syncing');
|
socket.emit('insight-error', 'Must subscribe with public key before syncing');
|
||||||
@ -36,6 +37,7 @@ module.exports.init = function(io_ext, config) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
throw new Error('Couldn\'t get messages on sync request: ' + err);
|
throw new Error('Couldn\'t get messages on sync request: ' + err);
|
||||||
}
|
}
|
||||||
|
console.log('\tFound '+messages.length+' message'+(messages.length !== 1?'s':''));
|
||||||
for (var i = 0; i < messages.length; i++) {
|
for (var i = 0; i < messages.length; i++) {
|
||||||
broadcastMessage(messages[i], socket);
|
broadcastMessage(messages[i], socket);
|
||||||
}
|
}
|
||||||
@ -44,6 +46,7 @@ module.exports.init = function(io_ext, config) {
|
|||||||
|
|
||||||
// when it sends a message, add it to db
|
// when it sends a message, add it to db
|
||||||
socket.on('message', function(m) {
|
socket.on('message', function(m) {
|
||||||
|
console.log('Message sent from ' + m.pubkey +' to '+m.to);
|
||||||
mdb.addMessage(m, function(err) {
|
mdb.addMessage(m, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw new Error('Couldn\'t add message to database: ' + err);
|
throw new Error('Couldn\'t add message to database: ' + err);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user