-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (33 loc) · 988 Bytes
/
index.js
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
var app, io, session, cookie, cookieParser, sessionStore, MobileDetect, Socket, SocketExtended, SetupHandshakes, toolkit;
// Config
var logging = false,
clients = [];
// Exporting module
module.exports = function(obj){
app = obj.app || null;
io = obj.io || null;
logging = obj.logging || logging;
if(!app || !io){
throw new Error('You must pass express and socket.io instance as arguments in the module function: mb = require("./socket.io-sync")({app:app, io:io})');
}
// Setting up handshakes
Setup = require('./lib/setup')({
app: app,
io: io,
logging: logging
});
// Extending Socket class
SocketExtended = require('./lib/socketExtended')({
sessionStore: Setup.sessionStore,
logging: logging,
Socket: obj.Socket || false,
});
// Toolkit
toolkit = require('./lib/toolkit');
// PUBLIC
this.randomPassword = toolkit.randomPassword;
this.clients = Setup.clients;
// Done
logging ? console.log('Module socket.io-sync loaded') : '';
return this;
}