-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,610 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "rm-lobby", | ||
"private": true, | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "rimraf ./lib/ && tsc", | ||
"test": "vitest" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "", | ||
"devDependencies": { | ||
"@tsconfig/node20": "~20.1.4", | ||
"@types/node": "~20.12.2", | ||
"rimraf": "~5.0.5", | ||
"typescript": "~5.4.3", | ||
"vitest": "~1.4.0", | ||
"@sentry/node": "~7.109.0" | ||
}, | ||
"dependencies": { | ||
"rm-database": "workspace:*", | ||
"rm-shared": "workspace:*", | ||
"rm-persona": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// <reference types="node" /> | ||
import { LegacyMessage } from "../../shared"; | ||
export declare class LoginInfoMessage extends LegacyMessage { | ||
_userId: number; | ||
_userName: string; | ||
_userData: Buffer; | ||
_customerId: number; | ||
_flags: number; | ||
_dllVersion: string; | ||
_hostname: string; | ||
_idAddress: string; | ||
_hashKey: Buffer; | ||
constructor(); | ||
/** | ||
* @param {Buffer} buffer | ||
* @returns {LoginInfoMessage} | ||
*/ | ||
deserialize(buffer: Buffer): LoginInfoMessage; | ||
/** | ||
* @returns {Buffer} | ||
*/ | ||
serialize(): Buffer; | ||
toString(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { | ||
LegacyMessage, | ||
deserializeString, | ||
serializeString, | ||
} from "rm-shared"; | ||
|
||
export class LoginInfoMessage extends LegacyMessage { | ||
_userId: number; | ||
_userName: string; | ||
_userData: Buffer; | ||
_customerId: number; | ||
_flags: number; | ||
_dllVersion: string; | ||
_hostname: string; | ||
_idAddress: string; | ||
_hashKey: Buffer; | ||
constructor() { | ||
super(); | ||
this._userId = 0; // 4 bytes | ||
this._userName = ""; | ||
this._userData = Buffer.alloc(64); | ||
this._customerId = 0; // 4 bytes | ||
this._flags = 0; // 4 bytes | ||
this._dllVersion = ""; | ||
this._hostname = ""; | ||
this._idAddress = ""; | ||
this._hashKey = Buffer.alloc(16); | ||
} | ||
|
||
/** | ||
* @param {Buffer} buffer | ||
* @returns {LoginInfoMessage} | ||
*/ | ||
override deserialize(buffer: Buffer): LoginInfoMessage { | ||
try { | ||
this._header._doDeserialize(buffer); | ||
let offset = this._header._size; | ||
this._userId = buffer.readInt32BE(offset); | ||
offset += 4; | ||
this._userName = deserializeString(buffer.subarray(offset)); | ||
offset += 4 + this._userName.length + 1; | ||
buffer.copy(this._userData, 0, offset, offset + 64); | ||
offset += 64; | ||
this._customerId = buffer.readInt32BE(offset); | ||
offset += 4; | ||
this._flags = buffer.readInt32BE(offset); | ||
offset += 4; | ||
this._dllVersion = deserializeString(buffer.subarray(offset)); | ||
offset += 4 + this._dllVersion.length + 1; | ||
this._hostname = deserializeString(buffer.subarray(offset)); | ||
offset += 4 + this._hostname.length + 1; | ||
this._idAddress = deserializeString(buffer.subarray(offset)); | ||
offset += 4 + this._idAddress.length + 1; | ||
buffer.copy(this._hashKey, 0, offset, offset + 16); | ||
|
||
return this; | ||
} catch (error) { | ||
throw Error(`Error deserializing LoginInfoMessage: ${error}`); | ||
} | ||
} | ||
|
||
/** | ||
* @returns {Buffer} | ||
*/ | ||
override serialize(): Buffer { | ||
try { | ||
const buffer = Buffer.alloc(this._header.length); | ||
this._header._doSerialize().copy(buffer); | ||
let offset = this._header._size; | ||
buffer.writeInt32BE(this._userId, offset); | ||
offset += 4; | ||
offset = serializeString(this._userName, buffer, offset); | ||
|
||
this._userData.copy(buffer, offset); | ||
offset += 64; | ||
buffer.writeInt32BE(this._customerId, offset); | ||
offset += 4; | ||
buffer.writeInt32BE(this._flags, offset); | ||
offset += 4; | ||
offset = serializeString(this._dllVersion, buffer, offset); | ||
|
||
offset = serializeString(this._hostname, buffer, offset); | ||
|
||
offset = serializeString(this._idAddress, buffer, offset); | ||
offset += 4 + this._idAddress.length + 1; | ||
this._hashKey.copy(buffer, offset); | ||
|
||
return buffer; | ||
} catch (error) { | ||
throw Error(`Error serializing LoginInfoMessage: ${error}`); | ||
} | ||
} | ||
|
||
override toString() { | ||
return `LoginInfoMessage: ${this._userName}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Commands from the game client to the game server | ||
* @export | ||
* @readonly | ||
* @type {TNPS_COMMAND_MAP[]} | ||
*/ | ||
/** | ||
* Commands from the game client to the game server | ||
* @export | ||
* @readonly | ||
* @type {TNPS_COMMAND_MAP[]} | ||
*/ | ||
import type { GameMessageOpCode } from "../../interfaces/index.js"; | ||
export declare const NPS_LOBBYCLIENT_COMMANDS: GameMessageOpCode[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Commands from the game client to the game server | ||
* @export | ||
* @readonly | ||
* @type {TNPS_COMMAND_MAP[]} | ||
*/ | ||
|
||
/** | ||
* Commands from the game client to the game server | ||
* @export | ||
* @readonly | ||
* @type {TNPS_COMMAND_MAP[]} | ||
*/ | ||
import type { GameMessageOpCode } from "./types.js"; | ||
|
||
export const NPS_LOBBYCLIENT_COMMANDS: GameMessageOpCode[] = [ | ||
{ name: "NPS_LOGIN", value: 256, module: "Lobby" }, | ||
{ name: "NPS_GET_USER_LIST", value: 257, module: "Lobby" }, | ||
{ name: "NPS_GET_MY_USER_DATA", value: 258, module: "Lobby" }, | ||
{ name: "NPS_SET_MY_USER_DATA", value: 259, module: "Lobby" }, | ||
{ name: "NPS_LOG_OFF_SERVER", value: 260, module: "Lobby" }, | ||
{ name: "NPS_CLOSE_COMM_CHANNEL", value: 261, module: "Lobby" }, | ||
{ name: "NPS_OPEN_COMM_CHANNEL", value: 262, module: "Lobby" }, | ||
{ name: "NPS_GET_CLIENT_COUNT", value: 263, module: "Lobby" }, | ||
{ name: "NPS_START_GAME", value: 264, module: "Lobby" }, | ||
{ name: "NPS_READY_FOR_GAME", value: 265, module: "Lobby" }, | ||
{ name: "NPS_START_GAME_SERVER", value: 266, module: "Lobby" }, | ||
{ name: "NPS_SET_SLEEP_STATE", value: 267, module: "Lobby" }, | ||
{ name: "NPS_GET_SERVER_INFO", value: 268, module: "Lobby" }, | ||
{ name: "NPS_SET_COMM_FLAGS", value: 269, module: "Lobby" }, | ||
{ name: "NPS_GET_READY_LIST", value: 270, module: "Lobby" }, | ||
{ name: "NPS_SEND_SERVER_LIST", value: 271, module: "Lobby" }, | ||
{ name: "NPS_SET_COMM_CHANNEL_RATE", value: 272, module: "Lobby" }, | ||
{ name: "NPS_SET_HEARTBEAT_TIMEOUT", value: 273, module: "Lobby" }, | ||
{ name: "NPS_GET_HEARTBEAT_TIMEOUT", value: 274, module: "Lobby" }, | ||
{ name: "NPS_SET_CHANNEL_DATA", value: 275, module: "Lobby" }, | ||
{ name: "NPS_FILE_START", value: 276, module: "Lobby" }, | ||
{ name: "NPS_FILE_DATA", value: 277, module: "Lobby" }, | ||
{ name: "NPS_FILE_COMPLETED", value: 278, module: "Lobby" }, | ||
{ name: "NPS_BOOT_USER_FROM_CHANNEL", value: 279, module: "Lobby" }, | ||
{ name: "NPS_LOCATE_USER", value: 280, module: "Lobby" }, | ||
{ name: "NPS_ENABLE_FILTER", value: 281, module: "Lobby" }, | ||
{ name: "NPS_DISABLE_FILTER", value: 282, module: "Lobby" }, | ||
{ name: "NPS_SLEEP_SERVER", value: 283, module: "Lobby" }, | ||
{ name: "NPS_WAKE_SERVER", value: 284, module: "Lobby" }, | ||
{ name: "NPS_TERMINATE_GAME_SERVER", value: 285, module: "Lobby" }, | ||
{ name: "NPS_SEND_SKU_REGISTRY", value: 286, module: "Lobby" }, | ||
{ name: "NPS_SET_READY_FOR_GAME", value: 287, module: "Lobby" }, | ||
{ name: "NPS_LOGIN_RESP", value: 288, module: "Lobby" }, | ||
{ name: "NPS_SOCKET_RECONNECT", value: 289, module: "Lobby" }, | ||
{ name: "NPS_SET_SLOT", value: 290, module: "Lobby" }, | ||
{ name: "NPS_GET_SLOT_LIST", value: 291, module: "Lobby" }, | ||
{ name: "NPS_SET_CHANNEL_CLOSED", value: 292, module: "Lobby" }, | ||
{ name: "NPS_UDP_STATUS", value: 293, module: "Lobby" }, | ||
{ name: "NPS_GET_USER_INFO", value: 294, module: "Lobby" }, | ||
{ name: "NPS_GET_MASTER_LIST", value: 295, module: "Lobby" }, | ||
{ name: "NPS_GET_MINI_USER_LIST", value: 296, module: "Lobby" }, | ||
{ name: "NPS_UDP_FAILURE", value: 297, module: "Lobby" }, | ||
{ name: "NPS_BUDDYLIST_REFRESH", value: 298, module: "Lobby" }, | ||
{ name: "NPS_BUDDYLIST_ADD_USERS", value: 299, module: "Lobby" }, | ||
{ name: "NPS_BUDDYLIST_REMOVE_USERS", value: 300, module: "Lobby" }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { GameMessageOpCode } from "../../interfaces/index.js"; | ||
/** | ||
* Commands from the game server to the game client | ||
* @export | ||
* @readonly | ||
* @type {TNPS_COMMAND_MAP[]} | ||
*/ | ||
export declare const NPS_LOBBYSERVER_COMMANDS: GameMessageOpCode[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { GameMessageOpCode } from "./types.js"; | ||
|
||
/** | ||
* Commands from the game server to the game client | ||
* @export | ||
* @readonly | ||
* @type {TNPS_COMMAND_MAP[]} | ||
*/ | ||
export const NPS_LOBBYSERVER_COMMANDS: GameMessageOpCode[] = [ | ||
{ name: "NPS_FORCE_LOGOFF", value: 513, module: "Lobby" }, | ||
{ name: "NPS_USER_LEFT", value: 514, module: "Lobby" }, | ||
{ name: "NPS_USER_JOINED", value: 515, module: "Lobby" }, | ||
{ name: "NPS_USER_INFO", value: 516, module: "Lobby" }, | ||
{ name: "NPS_SYSTEM_ALERT", value: 517, module: "Lobby" }, | ||
{ name: "NPS_CLIENT_COUNT", value: 518, module: "Lobby" }, | ||
{ name: "NPS_ACK", value: 519, module: "Lobby" }, | ||
{ name: "NPS_USER_LEFT_CHANNEL", value: 520, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_CLOSED", value: 521, module: "Lobby" }, | ||
{ name: "NPS_DUP_USER", value: 522, module: "Lobby" }, | ||
{ name: "NPS_SERVER_FULL", value: 523, module: "Lobby" }, | ||
{ name: "NPS_USER_JOINED_CHANNEL", value: 524, module: "Lobby" }, | ||
{ name: "NPS_SERVER_INFO", value: 525, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_CREATED", value: 526, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_DELETED", value: 527, module: "Lobby" }, | ||
{ name: "NPS_READY_LIST", value: 528, module: "Lobby" }, | ||
{ name: "NPS_USER_LIST", value: 529, module: "Lobby" }, | ||
{ name: "NPS_SERVER_LIST", value: 530, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_DENIED", value: 531, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_GRANTED", value: 532, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_CONDITIONAL", value: 533, module: "Lobby" }, | ||
{ name: "NPS_SERVER_REDIRECT", value: 534, module: "Lobby" }, | ||
{ name: "NPS_HEARTBEAT", value: 535, module: "Lobby" }, | ||
{ name: "NPS_HEARTBEAT_TIMEOUT", value: 536, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_UPDATE", value: 537, module: "Lobby" }, | ||
{ name: "NPS_FORCE_LEAVE_CHANNEL", value: 538, module: "Lobby" }, | ||
{ name: "NPS_USER_LOCATION", value: 539, module: "Lobby" }, | ||
{ name: "NPS_GAME_SERVER_STARTED", value: 540, module: "Lobby" }, | ||
{ name: "NPS_GAME_SERVER_TERMINATED", value: 541, module: "Lobby" }, | ||
{ name: "NPS_VERSIONS_DIFFERENT", value: 542, module: "Lobby" }, | ||
{ name: "NPS_SEND_VERSION_STRING", value: 543, module: "Lobby" }, | ||
{ name: "NPS_GAME_SKU_REGISTRY_KEY", value: 544, module: "Lobby" }, | ||
{ name: "NPS_PLUGIN_ACK", value: 545, module: "Lobby" }, | ||
{ name: "NPS_SERVER_CRASHED", value: 546, module: "Lobby" }, | ||
{ name: "NPS_OPEN_COMM_CHANNEL_ACK", value: 547, module: "Lobby" }, | ||
{ name: "NPS_GAME_SERVER_STATE_CHANGE", value: 548, module: "Lobby" }, | ||
{ name: "NPS_SLOT_UPDATE", value: 549, module: "Lobby" }, | ||
{ name: "NPS_SLOT_LIST", value: 550, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_MASTER", value: 551, module: "Lobby" }, | ||
{ name: "NPS_CHANNEL_MASTER_LIST", value: 552, module: "Lobby" }, | ||
{ name: "NPS_MINI_USER_LIST", value: 553, module: "Lobby" }, | ||
{ name: "NPS_INVALID_KEY", value: 554, module: "Lobby" }, | ||
{ name: "NPS_NO_VALIDATION_SERVER", value: 555, module: "Lobby" }, | ||
{ name: "NPS_INC_MINI_USER_LIST", value: 556, module: "Lobby" }, | ||
{ name: "NPS_DEC_MINI_USER_LIST", value: 557, module: "Lobby" }, | ||
{ name: "NPS_BUDDY_LIST", value: 558, module: "Lobby" }, | ||
{ name: "NPS_BUDDYLIST_UPDATE", value: 559, module: "Lobby" }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { GameMessageOpCode } from "../../interfaces/index.js"; | ||
/** | ||
* @export | ||
* @readonly | ||
* @type {NpsCommandMap[]} | ||
*/ | ||
export declare const NPS_LOBBY_COMMANDS: GameMessageOpCode[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NPS_LOBBYCLIENT_COMMANDS } from "./NPS_LOBBYCLIENT_COMMANDS.js"; | ||
import { NPS_LOBBYSERVER_COMMANDS } from "./NPS_LOBBYSERVER_COMMANDS.js"; | ||
import { GameMessageOpCode } from "./types.js"; | ||
|
||
/** | ||
* @export | ||
* @readonly | ||
* @type {NpsCommandMap[]} | ||
*/ | ||
export const NPS_LOBBY_COMMANDS: GameMessageOpCode[] = [ | ||
...NPS_LOBBYCLIENT_COMMANDS, | ||
...NPS_LOBBYSERVER_COMMANDS, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/// <reference types="node" /> | ||
import { LegacyMessage } from "../../shared"; | ||
import { LoginInfoMessage } from "./LoginInfoMessage.js"; | ||
export declare class UserInfo { | ||
_userId: number; | ||
_userName: string; | ||
_userData: Buffer; | ||
constructor(); | ||
deserialize(buffer: Buffer): this; | ||
serialize(): Buffer; | ||
size(): number; | ||
} | ||
export declare class UserInfoMessage extends LegacyMessage { | ||
_userId: number; | ||
_userName: string; | ||
_userData: Buffer; | ||
constructor(); | ||
/** | ||
* @param {Buffer} buffer | ||
* @returns {UserInfoMessage} | ||
*/ | ||
deserialize(buffer: Buffer): this; | ||
/** | ||
* @returns {Buffer} | ||
*/ | ||
serialize(): Buffer; | ||
/** | ||
* @param {LoginInfoMessage} loginInfoMessage | ||
*/ | ||
fromLoginInfoMessage(loginInfoMessage: LoginInfoMessage): this; | ||
calculateLength(): any; | ||
toString(): string; | ||
} |
Oops, something went wrong.