@zyno-io/ts-server-foundation 26.930.146 → 26.930.307

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,15 @@ message ServerMessage {
41
41
  }
42
42
  }
43
43
 
44
- message PingPong {}
44
+ enum PingPongType {
45
+ PING_PONG_TYPE_UNSPECIFIED = 0;
46
+ PING_PONG_TYPE_HELLO = 1;
47
+ PING_PONG_TYPE_HELLO_ACK = 2;
48
+ PING_PONG_TYPE_ACTIVATED = 3;
49
+ PING_PONG_TYPE_PING = 4;
50
+ PING_PONG_TYPE_PONG = 5;
51
+ }
52
+ message PingPong { optional PingPongType type = 1; }
45
53
  message TraceContext {
46
54
  string traceId = 1;
47
55
  string spanId = 2;
@@ -167,7 +175,7 @@ Server options:
167
175
 
168
176
  Handlers may also be zero-argument classes with a `handle(stream, data)` method. A new class instance is created for each request; SRPC does not resolve handler classes through application DI.
169
177
 
170
- Connection setup is deliberately ordered. After authentication, the server creates a pending stream and sends the initial `pingPong`. Registered connection handlers then run in registration order and are awaited. Only after they complete does the stream become active and queued client requests begin. A connection-handler failure disconnects the stream before activation. Disconnect handlers run in registration order but are synchronous callbacks; returning a promise does not delay cleanup.
178
+ Connection setup is deliberately ordered. After authentication, the server creates a pending stream and sends `pingPong` with type `HELLO`. The client answers with `HELLO_ACK`. Registered connection handlers run in registration order and are awaited. Only after they complete does the stream become active, the server send `ACTIVATED`, and queued client requests begin. A connection-handler failure disconnects the stream before activation. Disconnect handlers run in registration order but are synchronous callbacks; returning a promise does not delay cleanup.
171
179
 
172
180
  ## Server-To-Client Calls
173
181
 
@@ -226,7 +234,22 @@ The exported `SrpcClientOptions` type describes this object. `connect({ supersed
226
234
 
227
235
  Protocol-v2 and protocol-v3 connections reject a duplicate `clientId` unless `connect({ supersede: true })` is used. Legacy protocol-v1 connections retain replacement behavior: a later connection with the same `clientId` silently supersedes the existing stream.
228
236
 
229
- After the initial ping handshake, the client sends a ping every 55 seconds. A connection with no pong for 75 seconds closes with the `timeout` cause. The server checks the same 75-second inactivity window every 15 seconds. Unexpected client disconnects reconnect after one second when `enableReconnect` is true; `disconnect()`, conflicts, and an explicit `enableReconnect: false` suppress reconnection. `triggerConnectionCheck()` forces an immediate ping-based liveness check.
237
+ The optional `PingPong.type` enum distinguishes handshake messages from client pings and server pongs. Generated TypeScript codecs represent it as a numeric `PingPongType` enum with the prefixed names shown above and an optional `type` property (`undefined` when absent). The library exports matching numeric values as `SrpcPingPongType`.
238
+
239
+ | Type | Value | `SrpcClient` behavior |
240
+ | ----------------------- | ----- | ---------------------------------------------------------------------------------------- |
241
+ | `UNSPECIFIED` or absent | `0` | Legacy sequence: answer the first ping, connect on the next, then only refresh liveness. |
242
+ | `HELLO` | `1` | Answer with `HELLO_ACK`; wait for activation. |
243
+ | `HELLO_ACK` | `2` | Sent by the client to acknowledge `HELLO`. |
244
+ | `ACTIVATED` | `3` | Complete activation without answering. |
245
+ | `PING` | `4` | Sent by the client to check liveness. |
246
+ | `PONG` | `5` | Refresh liveness without answering or completing activation. |
247
+
248
+ An explicit `ACTIVATED` completes activation even without a prior `HELLO`. Duplicate `HELLO` messages receive `HELLO_ACK` responses and do not complete activation or repeat connection callbacks. All pingPongs refresh liveness; inbound `HELLO_ACK`, `PING`, and unknown future nonzero types do nothing else on the client. If liveness messages precede the handshake, the client still answers the first untyped ping and waits for the next untyped ping or `ACTIVATED`. The DevConsole browser client also waits for typed `ACTIVATED`, while preserving its existing first-ping connection behavior with untyped servers.
249
+
250
+ After activation, the client sends `PING` every 55 seconds. The server updates inbound liveness for every pingPong and answers typed `PING` and legacy untyped or `UNSPECIFIED` messages with `PONG` only after activation, regardless of the `reply` flag. It does not answer other nonzero types. Server pingPongs and client pings carry no `requestId` or `reply: true` flag. A connection with no pong for 75 seconds closes with the `timeout` cause. The server checks the same 75-second inactivity window every 15 seconds. Unexpected client disconnects reconnect after one second when `enableReconnect` is true; `disconnect()`, conflicts, and an explicit `enableReconnect: false` suppress reconnection. `triggerConnectionCheck()` forces an immediate `PING`-based liveness check.
251
+
252
+ This is wire-compatible with empty legacy `PingPong` messages. Old protobuf decoders ignore the new field, and new decoders accept empty messages. Applications own their envelope schemas and pass their generated codecs to sRPC: add the enum and optional field to each application's proto and regenerate with `tsf-gen-proto` to send or read the type. An old server-side codec ignores the in-memory `type` during encoding, so even an upgraded library sends empty pingPongs until that codec is regenerated. Existing peers can continue using the legacy handshake without regeneration. Custom codecs must likewise accept the optional field or ignore it.
230
253
 
231
254
  ## Authentication
232
255
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyno-io/ts-server-foundation",
3
- "version": "26.930.146",
3
+ "version": "26.930.307",
4
4
  "description": "TypeScript server foundation with reflected type metadata",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -92,7 +92,7 @@
92
92
  "@ttsc/graph": "^0.30.1",
93
93
  "@types/ws": "^8.18.1",
94
94
  "@zyno-io/config": "^1.14.0",
95
- "@zyno-io/ts-reflection": "26.930.146",
95
+ "@zyno-io/ts-reflection": "26.930.307",
96
96
  "bcrypt": "^6.0.0",
97
97
  "bullmq": "^6.3.4",
98
98
  "busboy": "^1.6.0",
@@ -6,7 +6,15 @@ package sgnl24.DevConsole;
6
6
  /// Framework
7
7
  ///
8
8
 
9
- message PingPong {}
9
+ enum PingPongType {
10
+ PING_PONG_TYPE_UNSPECIFIED = 0;
11
+ PING_PONG_TYPE_HELLO = 1;
12
+ PING_PONG_TYPE_HELLO_ACK = 2;
13
+ PING_PONG_TYPE_ACTIVATED = 3;
14
+ PING_PONG_TYPE_PING = 4;
15
+ PING_PONG_TYPE_PONG = 5;
16
+ }
17
+ message PingPong { optional PingPongType type = 1; }
10
18
 
11
19
  message WriteByteStream { bytes chunk = 1; }
12
20
  message FinishByteStream {}