Session 07 scope (5 features, 17 tests, ~1165 Go LOC): - Protocol/ParserTypes.cs: ParserState enum (79 states), PublishArgument, ParseContext - Protocol/IProtocolHandler.cs: handler interface decoupling parser from client - Protocol/ProtocolParser.cs: Parse(), ProtoSnippet(), OverMaxControlLineLimit(), ProcessPub/HeaderPub/RoutedMsgArgs/RoutedHeaderMsgArgs, ClonePubArg(), GetHeader() - tests/Protocol/ProtocolParserTests.cs: 17 tests via TestProtocolHandler stub Auth extras from session 06 (committed separately): - Auth/TpmKeyProvider.cs, Auth/CertificateIdentityProvider/, Auth/CertificateStore/ Internal utilities & data structures (session 06 overflow): - Internal/AccessTimeService.cs, ElasticPointer.cs, SystemMemory.cs, ProcessStatsProvider.cs - Internal/DataStructures/GenericSublist.cs, HashWheel.cs - Internal/DataStructures/SubjectTree.cs, SubjectTreeNode.cs, SubjectTreeParts.cs All 461 tests pass (460 unit + 1 integration). DB updated for features 2588-2592 and tests 2598-2614.
1.5 KiB
1.5 KiB
Session 08: Client Connection
Summary
The client connection handler — manages individual client TCP connections, message processing, subscription management, and client lifecycle. The largest single class in the server.
Scope
| Go File | Features | Feature IDs | Go LOC |
|---|---|---|---|
| server/client.go | 185 | 387–571 | 5,680 |
| server/client_proxyproto.go | 10 | 572–581 | 273 |
| Total | 195 | 5,953 |
.NET Classes
ClientConnection— client state, read/write loops, publish, subscribe, unsubscribeClientFlag— client state flagsClientInfo— client metadataProxyProtocolAddress— PROXY protocol v1/v2 parsing
Test Files
| Test File | Tests | Test IDs |
|---|---|---|
| server/client_test.go | 82 | 182–263 |
| server/client_proxyproto_test.go | 23 | 159–181 |
| server/closed_conns_test.go | 7 | 264–270 |
| server/ping_test.go | 1 | 2615 |
| Total | 113 |
Dependencies
- Session 01 (Foundation Types)
- Session 02 (Utilities — queues)
- Session 03 (Configuration — ServerOptions)
- Session 05 (Subscription Index)
- Session 07 (Protocol Parser)
.NET Target Location
dotnet/src/ZB.MOM.NatsNet.Server/ClientConnection.cs
Notes
- This is the core networking class — every connected client has one
- Heavy use of
sync.Mutexin Go → considerlockorSemaphoreSlim - Write coalescing and flush logic is performance-critical
- May need partial class split:
ClientConnection.Read.cs,ClientConnection.Write.cs, etc.