根据在线人数路由

This commit is contained in:
luying
2022-08-12 09:39:56 +08:00
parent 3e2c408645
commit 1313f0777f
7 changed files with 143 additions and 15 deletions
+22 -10
View File
@@ -9,9 +9,9 @@ export function chat(session: Session, msg: any, app: Application, cb: (err: Err
cb(new Error('can not find chat servers.'));
return;
}
let id = session.get('chatServer')||dispatch(session.get('roleId'), chatServers, 'chat').id;
let res = dispatch(session.get('roleId'), chatServers, 'chat');
cb(null, res.id);
cb(null, id);
}
export function battle(session: Session, msg: any, app: Application, cb: (err: Error, serverId?: string) => void) {
@@ -38,8 +38,8 @@ export function battle(session: Session, msg: any, app: Application, cb: (err: E
}
}
let res = dispatch(rid, battleServers, 'battle');
cb(null, res.id);
let id = session.get('battleServer')||dispatch(rid, battleServers, 'battle').id;
cb(null, id);
}
@@ -89,8 +89,8 @@ export function guild(session: Session, msg: any, app: Application, cb: (err: Er
}
}
let res = dispatch(rid, guildServers, 'guild');
cb(null, res.id);
let id = session.get('guildServer')||dispatch(rid, guildServers, 'guild').id;
cb(null, id);
}
export function activity(session: Session, msg: any, app: Application, cb: (err: Error, serverId?: string) => void) {
@@ -99,8 +99,8 @@ export function activity(session: Session, msg: any, app: Application, cb: (err:
cb(new Error('can not find activity servers.'));
return;
}
let res = dispatch(session.get('roleId'), activityServers, 'activity');
cb(null, res.id);
let id = session.get('activityServer')||dispatch(session.get('roleId'), activityServers, 'activity');
cb(null, id);
}
export function gm(session: Session, msg: any, app: Application, cb: (err: Error, serverId?: string) => void) {
@@ -115,6 +115,18 @@ export function gm(session: Session, msg: any, app: Application, cb: (err: Error
cb(null, res.id);
}
export function role(session: Session, msg: any, app: Application, cb: (err: Error, serverId?: string) => void) {
let roleServers = app.getServersByType('role');
if (!roleServers || roleServers.length === 0) {
cb(new Error('can not find activity servers.'));
return;
}
let id = session.get('roleServer')||dispatch(session.get('roleId'), roleServers).id;
cb(null, id);
}
export function order(session: Session, msg: any, app: Application, cb: (err: Error, serverId?: string) => void) {
let orderServers = app.getServersByType('order');
@@ -123,6 +135,6 @@ export function order(session: Session, msg: any, app: Application, cb: (err: Er
return;
}
let res = dispatch(session.get('roleId'), orderServers, 'order');
cb(null, res.id);
let id = session.get('orderServer')||dispatch(session.get('roleId'), orderServers, 'order').id;
cb(null, id);
}