More stuff (#5056)

* Skeleton + RemoveMessages

* GameJoinedData
This commit is contained in:
Zach H
2024-06-16 23:26:03 -04:00
committed by GitHub
parent 291c535edb
commit 0994d10410
8 changed files with 41 additions and 2 deletions

View File

@@ -4,10 +4,12 @@ import { joinRoom } from './joinRoom';
import { leaveRoom } from './leaveRoom';
import { listGames } from './listGames';
import { roomSay } from './roomSay';
import { removeMessages } from './removeMessages';
export const RoomEvents: ProtobufEvents = {
'.Event_JoinRoom.ext': joinRoom,
'.Event_LeaveRoom.ext': leaveRoom,
'.Event_ListGames.ext': listGames,
'.Event_RemoveMessages.ext': removeMessages,
'.Event_RoomSay.ext': roomSay,
'.Event_JoinRoom.ext': joinRoom,
};

View File

@@ -17,3 +17,8 @@ export interface LeaveRoomData {
export interface ListGamesData {
gameList: Game[];
}
export interface RemoveMessagesData {
name: string;
amount: number;
}

View File

@@ -0,0 +1,6 @@
import { RoomPersistence } from '../../persistence';
import { RemoveMessagesData, RoomEvent } from './interfaces';
export function removeMessages({ name, amount }: RemoveMessagesData, { roomEvent: { roomId } }: RoomEvent) {
RoomPersistence.removeMessages(roomId, name, amount);
}

View File

@@ -0,0 +1,6 @@
import { SessionPersistence } from '../../persistence';
import { GameJoinedData } from './interfaces';
export function gameJoined(gameJoined: GameJoinedData) {
SessionPersistence.gameJoined(gameJoined);
}

View File

@@ -11,14 +11,17 @@ import { serverShutdown } from './serverShutdown';
import { userJoined } from './userJoined';
import { userLeft } from './userLeft';
import { userMessage } from './userMessage';
import { gameJoined } from './gameJoined';
export const SessionEvents: ProtobufEvents = {
'.Event_AddToList.ext': addToList,
'.Event_ConnectionClosed.ext': connectionClosed,
'.Event_GameJoined.ext': gameJoined,
'.Event_ListRooms.ext': listRooms,
'.Event_NotifyUser.ext': notifyUser,
'.Event_PlayerPropertiesChanges.ext': playerPropertiesChanges,
'.Event_RemoveFromList.ext': removeFromList,
// '.Event_ReplayAdded.ext': () => {}, // TODO Eventually
'.Event_ServerIdentification.ext': serverIdentification,
'.Event_ServerMessage.ext': serverMessage,
'.Event_ServerShutdown.ext': serverShutdown,

View File

@@ -1,4 +1,4 @@
import { Room, User } from 'types';
import { Game, Room, User } from 'types';
export interface SessionEvent {
sessionEvent: {}
@@ -42,3 +42,11 @@ export interface UserJoinedData {
export interface UserLeftData {
name: string;
}
export interface GameJoinedData {
gameInfo: Game;
playerId: number;
spectator: boolean;
resuming: boolean;
judge: boolean;
}

View File

@@ -48,4 +48,8 @@ export class RoomPersistence {
static userLeft(roomId: number, name: string) {
RoomsDispatch.userLeft(roomId, name);
}
static removeMessages(roomId: number, name: string, amount: number): void {
console.log('removeMessages', roomId, name, amount);
};
}

View File

@@ -3,6 +3,7 @@ import { Log, StatusEnum, User, WebSocketConnectOptions } from 'types';
import { sanitizeHtml } from 'websocket/utils';
import NormalizeService from '../utils/NormalizeService';
import { GameJoinedData } from '../events/session/interfaces';
export class SessionPersistence {
static initialized() {
@@ -168,4 +169,8 @@ export class SessionPersistence {
static getGamesOfUser(userName: string, response: any): void {
console.log('getGamesOfUser');
}
static gameJoined(gameJoinedData: GameJoinedData): void {
console.log('gameJoined', gameJoinedData);
}
}