1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-11-27 03:46:54 +00:00
not-gwent-online/server/server.js

35 lines
818 B
JavaScript
Raw Normal View History

2015-06-15 19:03:12 +00:00
var argv = require('minimist')(process.argv.slice(2));
2015-07-03 09:42:13 +00:00
2015-06-24 16:22:56 +00:00
global.connections = require("./Connections")();
global.matchmaking = require("./Matchmaker")();
global.Room = require("./Room");
global.User = require("./User");
/*global.Socket = require("./Socket");*/
var app = require('http').createServer();
global.io = require("socket.io")(app);
app.listen(16918);
2015-06-27 13:37:36 +00:00
io.on("connection", function(socket) { //global connection
2015-06-24 16:22:56 +00:00
var user;
connections.add(user = User(socket));
console.log("new user ", user.getName());
socket.on("disconnect", function() {
connections.remove(user);
user.disconnect();
console.log("user ", user.getName(), " disconnected");
user = null;
2015-07-01 17:51:09 +00:00
//io.emit("update:playerOnline", connections.length());
2015-06-24 16:22:56 +00:00
})
2015-07-01 17:51:09 +00:00
io.emit("update:playerOnline", connections.length());
2015-06-24 16:22:56 +00:00
})