initial commit of poker game

This commit is contained in:
Edward Yang
2015-03-20 14:21:44 -07:00
commit cd7f17778f
147 changed files with 10833 additions and 0 deletions

View 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];
};

View 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);
};