-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsocket.js
More file actions
31 lines (26 loc) · 874 Bytes
/
Copy pathsocket.js
File metadata and controls
31 lines (26 loc) · 874 Bytes
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
'use strict';
var logger = require('./logger');
var socketAuth = require('passport.socketio');
var translation = require('./api/translate');
var express = require('express');
exports.init = function(server, app, redisStore) {
var io = require('socket.io').listen(server);
io.set('authorization', socketAuth.authorize({
cookieParser: express.cookieParser,
key: 'connect.sid',
secret: app.config.session.secret,
store: redisStore,
success: function(data, accept) {
logger.debug('Successful socket.io auth');
accept(null, true);
},
fail: function(data, msg, err, accept) {
if (err) {
logger.error(err);
}
logger.debug('Socket.io auth error: ' + msg);
accept(null, false);
}
}));
translation.init(io);
};