diff --git a/certificate/RSA-cert.pem b/certificate/RSA-cert.pem index 7a07dab..d605521 100644 --- a/certificate/RSA-cert.pem +++ b/certificate/RSA-cert.pem @@ -1,29 +1,29 @@ -----BEGIN CERTIFICATE----- -MIIE4zCCA8ugAwIBAgISBKkroyiDI8s2UhriA6ELDJ3dMA0GCSqGSIb3DQEBCwUA +MIIE4zCCA8ugAwIBAgISBAWtfXO4m+fOSxIBprZ/dGV3MA0GCSqGSIb3DQEBCwUA MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD -EwJSMzAeFw0yMzA2MjAwOTIyMjRaFw0yMzA5MTgwOTIyMjNaMBYxFDASBgNVBAMT -C2ppYW5taWF1LnRrMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzLvv -hFbHHrHnuFiq1/FLa5uGOq+uMP0MJFUcEwBri64PplXnzyH9bLjI13iBXijwsM+B -YjnInFzWuqArOg7N9/w+F+j9RlNCXhiLRFt9ahCduFwboa+V0/AsWnb6v40EqLHt -BfPWNfpCK3gat7gDNlEMVS3Ye53CLXlRLnMtOEieLNT7Wqqttmk9cfs+9P7tgLxQ -RzDaCeXPZv2xrEE5LNXCaHl65W9wBJzbHpHWbjmBw4yGDVnnmfooPWJMIHhHFi5u -tkwaXzja0tYVUuTh27ZwbZCtyOhubxJ6TYVU7c0Opl47C/6zuBGjeAwA+C49FPm5 -R4MLtVMIm9GCYTmKYQIDAQABo4ICDTCCAgkwDgYDVR0PAQH/BAQDAgWgMB0GA1Ud +EwJSMzAeFw0yMzEwMjYyMzMxNDlaFw0yNDAxMjQyMzMxNDhaMBYxFDASBgNVBAMT +C2ppYW5taWF1LnRrMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtZUS +uEOMp089fvgYY7qib+zODa/e2voRA8eEd/Ta0toTm9zvc8JLa8ji5gRiXs/0CCz5 +i7p+Moq5a774m81Oxw4EyXuod2tD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ICATE----- \ No newline at end of file diff --git a/certificate/RSA-privkey.pem b/certificate/RSA-privkey.pem index e993631..4d138ed 100644 --- a/certificate/RSA-privkey.pem +++ b/certificate/RSA-privkey.pem @@ -1,28 +1,28 @@ -----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMu++EVscesee4 -WKrX8Utrm4Y6r64w/QwkVRwTAGuLrg+mVefPIf1suMjXeIFeKPCwz4FiOcicXNa6 -oCs6Ds33/D4X6P1GU0JeGItEW31qEJ24XBuhr5XT8Cxadvq/jQSose0F89Y1+kIr -eBq3uAM2UQxVLdh7ncIteVEucy04SJ4s1Ptaqq22aT1x+z70/u2AvFBHMNoJ5c9m -/bGsQTks1cJoeXrlb3AEnNsekdZuOYHDjIYNWeeZ+ig9YkwgeEcWLm62TBpfONrS -1hVS5OHbtnBtkK3I6G5vEnpNhVTtzQ6mXjsL/rO4EaN4DAD4Lj0U+blHgwu1Uwib -0YJhOYphAgMBAAECggEAKUIKT5oJQIdLkhvUOfY3Y7UQxMzYhqjIBJ5eLPodsiVe -o/+V2mkYIAvQ9ZMkRuxrLMZ0ZW4Nnm0bHLrgWy/WlA3yGXFrcPugWUQK9LiXOoOk -tR1iuB+hSveQiJ6Hg4iQkspgYJ214mTPZuEqSTG8+/ozSQsXIDo3gmB7Wqf9SeUD -tBmItjTWY6XS31xhwzF6DBa5fzeN+D01pDrocl50MjNrXd0uUdy+SXYYud+N3SRs -LxDBLFQHikWNt+YVaW7RG0ZlGIyRVvM2QF/rONFEOLbQLA6Wi2SdU4OX22miZkmJ -TKs+kvlCsRvbUVE2jMYoTlQonTCWZ+vAIXfL3g1InQKBgQD9XZ2k1VvwJpnz2OpS -IYx7EUPCsAQ2KD5YzoigmrY6xLIR5gjqbM5d5VKwH6EyLn9TQ3SeC33w28ceT/y2 -DaGGFlhShBMKmxo1LBOQfJess67q0g/NVbyks9mbGxcjZqCP5wj8G7IHWtzH28rV -3T1EuM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ifafVTwWqmN/M9rKI4ZocHGE5BzhTB +9tf2Mr9mqLc/JpUCZSxw73pSJ6wx0rijIvx6AQ4BAoGAdxwdKeJUXCq2alk+n3uO +hdp76TKLrmJE219ZMCg0hbACTchE8RgbOiPFcx8l9/tCNPytKL4GeeH5RUSE27Qy ++jP0vck4Q4+QuUNCmzD4HpFtLLfEx2O4qRoPDd3C1NPc1qSlYIOJj89VoYwy52pr +7/Bwa9Ci20NJo61Pit7Ghf4= -----END PRIVATE KEY----- diff --git a/src/api/room/ApiExit.ts b/src/api/room/ApiExit.ts index 4f2a6a0..e89ca98 100644 --- a/src/api/room/ApiExit.ts +++ b/src/api/room/ApiExit.ts @@ -1,7 +1,11 @@ -import { ApiCall } from "tsrpc"; +import { ApiCall, BaseConnection } from "tsrpc"; +import Room from "../../component/Room/Room"; import { ReqExit, ResExit } from "../../shared/protocols/room/PtlExit"; +import { ServiceType } from "../../shared/protocols/serviceProto"; export default async function (call: ApiCall) { - // TODO - call.error("API Not Implemented"); + call.succ(0); + const conn: BaseConnection = call.conn; + const room: Room = conn.Room; + room.Exit(conn); } \ No newline at end of file diff --git a/src/component/Lobby/Lobby.ts b/src/component/Lobby/Lobby.ts index e90aa0d..4dd1670 100644 --- a/src/component/Lobby/Lobby.ts +++ b/src/component/Lobby/Lobby.ts @@ -28,12 +28,10 @@ export default class Lobby { /** DelConns */ public static DelConns(conn: BaseConnection): void { - for (let i: number = 0; i < this.conns.length; i++) { - if (this.conns[i] === conn) { - this.conns.splice(i, 1); - break; - } + if (conn.Room) { + conn.Room.Exit(conn); } + this.conns.splice(this.conns.indexOf(conn), 1); } // /** List */ diff --git a/src/component/Room/Room.ts b/src/component/Room/Room.ts index e7b5c66..e1852da 100644 --- a/src/component/Room/Room.ts +++ b/src/component/Room/Room.ts @@ -60,7 +60,10 @@ export default class Room { /** Exit */ public Exit(conn: BaseConnection): void { + this.conns.splice(this.conns.indexOf(conn), 1); server.broadcastMsg("room/Exit", 0, []>this.conns); + Room.rooms[this.RoomId] = null; + delete Room.rooms[this.RoomId]; } /** GotoGame */ @@ -102,6 +105,13 @@ export default class Room { } server.broadcastMsg("room/ChangeState", data, target); }); + if (conn) { + this.setState(conn, state); + } else { + this.conns.forEach((conn: BaseConnection) => { + this.setState(conn, state); + }); + } switch (state) { case EGameState.Ready: this.Ready(conn); @@ -111,6 +121,22 @@ export default class Room { this.TurnEnd(conn); break; + case EGameState.WaitNewGame: { + let canStart: boolean = true; + this.connData.forEach((connData: RoomConnData) => { + if (connData.state !== EGameState.WaitNewGame) { + canStart = false; + } + }); + if (canStart) { + this.conns.forEach((conn: BaseConnection) => { + this.setState(conn, EGameState.Ready); + }); + this.Ready(conn); + } + break; + } + default: break; } @@ -138,9 +164,7 @@ export default class Room { public Ready(conn: BaseConnection): void { const self: this = this; const cardCount: number = 24; - const data: RoomConnData = this.connData.get(conn); - data.state = EGameState.Ready; - this.connData.set(conn, data); + this.setState(conn, EGameState.Ready); let canStart: boolean = true; this.connData.forEach((connData: RoomConnData) => { if (connData.state === undefined || connData.state !== EGameState.Ready) { @@ -179,6 +203,13 @@ export default class Room { //#region Custom + /** setState */ + private setState(conn: BaseConnection, state: EGameState): void { + const data: RoomConnData = this.connData.get(conn); + data.state = state; + this.connData.set(conn, data); + } + /** Join */ public Join(conn: BaseConnection): void { this.conns.push(conn);