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

fix: addPlayer null

parent 8f6f4d2a
import { Client } from "../leanCloud/play";
import { RandomInt } from "../script/util";
export class NetworkHelper {
......@@ -83,12 +84,15 @@ export class NetworkHelper {
this.room.players.push(this.room.player);
this.player = this.room.player;
this.client.off(globalThis.Play.Event.PLAYER_ROOM_LEFT);
this.client.on(globalThis.Play.Event.PLAYER_ROOM_LEFT, (event) => {
this.onLeaveRoom({ data: { leavePlayerId: event.leftPlayer.userId } });
});
this.client.off(globalThis.Play.Event.PLAYER_ROOM_JOINED);
this.client.on(globalThis.Play.Event.PLAYER_ROOM_JOINED, (event) => {
this.onJoinRoom({ playerId: event.newPlayer.userId });
});
this.client.off(globalThis.Play.Event.CUSTOM_EVENT);
this.client.on(globalThis.Play.Event.CUSTOM_EVENT, (event) => {
this.onRecvFrame({ data: event.eventData });
});
......@@ -175,6 +179,7 @@ export class NetworkHelper {
this.closeRoom();
this.dismissRoom();
this.leaveRoom();
await this.client.close();
console.log("onDestroy2");
} catch (e) {
console.log(JSON.stringify(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