initial commit of poker game
This commit is contained in:
6
game-server/app/util/dispatcher.js
Normal file
6
game-server/app/util/dispatcher.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var crc = require('crc');
|
||||
|
||||
module.exports.dispatch = function(uid, connectors){
|
||||
var index = Math.abs(crc.crc32(uid)) % connectors.length;
|
||||
return connectors[index];
|
||||
};
|
12
game-server/app/util/routeUtil.js
Normal file
12
game-server/app/util/routeUtil.js
Normal file
@@ -0,0 +1,12 @@
|
||||
var exp = module.exports;
|
||||
var dispatcher = require('./dispatcher');
|
||||
|
||||
exp.game = function(session, msg, app, cb){
|
||||
var gameServers = app.getServersByType('game');
|
||||
if(!gameServers || gameServers.length === 0){
|
||||
cb(new Error('can not find game servers.'));
|
||||
return;
|
||||
}
|
||||
var res = dispatcher.dispatch(1, gameServers);
|
||||
cb(null, res.id);
|
||||
};
|
Reference in New Issue
Block a user