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

feat: feature to send strings as index #1176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

James-Frowen
Copy link
Member

will save bandwidth when sending many strings that are the same

This works, but requires test and a better way to use it before merging

will save bandwidth when sending many strings that are the same
@James-Frowen
Copy link
Member Author

example use

public static void WriteMission(this NetworkWriter finalWriter, Mission mission)
{
    var writer = finalWriter;
    var stringStore = new StringStore();
    var writer = new NetworkWriter(64_000, true);
    writer.StringStore = stringStore;

    // write large message with lots of strings here
    // ...
    
    // write strings then large message 
    finalWriter.WriteStringStore(stringStore);
    finalWriter.WriteBytesAndSizeSegment(writer.ToArraySegment());
}

public static Mission ReadMission(this NetworkReader finalReader)
{
    // read strings, then set it on the inner reader
    var stringStore = finalReader.ReadStringStore();
    var reader = new NetworkReader();
    reader.Reset(finalReader.ReadBytesAndSizeSegment());
    reader.StringStore = stringStore;
    
    // read large message, reader will use the stringStore we read above
    // ...
}

Copy link
Contributor

github-actions bot commented Aug 7, 2024

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Aug 7, 2024
@James-Frowen James-Frowen added keep-open Stops issue being closed because it is stale and removed Stale labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep-open Stops issue being closed because it is stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant