Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): add rusty-motors-chat as a dependency #2123

Merged
merged 4 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"lobby": "link:packages/lobby",
"moment": "^2.29.4",
"pino": "^9.3.2",
"rusty-motors-chat": "link:src/chat",
"rusty-motors-cli": "link:packages/cli",
"rusty-motors-connection": "link:packages/connection",
"rusty-motors-database": "link:packages/database",
Expand Down
17 changes: 12 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages:
- 'packages/*'
- "src/*"
46 changes: 46 additions & 0 deletions src/chat/index.ts
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()}`,
);
Comment on lines +36 to +38
Copy link

@coderabbitai coderabbitai bot Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the chat data processing logic.

The function is currently throwing an error, indicating that it is unable to process the chat data. This suggests that the implementation is incomplete and requires further development.

Do you want me to help implement the chat data processing logic or open a GitHub issue to track this task?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open an issue and assign it to me.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drazisil, the issue has been successfully created and assigned to you. You can find it here: #2129

Analysis chain

@drazisil, I've opened an issue and assigned it to you.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
gh issue create --title "Implement chat data processing logic" \
--body "The function \`receiveChatData\` in \`src/chat/index.ts\` is currently incomplete and throws an error, indicating that it requires further development to properly process chat data.

PR: https://github.com/rustymotors/server/pull/2123
Comment: https://github.com/rustymotors/server/pull/2123#discussion_r1760369660
Requester: @drazisil" \
--assignee drazisil

Length of output: 475


return {
connectionId,
messages: [],
};
drazisil marked this conversation as resolved.
Show resolved Hide resolved
}

export { receiveChatData };
17 changes: 17 additions & 0 deletions src/chat/package.json
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 test specified\" && exit 1"
},
"type": "module",
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
11 changes: 11 additions & 0 deletions src/chat/tsconfig.json
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"
]
}
1 change: 1 addition & 0 deletions src/chat/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type GameSocketCallback = (messages: Buffer[]) => void;
22 changes: 22 additions & 0 deletions src/chat/vite.config.ts
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",
},
});
Loading