Support Game Events (#5087)

This commit is contained in:
Zach H 2024-08-24 17:31:20 -07:00 committed by GitHub
parent bbe125beee
commit 248ea82573
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 77 additions and 3 deletions

View file

@ -1,6 +1,6 @@
import protobuf from 'protobufjs';
import { CommonEvents, RoomEvents, SessionEvents } from '../events';
import { CommonEvents, GameEvents, RoomEvents, SessionEvents } from '../events';
import { SessionPersistence } from '../persistence';
import { WebClient } from '../WebClient';
import { SessionCommands } from 'websocket';
@ -95,7 +95,7 @@ export class ProtobufService {
this.processSessionEvent(msg.sessionEvent, msg);
break;
case this.controller.ServerMessage.MessageType.GAME_EVENT_CONTAINER:
console.log(msg);
this.processGameEvent(msg.gameEvent, msg);
break;
default:
console.log(msg);
@ -128,6 +128,10 @@ export class ProtobufService {
this.processEvent(response, SessionEvents, raw);
}
private processGameEvent(response: any, raw: any): void {
this.processEvent(response, GameEvents, raw);
}
private processEvent(response: any, events: ProtobufEvents, raw: any) {
for (const event in events) {
const payload = response[event];