Browse Source

Created classes in server for room and player

master
Jeffery R 6 years ago
parent
commit
3c2cbec0a3
2 changed files with 71 additions and 1 deletions
  1. +55
    -1
      googletrendsgame/server/server.js
  2. +16
    -0
      googletrendsgame/server/utils.js

+ 55
- 1
googletrendsgame/server/server.js View File

@ -4,10 +4,64 @@ var io = require('socket.io')(http);
const port = 3000; const port = 3000;
var room = function(capacityP, roomN)
{
//max capacity of room -- default is 4 for now
this.capacity = capacityP;
//name of the room
this.roomName = roomN;
//list of words used in the game
this.words = [];
//list of clients sockets -- so we can push requests to them
this.users = [];
//increments when rounds pass
this.currentRoom = 0;
/**
* adds a user to a room
* @param socket
*/
this.addUser = function(socket)
{
}
}
var player = function(name)
{
//name of the user
this.name = name;
//score of the player
this.score = 0;
//reference to the room -- might not need this
this.room = null;
//
this.sumbission = null;
}
//list of all the rooms
var rooms = [];
//Whenever someone connects this gets executed //Whenever someone connects this gets executed
io.on('connection', function(socket) {
io.on('connection', function(socket)
{
console.log('A user connected'); console.log('A user connected');
socket.on('clientEvent', function(data) {
console.log(data);
});
//Whenever someone disconnects this piece of code executed //Whenever someone disconnects this piece of code executed
socket.on('disconnect', function () { socket.on('disconnect', function () {
console.log('A user disconnected'); console.log('A user disconnected');

+ 16
- 0
googletrendsgame/server/utils.js View File

@ -0,0 +1,16 @@
var words = [];
module.exports=
{
/**
* Returns a random word
* @returns {string}
*/
getRandomWord : function()
{
return '';
}
};

Loading…
Cancel
Save