/
var
/
www
/
myprog.com.ua
/
server
/
node
/
ws
/
/var/www/myprog.com.ua/server/node/ws
mkdir
upload
Name
Size
Mode
Actions
hosts.js
23377
0644
edit
dl
rm
system.js
5215
0644
edit
dl
rm
users.js
23704
0644
edit
dl
rm
ws_server.js
1937
0644
edit
dl
rm
Edit:
/var/www/myprog.com.ua/server/node/ws/ws_server.js
(1937B)
const Session = require('../objects/session'); const Device = require('../objects/device'); const Host = require('../objects/host'); //let _self; class WsServer { constructor(core, io) { // if (!_self) { // //_self = this; // } this.core = core; this.io = io; //return _self; } run() { let _self = this; _self.io.on('connection', (socket) => { _self.accept_host(socket); _self.accept_user(socket); _self.accept_system(socket); socket.on('disconnect', function () { console.debug('CommandManager::disconnect()::' + socket.id); let session = _self.core.sessions_manager.get_session_by_socket(socket.id); if (session) { console.debug('CommandManager::session found::' + socket.id); if (session.is_host()) { console.debug('CommandManager::host::' + session.host.id); //let host = _self.core.service_hosts.get_host_by_socket_id(socket.id); _self.core.service_hosts.get_host_by_socket_id(socket.id).then((host) => { console.debug(host); if (host instanceof Host) { console.debug('CommandManager::make disconnect::' + host.id); host.disconnect(); host.online = 0; _self.core.service_hosts.update_host(host); } }); } _self.core.sessions_manager.remove_socket(socket.id); } }); }); }; } require('./hosts')(WsServer); require('./users')(WsServer); require('./system')(WsServer); module.exports = WsServer;
Save
cmd:
run