修改一些局部的变量

This commit is contained in:
zhl 2021-01-15 16:23:46 +08:00
parent 14f3cc5628
commit 795232ce2d

View File

@ -86,12 +86,12 @@ export class RankedLobbyRoom extends Room {
} }
this.onMessage("bye", (client: Client, message: any) => { this.onMessage("bye", (client: Client, message: any) => {
const stat = this.stats.find(stat => stat.clients.has(client.sessionId)); const stat = this.stats.find(obj => obj.clients.has(client.sessionId));
if (stat && stat.group && typeof (stat.group.confirmed) === "number") { if (stat && stat.group && typeof (stat.group.confirmed) === "number") {
stat.confirmed = true; stat.confirmed = true;
stat.group.confirmed++; stat.group.confirmed++;
stat.clients.delete(client.sessionId); //stat.clients.delete(client.sessionId);
client.leave(); client.leave();
} }
}) })
@ -339,12 +339,16 @@ export class RankedLobbyRoom extends Room {
await Promise.all(group.clients.map(async (client) => { await Promise.all(group.clients.map(async (client) => {
const matchData = await matchMaker.reserveSeatFor(room, client.options);
/** /**
* Send room data for new WebSocket connection! * Send room data for new WebSocket connection!
*/ */
for (let [,data] of client.clients) { for (let [,data] of client.clients) {
let matchOpt = {
seat: data.seat
}
Object.assign(matchOpt, data.options);
const matchData = await matchMaker.reserveSeatFor(room, matchOpt);
let options: any = {seat: data.seat, rank: data.options.rank}; let options: any = {seat: data.seat, rank: data.options.rank};
Object.assign(options, matchData); Object.assign(options, matchData);
data.client.send("match_success", options); data.client.send("match_success", options);
@ -377,7 +381,7 @@ export class RankedLobbyRoom extends Room {
} }
onLeave(client: Client, consented: boolean) { onLeave(client: Client, consented: boolean) {
const stat = this.stats.find(stat => stat.clients.has(client.sessionId)); const stat = this.stats.find(obj => obj.clients.has(client.sessionId));
if (stat.clients.size > 1) { if (stat.clients.size > 1) {
stat.clients.delete(client.sessionId); stat.clients.delete(client.sessionId);
let data = [...stat.clients.values()][0]; let data = [...stat.clients.values()][0];