From 49defc2ee706000cf7572f6a3793bf741ddbba3e Mon Sep 17 00:00:00 2001 From: Molly Draven Date: Sat, 12 Oct 2024 10:23:23 -0400 Subject: [PATCH] refactor(State): remove unused onDataHandlers property --- packages/gateway/src/GatewayServer.ts | 20 ---------- packages/shared/index.ts | 2 - packages/shared/src/State.ts | 54 --------------------------- 3 files changed, 76 deletions(-) diff --git a/packages/gateway/src/GatewayServer.ts b/packages/gateway/src/GatewayServer.ts index 1a518ce75..e4de3b2cf 100644 --- a/packages/gateway/src/GatewayServer.ts +++ b/packages/gateway/src/GatewayServer.ts @@ -305,26 +305,6 @@ export class Gateway { /** @type {Gateway | undefined} */ Gateway._instance = undefined; -/** - * Registers various data handlers to the provided state. - * - * This function adds handlers for different types of data, such as login data, - * chat data, persona data, lobby data, and transaction data. Each handler is - * associated with a specific code. - * - * @param state - The initial state to which the data handlers will be added. - * @returns The updated state with all the data handlers registered. - */ -function registerDataHandlers(state: State) { - state = addOnDataHandler(state, 8226, receiveLoginData); - state = addOnDataHandler(state, 8227, receiveChatData); - state = addOnDataHandler(state, 8228, receivePersonaData); - state = addOnDataHandler(state, 7003, receiveLobbyData); - state = addOnDataHandler(state, 9000, receiveChatData); - state = addOnDataHandler(state, 43300, receiveTransactionsData); - return state; -} - /** * Get a singleton instance of GatewayServer * diff --git a/packages/shared/index.ts b/packages/shared/index.ts index 071b27dce..5750f7d46 100644 --- a/packages/shared/index.ts +++ b/packages/shared/index.ts @@ -26,8 +26,6 @@ export { addSession, createInitialState, fetchStateFromDatabase, - addOnDataHandler, - getOnDataHandler, addEncryption, getEncryption, McosSession, diff --git a/packages/shared/src/State.ts b/packages/shared/src/State.ts index 8def5ad46..221d2ed16 100644 --- a/packages/shared/src/State.ts +++ b/packages/shared/src/State.ts @@ -181,7 +181,6 @@ export interface State { encryptions: Record; sessions: Record; // queuedConnections: Record; - onDataHandlers: Record; save: (state?: State) => void; } @@ -212,7 +211,6 @@ export function createInitialState({ encryptions: {}, sessions: {}, // queuedConnections: {}, - onDataHandlers: {}, save: function (state?: State) { if (typeof state === "undefined") { state = this as State; @@ -226,58 +224,6 @@ export function createInitialState({ }; } -/** - * Add a data handler to the state. - * - * This function adds a data handler to the state. - * The returned state is a new state object, and the original state is not - * modified. You should then call the save function on the new state to update - * the database. - * - * @param {State} state The state to add the data handler to. - * @param {number} port The port to add the data handler for. - * @param {OnDataHandler} handler The data - * handler to - * add. - * @returns {State} The state with the data handler added. - */ -export function addOnDataHandler( - state: State, - port: number, - handler: OnDataHandler, -): State { - const onDataHandlers = state.onDataHandlers; - onDataHandlers[port.toString()] = handler; - const newState = { - ...state, - onDataHandlers, - }; - return newState; -} - -/** - * Get a data handler for a port from the state. - * - * This function gets a data handler for a port from the state. - * - * @param {State} state The state to get the data handler from. - * @param {number} port The port to get the data handler for. - * @returns {OnDataHandler | undefined} The - * data - * handler - * for the - * given port, - * or undefined - * if no data - * handler exists - */ -export function getOnDataHandler( - state: State, - port: number, -): OnDataHandler | undefined { - return state.onDataHandlers[port.toString()]; -} - /** * Add an encryption to the state. *