much cleaner approach to group lock update
This commit is contained in:
parent
3a5aa3c3c5
commit
5a8cba24fa
@ -23,7 +23,6 @@ import {
|
|||||||
VariableMessage,
|
VariableMessage,
|
||||||
VariableWithTagMessage,
|
VariableWithTagMessage,
|
||||||
ServerToClientMessage,
|
ServerToClientMessage,
|
||||||
LockGroupMessage,
|
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||||
import { RoomSocket, ZoneSocket } from "src/RoomManager";
|
import { RoomSocket, ZoneSocket } from "src/RoomManager";
|
||||||
@ -550,8 +549,8 @@ export class GameRoom {
|
|||||||
this.positionNotifier.emitEmoteEvent(user, emoteEventMessage);
|
this.positionNotifier.emitEmoteEvent(user, emoteEventMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public emitLockGroupMessage(user: User, lockGroupMessage: LockGroupMessage) {
|
public emitLockGroupEvent(user: User, groupId: number) {
|
||||||
this.positionNotifier.emitLockGroupEvent(user, lockGroupMessage);
|
this.positionNotifier.emitLockGroupEvent(user, groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public addRoomListener(socket: RoomSocket) {
|
public addRoomListener(socket: RoomSocket) {
|
||||||
|
@ -21,7 +21,7 @@ import { Movable } from "_Model/Movable";
|
|||||||
import { PositionInterface } from "_Model/PositionInterface";
|
import { PositionInterface } from "_Model/PositionInterface";
|
||||||
import { ZoneSocket } from "../RoomManager";
|
import { ZoneSocket } from "../RoomManager";
|
||||||
import { User } from "../Model/User";
|
import { User } from "../Model/User";
|
||||||
import { EmoteEventMessage, LockGroupMessage, SetPlayerDetailsMessage } from "../Messages/generated/messages_pb";
|
import { EmoteEventMessage, SetPlayerDetailsMessage } from "../Messages/generated/messages_pb";
|
||||||
|
|
||||||
interface ZoneDescriptor {
|
interface ZoneDescriptor {
|
||||||
i: number;
|
i: number;
|
||||||
@ -140,10 +140,10 @@ export class PositionNotifier {
|
|||||||
zone.emitEmoteEvent(emoteEventMessage);
|
zone.emitEmoteEvent(emoteEventMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public emitLockGroupEvent(user: User, lockGroupMessage: LockGroupMessage) {
|
public emitLockGroupEvent(user: User, groupId: number) {
|
||||||
const zoneDesc = this.getZoneDescriptorFromCoordinates(user.getPosition().x, user.getPosition().y);
|
const zoneDesc = this.getZoneDescriptorFromCoordinates(user.getPosition().x, user.getPosition().y);
|
||||||
const zone = this.getZone(zoneDesc.i, zoneDesc.j);
|
const zone = this.getZone(zoneDesc.i, zoneDesc.j);
|
||||||
zone.emitLockGroupEvent(lockGroupMessage);
|
zone.emitLockGroupEvent(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public *getAllUsersInSquareAroundZone(zone: Zone): Generator<User> {
|
public *getAllUsersInSquareAroundZone(zone: Zone): Generator<User> {
|
||||||
|
@ -7,14 +7,13 @@ import {
|
|||||||
EmoteEventMessage,
|
EmoteEventMessage,
|
||||||
SetPlayerDetailsMessage,
|
SetPlayerDetailsMessage,
|
||||||
PlayerDetailsUpdatedMessage,
|
PlayerDetailsUpdatedMessage,
|
||||||
LockGroupMessage,
|
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
|
|
||||||
export type EntersCallback = (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => void;
|
export type EntersCallback = (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => void;
|
||||||
export type MovesCallback = (thing: Movable, position: PositionInterface, listener: ZoneSocket) => void;
|
export type MovesCallback = (thing: Movable, position: PositionInterface, listener: ZoneSocket) => void;
|
||||||
export type LeavesCallback = (thing: Movable, newZone: Zone | null, listener: ZoneSocket) => void;
|
export type LeavesCallback = (thing: Movable, newZone: Zone | null, listener: ZoneSocket) => void;
|
||||||
export type EmoteCallback = (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => void;
|
export type EmoteCallback = (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => void;
|
||||||
export type LockGroupCallback = (lockGroupMessage: LockGroupMessage, listener: ZoneSocket) => void;
|
export type LockGroupCallback = (groupId: number, listener: ZoneSocket) => void;
|
||||||
export type PlayerDetailsUpdatedCallback = (
|
export type PlayerDetailsUpdatedCallback = (
|
||||||
playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage,
|
playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage,
|
||||||
listener: ZoneSocket
|
listener: ZoneSocket
|
||||||
@ -111,9 +110,9 @@ export class Zone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public emitLockGroupEvent(lockGroupMessage: LockGroupMessage) {
|
public emitLockGroupEvent(groupId: number) {
|
||||||
for (const listener of this.listeners) {
|
for (const listener of this.listeners) {
|
||||||
this.onLockGroup(lockGroupMessage, listener);
|
this.onLockGroup(groupId, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ const roomManager: IRoomManagerServer = {
|
|||||||
message.getFollowabortmessage() as FollowAbortMessage
|
message.getFollowabortmessage() as FollowAbortMessage
|
||||||
);
|
);
|
||||||
} else if (message.hasLockgrouppromptmessage()) {
|
} else if (message.hasLockgrouppromptmessage()) {
|
||||||
socketManager.handleLockGroupMessage(
|
socketManager.handleLockGroupPromptMessage(
|
||||||
room,
|
room,
|
||||||
user,
|
user,
|
||||||
message.getLockgrouppromptmessage() as LockGroupPromptMessage
|
message.getLockgrouppromptmessage() as LockGroupPromptMessage
|
||||||
|
@ -39,7 +39,6 @@ import {
|
|||||||
SetPlayerDetailsMessage,
|
SetPlayerDetailsMessage,
|
||||||
PlayerDetailsUpdatedMessage,
|
PlayerDetailsUpdatedMessage,
|
||||||
GroupUsersUpdateMessage,
|
GroupUsersUpdateMessage,
|
||||||
LockGroupMessage,
|
|
||||||
LockGroupPromptMessage,
|
LockGroupPromptMessage,
|
||||||
RoomMessage,
|
RoomMessage,
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
@ -287,8 +286,7 @@ export class SocketManager {
|
|||||||
this.onClientLeave(thing, newZone, listener),
|
this.onClientLeave(thing, newZone, listener),
|
||||||
(emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) =>
|
(emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) =>
|
||||||
this.onEmote(emoteEventMessage, listener),
|
this.onEmote(emoteEventMessage, listener),
|
||||||
(lockGroupMessage: LockGroupMessage, listener: ZoneSocket) =>
|
(groupId: number, listener: ZoneSocket) => this.onLockGroup(groupId, listener, roomPromise),
|
||||||
this.onLockGroup(lockGroupMessage, listener, roomPromise),
|
|
||||||
(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) =>
|
(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) =>
|
||||||
this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener)
|
this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener)
|
||||||
)
|
)
|
||||||
@ -392,15 +390,11 @@ export class SocketManager {
|
|||||||
emitZoneMessage(subMessage, client);
|
emitZoneMessage(subMessage, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onLockGroup(
|
private async onLockGroup(groupId: number, client: ZoneSocket, roomPromise: PromiseLike<GameRoom> | undefined) {
|
||||||
lockGroupMessage: LockGroupMessage,
|
|
||||||
client: ZoneSocket,
|
|
||||||
roomPromise: PromiseLike<GameRoom> | undefined
|
|
||||||
) {
|
|
||||||
if (!roomPromise) {
|
if (!roomPromise) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const group = (await roomPromise).getGroupById(lockGroupMessage.getGroupid());
|
const group = (await roomPromise).getGroupById(groupId);
|
||||||
if (!group) {
|
if (!group) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -915,10 +909,7 @@ export class SocketManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
group.lock(message.getLock());
|
group.lock(message.getLock());
|
||||||
const lockGroupMessage = new LockGroupMessage();
|
room.emitLockGroupEvent(user, group.getId());
|
||||||
lockGroupMessage.setLock(message.getLock());
|
|
||||||
lockGroupMessage.setGroupid(group.getId());
|
|
||||||
room.emitLockGroupMessage(user, lockGroupMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +48,6 @@ export interface GroupCreatedUpdatedMessageInterface {
|
|||||||
locked: boolean;
|
locked: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LockGroupMessageInterface {
|
|
||||||
groupId: number;
|
|
||||||
lock: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GroupUsersUpdateMessageInterface {
|
export interface GroupUsersUpdateMessageInterface {
|
||||||
groupId: number;
|
groupId: number;
|
||||||
userIds: number[];
|
userIds: number[];
|
||||||
|
@ -40,7 +40,6 @@ import {
|
|||||||
PositionMessage_Direction,
|
PositionMessage_Direction,
|
||||||
SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto,
|
SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto,
|
||||||
PingMessage as PingMessageTsProto,
|
PingMessage as PingMessageTsProto,
|
||||||
LockGroupMessage,
|
|
||||||
} from "../Messages/ts-proto-generated/messages";
|
} from "../Messages/ts-proto-generated/messages";
|
||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
|
|
||||||
@ -102,9 +101,6 @@ export class RoomConnection implements RoomConnection {
|
|||||||
private readonly _groupUsersUpdateMessageStream = new Subject<GroupUsersUpdateMessageInterface>();
|
private readonly _groupUsersUpdateMessageStream = new Subject<GroupUsersUpdateMessageInterface>();
|
||||||
public readonly groupUsersUpdateMessageStream = this._groupUsersUpdateMessageStream.asObservable();
|
public readonly groupUsersUpdateMessageStream = this._groupUsersUpdateMessageStream.asObservable();
|
||||||
|
|
||||||
private readonly _lockGroupMessageStream = new Subject<LockGroupMessage>();
|
|
||||||
public readonly lockGroupMessageStream = this._lockGroupMessageStream.asObservable();
|
|
||||||
|
|
||||||
private readonly _groupDeleteMessageStream = new Subject<GroupDeleteMessageTsProto>();
|
private readonly _groupDeleteMessageStream = new Subject<GroupDeleteMessageTsProto>();
|
||||||
public readonly groupDeleteMessageStream = this._groupDeleteMessageStream.asObservable();
|
public readonly groupDeleteMessageStream = this._groupDeleteMessageStream.asObservable();
|
||||||
|
|
||||||
@ -268,10 +264,6 @@ export class RoomConnection implements RoomConnection {
|
|||||||
this._emoteEventMessageStream.next(subMessage.emoteEventMessage);
|
this._emoteEventMessageStream.next(subMessage.emoteEventMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "lockGroupMessage": {
|
|
||||||
this._lockGroupMessageStream.next(subMessage.lockGroupMessage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "playerDetailsUpdatedMessage": {
|
case "playerDetailsUpdatedMessage": {
|
||||||
this._playerDetailsUpdatedMessageStream.next(subMessage.playerDetailsUpdatedMessage);
|
this._playerDetailsUpdatedMessageStream.next(subMessage.playerDetailsUpdatedMessage);
|
||||||
break;
|
break;
|
||||||
|
@ -51,7 +51,6 @@ import { PathfindingManager } from "../../Utils/PathfindingManager";
|
|||||||
import { ActivatablesManager } from "./ActivatablesManager";
|
import { ActivatablesManager } from "./ActivatablesManager";
|
||||||
import type {
|
import type {
|
||||||
GroupCreatedUpdatedMessageInterface,
|
GroupCreatedUpdatedMessageInterface,
|
||||||
LockGroupMessageInterface,
|
|
||||||
MessageUserMovedInterface,
|
MessageUserMovedInterface,
|
||||||
MessageUserPositionInterface,
|
MessageUserPositionInterface,
|
||||||
OnConnectInterface,
|
OnConnectInterface,
|
||||||
@ -134,11 +133,6 @@ interface DeleteGroupEventInterface {
|
|||||||
groupId: number;
|
groupId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LockGroupEventInterface {
|
|
||||||
type: "LockGroupEvent";
|
|
||||||
event: LockGroupMessageInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PlayerDetailsUpdatedInterface {
|
interface PlayerDetailsUpdatedInterface {
|
||||||
type: "PlayerDetailsUpdated";
|
type: "PlayerDetailsUpdated";
|
||||||
details: PlayerDetailsUpdatedMessageInterface;
|
details: PlayerDetailsUpdatedMessageInterface;
|
||||||
@ -163,7 +157,6 @@ export class GameScene extends DirtyScene {
|
|||||||
| UserMovedEventInterface
|
| UserMovedEventInterface
|
||||||
| GroupCreatedUpdatedEventInterface
|
| GroupCreatedUpdatedEventInterface
|
||||||
| DeleteGroupEventInterface
|
| DeleteGroupEventInterface
|
||||||
| LockGroupEventInterface
|
|
||||||
| PlayerDetailsUpdatedInterface
|
| PlayerDetailsUpdatedInterface
|
||||||
>();
|
>();
|
||||||
private initPosition: PositionInterface | null = null;
|
private initPosition: PositionInterface | null = null;
|
||||||
@ -808,10 +801,6 @@ export class GameScene extends DirtyScene {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.connection.lockGroupMessageStream.subscribe((message) => {
|
|
||||||
this.lockGroup(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.connection.onServerDisconnected(() => {
|
this.connection.onServerDisconnected(() => {
|
||||||
console.log("Player disconnected from server. Reloading scene.");
|
console.log("Player disconnected from server. Reloading scene.");
|
||||||
this.cleanupClosingScene();
|
this.cleanupClosingScene();
|
||||||
@ -1847,10 +1836,6 @@ ${escapedMessage}
|
|||||||
currentPlayerGroupLockStateStore.set(undefined);
|
currentPlayerGroupLockStateStore.set(undefined);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "LockGroupEvent": {
|
|
||||||
this.doLockGroup(event.event);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
const tmp: never = event;
|
const tmp: never = event;
|
||||||
}
|
}
|
||||||
@ -2049,22 +2034,6 @@ ${escapedMessage}
|
|||||||
this.groups.delete(groupId);
|
this.groups.delete(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
lockGroup(event: LockGroupMessageInterface): void {
|
|
||||||
this.pendingEvents.enqueue({
|
|
||||||
type: "LockGroupEvent",
|
|
||||||
event,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
doLockGroup(event: LockGroupMessageInterface): void {
|
|
||||||
const group = this.groups.get(event.groupId);
|
|
||||||
if (!group) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentPlayerGroupLockStateStore.set(event.lock);
|
|
||||||
group.setTexture(event.lock ? "circleSprite-red" : "circleSprite-white");
|
|
||||||
}
|
|
||||||
|
|
||||||
doUpdatePlayerDetails(message: PlayerDetailsUpdatedMessageInterface): void {
|
doUpdatePlayerDetails(message: PlayerDetailsUpdatedMessageInterface): void {
|
||||||
const character = this.MapPlayersByKey.get(message.userId);
|
const character = this.MapPlayersByKey.get(message.userId);
|
||||||
if (character === undefined) {
|
if (character === undefined) {
|
||||||
|
@ -102,11 +102,6 @@ message LockGroupPromptMessage {
|
|||||||
bool lock = 1;
|
bool lock = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message LockGroupMessage {
|
|
||||||
int32 groupId = 1;
|
|
||||||
bool lock = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ClientToServerMessage {
|
message ClientToServerMessage {
|
||||||
oneof message {
|
oneof message {
|
||||||
UserMovesMessage userMovesMessage = 2;
|
UserMovesMessage userMovesMessage = 2;
|
||||||
@ -182,7 +177,6 @@ message SubMessage {
|
|||||||
VariableMessage variableMessage = 8;
|
VariableMessage variableMessage = 8;
|
||||||
ErrorMessage errorMessage = 9;
|
ErrorMessage errorMessage = 9;
|
||||||
PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 10;
|
PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 10;
|
||||||
LockGroupMessage lockGroupMessage = 11;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +431,6 @@ message SubToPusherMessage {
|
|||||||
EmoteEventMessage emoteEventMessage = 9;
|
EmoteEventMessage emoteEventMessage = 9;
|
||||||
ErrorMessage errorMessage = 10;
|
ErrorMessage errorMessage = 10;
|
||||||
PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 11;
|
PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 11;
|
||||||
LockGroupMessage lockGroupMessage = 12;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import {
|
|||||||
FollowConfirmationMessage,
|
FollowConfirmationMessage,
|
||||||
FollowAbortMessage,
|
FollowAbortMessage,
|
||||||
VariableMessage,
|
VariableMessage,
|
||||||
LockGroupMessage,
|
|
||||||
LockGroupPromptMessage,
|
LockGroupPromptMessage,
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
ErrorMessage,
|
ErrorMessage,
|
||||||
PlayerDetailsUpdatedMessage,
|
PlayerDetailsUpdatedMessage,
|
||||||
SetPlayerDetailsMessage,
|
SetPlayerDetailsMessage,
|
||||||
LockGroupMessage,
|
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { ClientReadableStream } from "grpc";
|
import { ClientReadableStream } from "grpc";
|
||||||
import { PositionDispatcher } from "_Model/PositionDispatcher";
|
import { PositionDispatcher } from "_Model/PositionDispatcher";
|
||||||
@ -33,7 +32,6 @@ export interface ZoneEventListener {
|
|||||||
onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void;
|
onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void;
|
||||||
onGroupMoves(group: GroupDescriptor, listener: ExSocketInterface): void;
|
onGroupMoves(group: GroupDescriptor, listener: ExSocketInterface): void;
|
||||||
onGroupLeaves(groupId: number, listener: ExSocketInterface): void;
|
onGroupLeaves(groupId: number, listener: ExSocketInterface): void;
|
||||||
onLockGroup(lockGroupMessage: LockGroupMessage, listener: ExSocketInterface): void;
|
|
||||||
onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void;
|
onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void;
|
||||||
onError(errorMessage: ErrorMessage, listener: ExSocketInterface): void;
|
onError(errorMessage: ErrorMessage, listener: ExSocketInterface): void;
|
||||||
onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface): void;
|
onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface): void;
|
||||||
@ -140,10 +138,6 @@ export class GroupDescriptor {
|
|||||||
return new GroupDescriptor(message.getGroupid(), message.getGroupsize(), position, message.getLocked());
|
return new GroupDescriptor(message.getGroupid(), message.getGroupsize(), position, message.getLocked());
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateFromLockGroupMessage(message: LockGroupMessage): void {
|
|
||||||
this.locked = message.getLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public update(groupDescriptor: GroupDescriptor) {
|
public update(groupDescriptor: GroupDescriptor) {
|
||||||
this.groupSize = groupDescriptor.groupSize;
|
this.groupSize = groupDescriptor.groupSize;
|
||||||
this.position = groupDescriptor.position;
|
this.position = groupDescriptor.position;
|
||||||
@ -221,14 +215,6 @@ export class Zone {
|
|||||||
const fromZone = groupUpdateZoneMessage.getFromzone();
|
const fromZone = groupUpdateZoneMessage.getFromzone();
|
||||||
this.notifyGroupEnter(groupDescriptor, fromZone?.toObject());
|
this.notifyGroupEnter(groupDescriptor, fromZone?.toObject());
|
||||||
}
|
}
|
||||||
} else if (message.hasLockgroupmessage()) {
|
|
||||||
const lockGroupMessage = message.getLockgroupmessage() as LockGroupMessage;
|
|
||||||
const groupId = lockGroupMessage.getGroupid();
|
|
||||||
const oldGroupDescriptor = this.groups.get(groupId);
|
|
||||||
if (oldGroupDescriptor !== undefined) {
|
|
||||||
oldGroupDescriptor.updateFromLockGroupMessage(lockGroupMessage);
|
|
||||||
this.notifyLockGroup(lockGroupMessage);
|
|
||||||
}
|
|
||||||
} else if (message.hasUserleftzonemessage()) {
|
} else if (message.hasUserleftzonemessage()) {
|
||||||
const userLeftMessage = message.getUserleftzonemessage() as UserLeftZoneMessage;
|
const userLeftMessage = message.getUserleftzonemessage() as UserLeftZoneMessage;
|
||||||
this.users.delete(userLeftMessage.getUserid());
|
this.users.delete(userLeftMessage.getUserid());
|
||||||
@ -256,9 +242,6 @@ export class Zone {
|
|||||||
} else if (message.hasEmoteeventmessage()) {
|
} else if (message.hasEmoteeventmessage()) {
|
||||||
const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage;
|
const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage;
|
||||||
this.notifyEmote(emoteEventMessage);
|
this.notifyEmote(emoteEventMessage);
|
||||||
} else if (message.hasLockgroupmessage()) {
|
|
||||||
const lockGroupMessage = message.getLockgroupmessage() as LockGroupMessage;
|
|
||||||
this.notifyLockGroup(lockGroupMessage);
|
|
||||||
} else if (message.hasPlayerdetailsupdatedmessage()) {
|
} else if (message.hasPlayerdetailsupdatedmessage()) {
|
||||||
const playerDetailsUpdatedMessage =
|
const playerDetailsUpdatedMessage =
|
||||||
message.getPlayerdetailsupdatedmessage() as PlayerDetailsUpdatedMessage;
|
message.getPlayerdetailsupdatedmessage() as PlayerDetailsUpdatedMessage;
|
||||||
@ -369,12 +352,6 @@ export class Zone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private notifyLockGroup(lockGroupMessage: LockGroupMessage) {
|
|
||||||
for (const listener of this.listeners) {
|
|
||||||
this.socketListener.onLockGroup(lockGroupMessage, listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private notifyPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage) {
|
private notifyPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage) {
|
||||||
for (const listener of this.listeners) {
|
for (const listener of this.listeners) {
|
||||||
if (listener.userId === playerDetailsUpdatedMessage.getUserid()) {
|
if (listener.userId === playerDetailsUpdatedMessage.getUserid()) {
|
||||||
|
@ -38,7 +38,6 @@ import {
|
|||||||
ErrorMessage,
|
ErrorMessage,
|
||||||
WorldFullMessage,
|
WorldFullMessage,
|
||||||
PlayerDetailsUpdatedMessage,
|
PlayerDetailsUpdatedMessage,
|
||||||
LockGroupMessage,
|
|
||||||
LockGroupPromptMessage,
|
LockGroupPromptMessage,
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||||
@ -307,13 +306,6 @@ export class SocketManager implements ZoneEventListener {
|
|||||||
emitInBatch(listener, subMessage);
|
emitInBatch(listener, subMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
onLockGroup(lockGroupMessage: LockGroupMessage, listener: ExSocketInterface): void {
|
|
||||||
const subMessage = new SubMessage();
|
|
||||||
subMessage.setLockgroupmessage(lockGroupMessage);
|
|
||||||
|
|
||||||
emitInBatch(listener, subMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPlayerDetailsUpdated(
|
onPlayerDetailsUpdated(
|
||||||
playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage,
|
playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage,
|
||||||
listener: ExSocketInterface
|
listener: ExSocketInterface
|
||||||
|
Loading…
Reference in New Issue
Block a user