-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.js
45 lines (37 loc) · 1.43 KB
/
Server.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
42
43
44
45
var io = require('socket.io')({ transports: ['websocket'], });
var Player = require("./API/DataModels/Player");
var Lobby = require("./API/DataModels/Lobby");
var SocketSettings = require("./API/ServerSettings/SocketServerSettings");
var ServerEvents = require("./API/ServerEvents/ServerEvents");
var lobby = new Lobby("Lobby1", 1);
console.log("Socket Server Started at port: " + SocketSettings.socketPort);
io.attach(SocketSettings.socketPort);
io.on('connection', function (socket) {
console.log('A user connected');
//socket.emit(ServerEvents.ON_CONNECTED);
var player=null;
socket.on(ServerEvents.REGISTER_USER, function (data) {
console.log('User Rregistering'+JSON.stringify(data));
// player=new Player(data.playerName,socket);
// var playerData={
// playerName:data.playerName,
// playerID:player.playerID
// }
// socket.emit(ServerEvents.ON_USER_REGISTER,playerData);
});
socket.on(ServerEvents.JOIN_ROOM, function () {
console.log("player joining room");
// var room=lobby.GetTheRoom();
// player.JoinRoom(room);
// //player.JoinGame();
});
socket.on(ServerEvents.LEAVE_ROOM, function (data) {
});
socket.on(ServerEvents.SEND_INPUT, function (data) {
console.log("Input Recieved"+JSON.stringify(data));
// player.ProcessInput(data);
});
socket.on("disconnect", function () {
console.log("user Disonnected");
});
});