3 var env
= require('gitter-web-env');
4 var logger
= env
.logger
;
7 var presenceService
= require('gitter-web-presence');
8 var bayeux
= require('../../web/bayeux');
10 module
.exports = function(req
, res
, next
) {
11 var socketId
= req
.body
.socketId
;
12 var on
= parseInt(req
.body
.on
, 10);
14 bayeux
.clientExists(socketId
, function(exists
) {
16 stats
.eventHF('eyeballs.failed');
17 stats
.eventHF('eyeballs.failed.invalid.socket');
19 logger
.warn('eyeball: socket ' + socketId
+ ' does not exist. ');
20 return res
.sendStatus(400);
23 presenceService
.clientEyeballSignal(req
.user
.id
, socketId
, on
, function(err
) {
25 stats
.eventHF('eyeballs.failed');
27 if (err
.invalidSocketId
) {
28 stats
.eventHF('eyeballs.failed.invalid.presence');
33 ' exists in the faye engine, but not in the presence service.'
35 bayeux
.destroyClient(socketId
);
37 return res
.sendStatus(400);
48 res
.send({ success
: true });