Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several significant changes to the networking components of the project, focusing on refactoring client and server internals, enhancing packet handling, and improving code modularity and clarity. The most notable changes include the introduction of a
ClientContextto encapsulate per-client state, updates to the packet caching and reordering mechanisms, and the addition of new network command types and logic. These changes aim to make the networking layer more robust, extensible, and easier to maintain.Networking Architecture and API Refactoring:
ClientContextstruct that encapsulates per-client state such asPacketDefragmentation,PacketCache,PacketReorderer, andCommandQueue, and updatedClientListto use this context for each client. This change modularizes client state management and paves the way for cleaner networking logic. [1] [2]Clientclass to move packet cache and reorderer management into the newClientContext, and changed the acknowledged packets container from astd::vectorto astd::unordered_setwith a custom hash for efficiency. [1] [2] [3]ClientListevent system: replaced the oldClientListEventstruct with a newEventstruct using a strongly-typed enum, and updated all related methods. [1] [2]Packet Handling Improvements:
PacketCachewith move semantics, a thread mutex for thread safety, and an enable/disable flag to control caching behavior. Added a custom hash function for packet labels to improve lookup performance. [1] [2]PacketDefragmentationnon-copyable but movable to prevent accidental copies and clarify ownership semantics.Network Command System Enhancements:
CONNECT_HANDLERnetwork command type and implemented the correspondingNetConnectHandlerCommandclass, which manages multi-stage connection and handshake logic, including MTU discovery and (potentially) cryptographic handshakes. Refactored the baseNetCommandinterface to usevoidreturn types and internal state for command results, and updated command classes (NetMTUCommand,NetConnectCommand,NetDisconnectCommand) to befinaland use the new interface. [1] [2] [3] [4]Server and Client Example Updates:
Build System Updates:
C_netServer.cpp,C_netClient.cpp) to the build system for both the server and client libraries. [1] [2]These changes collectively improve the maintainability, performance, and extensibility of the networking subsystem.