Skip to content

feat: feature to send strings as index#1176

Merged
James-Frowen merged 6 commits intomainfrom
string-store
Mar 10, 2026
Merged

feat: feature to send strings as index#1176
James-Frowen merged 6 commits intomainfrom
string-store

Conversation

@James-Frowen
Copy link
Copy Markdown
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

@James-Frowen
Copy link
Copy Markdown
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
    // ...
}

@github-actions
Copy link
Copy Markdown
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
@James-Frowen James-Frowen force-pushed the string-store branch 2 times, most recently from 53ff8aa to bfad862 Compare March 10, 2026 16:20
@James-Frowen James-Frowen merged commit e73b731 into main Mar 10, 2026
4 checks passed
@James-Frowen James-Frowen deleted the string-store branch March 10, 2026 16:25
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 157.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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 released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant