-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): add rusty-motors-chat as a dependency (#2123)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new chat module, enhancing communication capabilities within the application. - Added support for handling messages through a new callback type for game socket connections. - Implemented a function to receive and process incoming chat messages (currently in preliminary state). - **Configuration** - Established foundational configuration for the chat module, including TypeScript and testing setups. - Expanded workspace scope to include additional modules in the source directory. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
8 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
packages: | ||
- 'packages/*' | ||
- "src/*" |
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,46 @@ | ||
import { | ||
GameMessage, | ||
getServerLogger, | ||
type ServiceResponse, | ||
} from "rusty-motors-shared"; | ||
import type { Serializable } from "rusty-motors-shared-packets"; | ||
|
||
/** | ||
* Receive chat data | ||
* | ||
* @param connectionId - Connection ID | ||
* @param message - Message | ||
* @returns Service response | ||
*/ | ||
async function receiveChatData({ | ||
connectionId, | ||
message, | ||
}: { | ||
connectionId: string; | ||
message: Serializable; | ||
}): Promise<ServiceResponse> { | ||
const log = getServerLogger({}); | ||
|
||
log.info(`Received chat data from connection ${connectionId}`); | ||
log.debug(`Message: ${message.toHexString()}`); | ||
|
||
const inboundMessage = new GameMessage(0); | ||
inboundMessage.deserialize(message.serialize()); | ||
|
||
log.debug(`Deserialized message: ${inboundMessage.toHexString()}`); | ||
|
||
const id = inboundMessage._header.id; | ||
|
||
log.debug(`Message ID: ${id}`); | ||
|
||
throw new Error( | ||
`Unable to process chat data from connection ${connectionId}, data: ${message.toHexString()}`, | ||
); | ||
|
||
return { | ||
connectionId, | ||
messages: [], | ||
}; | ||
} | ||
|
||
export { receiveChatData }; |
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,17 @@ | ||
{ | ||
"name": "rusty-motors-chat", | ||
"version": "1.0.0", | ||
"exports": { | ||
".": { | ||
"import": "./index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no tests yet\" && exit 0" | ||
}, | ||
"type": "module", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"description": "" | ||
} |
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,11 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"incremental": true, | ||
"composite": true | ||
}, | ||
"include": [ | ||
"index.ts", | ||
"**/*.ts" | ||
] | ||
} |
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 @@ | ||
export type GameSocketCallback = (messages: Buffer[]) => void; |
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,22 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
coverage: { | ||
enabled: true, | ||
all: true, | ||
exclude: [ | ||
"src/**/*.spec.ts", | ||
"src/**/*.test.ts", | ||
"bin/**/*.ts", | ||
"ecosystem.config.js", | ||
"migrate.ts", | ||
"packages/**/*.d.ts", | ||
], | ||
reporter: ["lcov", "text", "cobertura"], | ||
}, | ||
reporters: ["junit", "default", "hanging-process"], | ||
outputFile: "mcos.junit.xml", | ||
pool: "forks", | ||
}, | ||
}); |