initial commit of poker game
This commit is contained in:
37
game-server/app/servers/gate/handler/gateHandler.js
Normal file
37
game-server/app/servers/gate/handler/gateHandler.js
Normal file
@@ -0,0 +1,37 @@
|
||||
var dispatcher = require('../../../util/dispatcher');
|
||||
|
||||
module.exports = function(app){
|
||||
return new Handler(app);
|
||||
};
|
||||
|
||||
var Handler = function(app){
|
||||
this.app = app;
|
||||
};
|
||||
|
||||
var handler = Handler.prototype;
|
||||
|
||||
/**
|
||||
* Gate handler that dispatch user to connectors.
|
||||
*
|
||||
* @param {Object} msg message from client
|
||||
* @param {Object} session
|
||||
* @param {Function} next next stemp callback
|
||||
*
|
||||
*/
|
||||
handler.queryEntry = function(msg, session, next){
|
||||
// get all connectors
|
||||
var connectors = this.app.getServersByType('connector');
|
||||
if(!connectors || connectors.length === 0){
|
||||
next(null, {
|
||||
code : 500
|
||||
});
|
||||
return;
|
||||
}
|
||||
// select connector
|
||||
var res = dispatcher.dispatch(1, connectors);
|
||||
next(null, {
|
||||
code : 200,
|
||||
host : res.host,
|
||||
port : res.clientPort
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user