2015-07-20 09:41:58 +00:00
|
|
|
"use strict";
|
|
|
|
|
2015-07-21 14:10:24 +00:00
|
|
|
var fs = require("fs");
|
|
|
|
var path = require("path");
|
2015-07-22 00:00:05 +00:00
|
|
|
var enslClient = require(path.join(__dirname, "../lib/ensl/client"))();
|
2015-07-21 14:10:24 +00:00
|
|
|
var chatController = require(path.join(__dirname, "../lib/chat/controller"));
|
2015-07-22 16:28:15 +00:00
|
|
|
var gatherController = require(path.join(__dirname, "../lib/gather/controller"));
|
2015-07-22 16:38:58 +00:00
|
|
|
var userController = require(path.join(__dirname, "../lib/user/controller"));
|
2015-07-22 15:35:40 +00:00
|
|
|
var winston = require("winston");
|
2015-07-21 14:10:24 +00:00
|
|
|
|
2015-07-20 09:41:58 +00:00
|
|
|
module.exports = function (io) {
|
2015-07-22 00:00:05 +00:00
|
|
|
var id = 2131;
|
|
|
|
|
2015-07-22 16:38:58 +00:00
|
|
|
var rootNamespace = io.of('/')
|
|
|
|
|
2015-07-21 00:24:14 +00:00
|
|
|
// Authorisation
|
2015-07-22 16:38:58 +00:00
|
|
|
io.use(function (socket, next) {
|
2015-07-22 00:00:05 +00:00
|
|
|
enslClient.getUserById({
|
|
|
|
id: id
|
|
|
|
}, function (error, response, body) {
|
2015-07-22 15:35:40 +00:00
|
|
|
if (error) {
|
|
|
|
winston.error(error);
|
|
|
|
return next(error)
|
|
|
|
};
|
2015-07-22 00:00:05 +00:00
|
|
|
socket._user = body;
|
|
|
|
next();
|
|
|
|
});
|
2015-07-21 00:24:14 +00:00
|
|
|
});
|
2015-07-20 22:47:18 +00:00
|
|
|
|
2015-07-22 16:38:58 +00:00
|
|
|
userController(rootNamespace);
|
2015-07-22 16:28:15 +00:00
|
|
|
chatController(rootNamespace);
|
|
|
|
gatherController(rootNamespace);
|
2015-07-20 22:47:18 +00:00
|
|
|
};
|