[mod] Room
This commit is contained in:
parent
2568a95cc4
commit
8a3e93e5d8
@ -6,7 +6,7 @@ export default async function (call: ApiCall<ReqLobbyList, ResLobbyList>) {
|
||||
const data: any[] = []
|
||||
for (let i = 0; i < Lobby.Room.length; i++) {
|
||||
const room = Lobby.Room[i]
|
||||
data.push(room.SerialNumber)
|
||||
data.push(room.RoomId)
|
||||
}
|
||||
call.succ(data)
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import Client from "../Client/Client"
|
||||
import { BaseConnection } from "tsrpc";
|
||||
|
||||
|
||||
/**
|
||||
* Room
|
||||
@ -7,13 +8,19 @@ export default class Room {
|
||||
|
||||
//#region public
|
||||
|
||||
public SerialNumber: number = 0
|
||||
static maxRoomId: number = 0;
|
||||
static rooms: { [roomId: number]: Room } = {};
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region public
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region private
|
||||
|
||||
private wsArr: Client[] = []
|
||||
private roomId: number = 0
|
||||
private conns: BaseConnection[] = [];
|
||||
|
||||
//#endregion
|
||||
|
||||
@ -22,9 +29,9 @@ export default class Room {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
constructor(serialNumber: number, ws: Client) {
|
||||
this.SerialNumber = serialNumber
|
||||
this.wsArr.push(ws)
|
||||
constructor() {
|
||||
// 给每个新房间生成一个唯一的 ID
|
||||
this.roomId = ++Room.maxRoomId;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@ -32,11 +39,8 @@ export default class Room {
|
||||
//#region Custom
|
||||
|
||||
/** Join */
|
||||
public Join(ws: Client): void {
|
||||
this.wsArr.forEach(otherWS => {
|
||||
// otherWS.SendClient()
|
||||
})
|
||||
this.wsArr.push(ws)
|
||||
public Join(conn: BaseConnection): void {
|
||||
this.conns.push(conn);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user