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

add DataPack encode and decode rpc message #150

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Conversation

noneghost
Copy link
Contributor

@noneghost noneghost commented Nov 14, 2023

A DataPack API is added to implement the encoding and decoding logic of messages. The default encode and decode logic is still JSON, and when the user wants to extend, pass in the user-implemented DataPack class instance when instantiating on the server or client.

export interface DataPack {
    encode(value: any): any;
    decode(value: any): any;
}

export class DefaultDataPack implements DataPack
{
    encode(value: any)
    {
        return JSON.stringify(value)
    }

    decode(value: any)
    {
        return JSON.parse(value)
    }
}

src/lib/client.ts Outdated Show resolved Hide resolved
src/lib/client.ts Show resolved Hide resolved
src/lib/utils.ts Outdated Show resolved Hide resolved
Copy link
Member

@mkozjak mkozjak left a comment

Choose a reason for hiding this comment

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

Looks great. Just need to sort out these first few lines in API.md that are modified for some reason.

API.md Outdated Show resolved Hide resolved
@mkozjak mkozjak self-requested a review November 17, 2023 08:58
Copy link
Member

@mkozjak mkozjak left a comment

Choose a reason for hiding this comment

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

Looks great! Just minor changes on API.md needed.

@noneghost
Copy link
Contributor Author

Looks great! Just minor changes on API.md needed.

Are there any other questions with the API documentation?

Copy link
Member

@mkozjak mkozjak left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks!

@mkozjak mkozjak merged commit 6d58942 into elpheria:trunk Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants