mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
parent
291c535edb
commit
0994d10410
8 changed files with 41 additions and 2 deletions
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,3 +17,8 @@ export interface LeaveRoomData {
|
|||
export interface ListGamesData {
|
||||
gameList: Game[];
|
||||
}
|
||||
|
||||
export interface RemoveMessagesData {
|
||||
name: string;
|
||||
amount: number;
|
||||
}
|
||||
|
|
|
|||
6
webclient/src/websocket/events/room/removeMessages.ts
Normal file
6
webclient/src/websocket/events/room/removeMessages.ts
Normal 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);
|
||||
}
|
||||
6
webclient/src/websocket/events/session/gameJoined.ts
Normal file
6
webclient/src/websocket/events/session/gameJoined.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { SessionPersistence } from '../../persistence';
|
||||
import { GameJoinedData } from './interfaces';
|
||||
|
||||
export function gameJoined(gameJoined: GameJoinedData) {
|
||||
SessionPersistence.gameJoined(gameJoined);
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue