Commit c4009ceb authored by 范雪寒's avatar 范雪寒

test:

parent e9b3f3af
...@@ -123,6 +123,7 @@ export class NetworkHelper { ...@@ -123,6 +123,7 @@ export class NetworkHelper {
console.log("this.room = " + JSON.stringify(this.room.roomInfo)); console.log("this.room = " + JSON.stringify(this.room.roomInfo));
} }
player: MGOBE.Player;
joinRoom(roomType: string, maxPlayers: number, customData: string = "") { joinRoom(roomType: string, maxPlayers: number, customData: string = "") {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const playerName = "Tom" + Math.random(); const playerName = "Tom" + Math.random();
...@@ -149,6 +150,7 @@ export class NetworkHelper { ...@@ -149,6 +150,7 @@ export class NetworkHelper {
const player = event.data.roomInfo.playerList.find( const player = event.data.roomInfo.playerList.find(
(player) => player.name == playerName (player) => player.name == playerName
); );
this.player = player;
if (this.checkRoomOwnerOffLine()) { if (this.checkRoomOwnerOffLine()) {
if (this._eventListeners["playerOffLine"]) { if (this._eventListeners["playerOffLine"]) {
this._eventListeners["playerOffLine"](event); this._eventListeners["playerOffLine"](event);
...@@ -180,7 +182,7 @@ export class NetworkHelper { ...@@ -180,7 +182,7 @@ export class NetworkHelper {
dismissRoom() { dismissRoom() {
const roomInfo = this.room.roomInfo; const roomInfo = this.room.roomInfo;
const player = roomInfo.playerList.find( const player = roomInfo.playerList.find(
(player) => player.name == playerName (player) => player.name == this.player.name
); );
if (roomInfo.owner == player.id) { if (roomInfo.owner == player.id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -312,10 +314,10 @@ export class NetworkHelper { ...@@ -312,10 +314,10 @@ export class NetworkHelper {
async onDestroy() { async onDestroy() {
try { try {
console.log("onDestroy1"); console.log("onDestroy1");
this.dismissRoom();
MGOBE.Listener.clear(); MGOBE.Listener.clear();
this.stopFrameSync(); this.stopFrameSync();
this.closeRoom(); this.closeRoom();
this.dismissRoom();
this.leaveRoom(); this.leaveRoom();
console.log("onDestroy2"); console.log("onDestroy2");
} catch (e) { } catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment