Files
ZYZ/game-server/app/util/routeUtil.ts
2020-09-08 19:59:19 +08:00

27 lines
856 B
TypeScript

import { dispatch} from './dispatcher';
import { Session, Application } from 'pinus';
export function chat(session: Session, msg: any, app: Application, cb: (err: Error , serverId ?: string) => void) {
let chatServers = app.getServersByType('chat');
if(!chatServers || chatServers.length === 0) {
cb(new Error('can not find chat servers.'));
return;
}
let res = dispatch(session.get('rid'), chatServers);
cb(null, res.id);
}
export function battle(session: Session, msg: any, app: Application, cb: (err: Error , serverId ?: string) => void) {
let battleServers = app.getServersByType('battle');
if(!battleServers || battleServers.length === 0) {
cb(new Error('can not find battle servers.'));
return;
}
let res = dispatch(session.get('rid'), battleServers);
cb(null, res.id);
}