Child: [146b7d] (diff)

Download this file

mobile.js    57 lines (42 with data), 1.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
// var CONSTANTS = require('../lib/constants');
var initialized = false;
var NAMESPACE = '/mobileApp';
var mobileNamespace;
function init(dependencies) {
var logger = dependencies('logger');
var pubsub = dependencies('pubsub').global;
var io = dependencies('wsserver').io;
//console.log (io);
if (initialized) {
logger.warn('The contact notification service is already initialized');
return;
}
mobileNamespace = io.of(NAMESPACE);
//console.log ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
//console.log (mobileNamespace);
mobileNamespace.on('connection', function(socket) {
logger.info('New connection on ' + NAMESPACE);
setInterval(function(){
socket.emit('notification', { hello: 'world' });
},2000);
/*
setTimeout(function(){
console.log(io);
},5000);
*/
socket.on('messages', function (data) {
console.log(data);
});
// socket.on('subscribe', function(bookId) {
// logger.info('Joining contact room', bookId);
// socket.join(bookId);
// });
// socket.on('unsubscribe', function(bookId) {
// logger.info('Leaving contact room', bookId);
// socket.leave(bookId);
// });
});
initialized = true;
}
module.exports.init = init;