@irtio/protocol 0.8.0 → 0.9.0
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.
- package/dist/index.d.ts +41 -1
- package/dist/index.js +30 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -275,7 +275,47 @@ declare const ErrorCode: {
|
|
|
275
275
|
readonly code: 34;
|
|
276
276
|
readonly message: "room {roomId} was deleted by an operator; its stored state is gone";
|
|
277
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* The box dropped this client because the socket stopped answering, not because anything about
|
|
280
|
+
* the game went wrong.
|
|
281
|
+
*
|
|
282
|
+
* Two mechanisms end here, and they are the two ways a client can be alive on paper and useless
|
|
283
|
+
* on the wire. The keepalive: the supervisor pings every {@link IDLE_PING_MS} and drops a
|
|
284
|
+
* session that has missed {@link IDLE_PING_MISSES} pongs, so a socket has about
|
|
285
|
+
* `IDLE_PING_MS * (IDLE_PING_MISSES + 1)` of silence before it goes. And the slow consumer:
|
|
286
|
+
* a client whose receive buffer keeps growing gets {@link ErrorCode.E_SLOW_CONSUMER} instead,
|
|
287
|
+
* which is the same family of problem said more precisely.
|
|
288
|
+
*
|
|
289
|
+
* Its own code because the alternative is what the platform did before: `terminate()`, which
|
|
290
|
+
* gives the browser a 1006 with no code and no reason, indistinguishable from a lost network,
|
|
291
|
+
* a crashed box and a closed room. A client that can read this can say "you were disconnected
|
|
292
|
+
* for being idle" and reconnect, which is the right move — nothing was lost and the room is
|
|
293
|
+
* still there. Not fatal, for that reason.
|
|
294
|
+
*
|
|
295
|
+
* Close code {@link CLOSE_IDLE_TIMEOUT}.
|
|
296
|
+
*/
|
|
297
|
+
readonly E_IDLE_TIMEOUT: {
|
|
298
|
+
readonly code: 35;
|
|
299
|
+
readonly message: "connection idle: no response to {misses} keepalives over {seconds}s";
|
|
300
|
+
};
|
|
278
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* How often the box pings an open session, and how many unanswered pings it takes to drop it.
|
|
304
|
+
*
|
|
305
|
+
* Named here rather than only at the drop site because they are the two numbers a client author
|
|
306
|
+
* has to know to tell an idle drop from an outage, and the documented threshold has to come from
|
|
307
|
+
* the same constant the box enforces.
|
|
308
|
+
*/
|
|
309
|
+
declare const IDLE_PING_MS = 20000;
|
|
310
|
+
declare const IDLE_PING_MISSES = 2;
|
|
311
|
+
/**
|
|
312
|
+
* The WebSocket close code for {@link ErrorCode.E_IDLE_TIMEOUT}.
|
|
313
|
+
*
|
|
314
|
+
* In the application range beside {@link CLOSE_EGRESS_WALL} and {@link CLOSE_ROOM_DELETED}, for
|
|
315
|
+
* their reason: the client's `onclose` carries `{ code, reason }`, and a close a client should
|
|
316
|
+
* quietly reconnect from has to be distinguishable from one it must not.
|
|
317
|
+
*/
|
|
318
|
+
declare const CLOSE_IDLE_TIMEOUT = 4408;
|
|
279
319
|
/**
|
|
280
320
|
* The WebSocket close code the router uses for {@link ErrorCode.E_PLACEMENT}: RFC 6455's 1013,
|
|
281
321
|
* "try again later". Distinct from the 1008 policy close and the 1011 internal-error close the
|
|
@@ -1611,4 +1651,4 @@ declare function originAllowed(origins: readonly string[], allowNoOrigin: boolea
|
|
|
1611
1651
|
*/
|
|
1612
1652
|
declare function parseOriginList(raw: string | undefined): readonly string[];
|
|
1613
1653
|
|
|
1614
|
-
export { type AttributeOptions, BUS_CHANNEL_RE, BUS_ERRORS, BUS_LIMITS, BUS_MAILBOX_PREFIX, BUS_OUTBOX, BUS_OUTBOX_PREFIX, BUS_SHARD_STARTING, type BusErrorCode, type BusMailboxEntry, type BusOutboxEntry, type BusProblem, CLOSE_EGRESS_WALL, CLOSE_ROOM_DELETED, CLOSE_TRY_AGAIN_LATER, CODE_ALPHABET, CPU_QUOTA_PCT_MAX, CPU_QUOTA_PCT_MIN, type Call, type ChurnIds, type ClientCallable, type Credential, DEFAULT_MAX_AWAKE, DEFAULT_MEMORY_MB, DEFAULT_ROOM_TYPE, EMPTY_PROFILE, ERROR_CATALOGUE, type ErrorCatalogueEntry, ErrorCode, type ErrorCodeDef, type ErrorCodeName, type ErrorPayload, type Frame, FrameType, HELLO_SCHEMA_SWAP_BIT, type Hello, MATCH_CODE_LENGTH, MAX_AWAKE_MAX, MSG_KIND_TYPED, type Msg, type MsgTarget, NATIVE_RESERVE_FRACTION, PHYSICS_HEADROOM_MIB, PRESENCE_COLLECTION, PROFILE_KINDS, PROTOCOL_VERSION, type ParsedRoomId, type Ping, type Pong, type PresenceRecord, type ProfileKind, ProfileLedger, type ProfileRow, type ProfileSnapshot, RELAY_HASH8, RETENTION_MAX_MS, RETENTION_MIN_MS, RETENTION_RE, ROOMS_PER_VCPU, ROOM_CLASS_MAX_MB, ROOM_ID_RE, ROOM_MEMORY_MB_MAX, ROOM_MEMORY_MB_MIN, ROOM_TYPE_DELIMITER, ROOM_TYPE_RE, type Reply, type RoomSizeClass, type RoomTypeSizing, SUPERVISOR_BASELINE_MIB, VM_MEM_MIB_MAX, VM_MEM_MIB_MIN, type VmCpuSizing, type VmSizing, type VoiceClientMessage, type VoicePeer, type VoiceServerMessage, type VoiceTransportInfo, type Welcome, YOUNG_GEN_MB, builtinRpcs, busChannelProblem, busPayloadProblem, correctPayload, declarationsFit, decodeCall, decodeErrorPayload, decodeFrame, decodeHello, decodeMsg, decodePing, decodePong, decodeReply, decodeVoiceMessage, decodeWelcome, deltaPayload, diffProfiles, encodeCall, encodeCorrectFrame, encodeDeltaFrame, encodeErrorPayload, encodeFrame, encodeHello, encodeMsg, encodePing, encodePong, encodeReply, encodeSchemaFrame, encodeVoiceMessage, encodeWelcome, encodeWriteFrame, errorByCode, formatError, formatRoomId, isFrameType, isLocalhostOrigin, isMailboxAlarm, isOutboxAlarm, isRelayHash8, isTypedMsg, isVoiceMsg, mergeProfiles, nativeReserveOf, originAllowed, parseOriginList, parseRetention, parseRoomId, presenceEntity, readCorrectAppliedTick, readCorrectClientTick, readSchemaPayload, relaySchema, requestOwnership, roomClassFor, roomClassOfSource, roomHoursSourceFor, rpcByIdOf, rpcIdOf, rpcTable, scaleProfile, schemaPayload, topProfileRows, typeFootprintMib, typedMsgFromClientOk, vmCpuFor, vmSizeFor, withBuiltins, writePayload };
|
|
1654
|
+
export { type AttributeOptions, BUS_CHANNEL_RE, BUS_ERRORS, BUS_LIMITS, BUS_MAILBOX_PREFIX, BUS_OUTBOX, BUS_OUTBOX_PREFIX, BUS_SHARD_STARTING, type BusErrorCode, type BusMailboxEntry, type BusOutboxEntry, type BusProblem, CLOSE_EGRESS_WALL, CLOSE_IDLE_TIMEOUT, CLOSE_ROOM_DELETED, CLOSE_TRY_AGAIN_LATER, CODE_ALPHABET, CPU_QUOTA_PCT_MAX, CPU_QUOTA_PCT_MIN, type Call, type ChurnIds, type ClientCallable, type Credential, DEFAULT_MAX_AWAKE, DEFAULT_MEMORY_MB, DEFAULT_ROOM_TYPE, EMPTY_PROFILE, ERROR_CATALOGUE, type ErrorCatalogueEntry, ErrorCode, type ErrorCodeDef, type ErrorCodeName, type ErrorPayload, type Frame, FrameType, HELLO_SCHEMA_SWAP_BIT, type Hello, IDLE_PING_MISSES, IDLE_PING_MS, MATCH_CODE_LENGTH, MAX_AWAKE_MAX, MSG_KIND_TYPED, type Msg, type MsgTarget, NATIVE_RESERVE_FRACTION, PHYSICS_HEADROOM_MIB, PRESENCE_COLLECTION, PROFILE_KINDS, PROTOCOL_VERSION, type ParsedRoomId, type Ping, type Pong, type PresenceRecord, type ProfileKind, ProfileLedger, type ProfileRow, type ProfileSnapshot, RELAY_HASH8, RETENTION_MAX_MS, RETENTION_MIN_MS, RETENTION_RE, ROOMS_PER_VCPU, ROOM_CLASS_MAX_MB, ROOM_ID_RE, ROOM_MEMORY_MB_MAX, ROOM_MEMORY_MB_MIN, ROOM_TYPE_DELIMITER, ROOM_TYPE_RE, type Reply, type RoomSizeClass, type RoomTypeSizing, SUPERVISOR_BASELINE_MIB, VM_MEM_MIB_MAX, VM_MEM_MIB_MIN, type VmCpuSizing, type VmSizing, type VoiceClientMessage, type VoicePeer, type VoiceServerMessage, type VoiceTransportInfo, type Welcome, YOUNG_GEN_MB, builtinRpcs, busChannelProblem, busPayloadProblem, correctPayload, declarationsFit, decodeCall, decodeErrorPayload, decodeFrame, decodeHello, decodeMsg, decodePing, decodePong, decodeReply, decodeVoiceMessage, decodeWelcome, deltaPayload, diffProfiles, encodeCall, encodeCorrectFrame, encodeDeltaFrame, encodeErrorPayload, encodeFrame, encodeHello, encodeMsg, encodePing, encodePong, encodeReply, encodeSchemaFrame, encodeVoiceMessage, encodeWelcome, encodeWriteFrame, errorByCode, formatError, formatRoomId, isFrameType, isLocalhostOrigin, isMailboxAlarm, isOutboxAlarm, isRelayHash8, isTypedMsg, isVoiceMsg, mergeProfiles, nativeReserveOf, originAllowed, parseOriginList, parseRetention, parseRoomId, presenceEntity, readCorrectAppliedTick, readCorrectClientTick, readSchemaPayload, relaySchema, requestOwnership, roomClassFor, roomClassOfSource, roomHoursSourceFor, rpcByIdOf, rpcIdOf, rpcTable, scaleProfile, schemaPayload, topProfileRows, typeFootprintMib, typedMsgFromClientOk, vmCpuFor, vmSizeFor, withBuiltins, writePayload };
|
package/dist/index.js
CHANGED
|
@@ -168,9 +168,35 @@ var ErrorCode = {
|
|
|
168
168
|
E_ROOM_DELETED: {
|
|
169
169
|
code: 34,
|
|
170
170
|
message: "room {roomId} was deleted by an operator; its stored state is gone"
|
|
171
|
-
}
|
|
171
|
+
},
|
|
172
172
|
// ---- end M6 lane A ----
|
|
173
|
+
/**
|
|
174
|
+
* The box dropped this client because the socket stopped answering, not because anything about
|
|
175
|
+
* the game went wrong.
|
|
176
|
+
*
|
|
177
|
+
* Two mechanisms end here, and they are the two ways a client can be alive on paper and useless
|
|
178
|
+
* on the wire. The keepalive: the supervisor pings every {@link IDLE_PING_MS} and drops a
|
|
179
|
+
* session that has missed {@link IDLE_PING_MISSES} pongs, so a socket has about
|
|
180
|
+
* `IDLE_PING_MS * (IDLE_PING_MISSES + 1)` of silence before it goes. And the slow consumer:
|
|
181
|
+
* a client whose receive buffer keeps growing gets {@link ErrorCode.E_SLOW_CONSUMER} instead,
|
|
182
|
+
* which is the same family of problem said more precisely.
|
|
183
|
+
*
|
|
184
|
+
* Its own code because the alternative is what the platform did before: `terminate()`, which
|
|
185
|
+
* gives the browser a 1006 with no code and no reason, indistinguishable from a lost network,
|
|
186
|
+
* a crashed box and a closed room. A client that can read this can say "you were disconnected
|
|
187
|
+
* for being idle" and reconnect, which is the right move — nothing was lost and the room is
|
|
188
|
+
* still there. Not fatal, for that reason.
|
|
189
|
+
*
|
|
190
|
+
* Close code {@link CLOSE_IDLE_TIMEOUT}.
|
|
191
|
+
*/
|
|
192
|
+
E_IDLE_TIMEOUT: {
|
|
193
|
+
code: 35,
|
|
194
|
+
message: "connection idle: no response to {misses} keepalives over {seconds}s"
|
|
195
|
+
}
|
|
173
196
|
};
|
|
197
|
+
var IDLE_PING_MS = 2e4;
|
|
198
|
+
var IDLE_PING_MISSES = 2;
|
|
199
|
+
var CLOSE_IDLE_TIMEOUT = 4408;
|
|
174
200
|
var CLOSE_TRY_AGAIN_LATER = 1013;
|
|
175
201
|
var CLOSE_EGRESS_WALL = 4290;
|
|
176
202
|
var CLOSE_ROOM_DELETED = 4291;
|
|
@@ -1305,6 +1331,7 @@ export {
|
|
|
1305
1331
|
BUS_OUTBOX_PREFIX,
|
|
1306
1332
|
BUS_SHARD_STARTING,
|
|
1307
1333
|
CLOSE_EGRESS_WALL,
|
|
1334
|
+
CLOSE_IDLE_TIMEOUT,
|
|
1308
1335
|
CLOSE_ROOM_DELETED,
|
|
1309
1336
|
CLOSE_TRY_AGAIN_LATER,
|
|
1310
1337
|
CODE_ALPHABET,
|
|
@@ -1318,6 +1345,8 @@ export {
|
|
|
1318
1345
|
ErrorCode,
|
|
1319
1346
|
FrameType,
|
|
1320
1347
|
HELLO_SCHEMA_SWAP_BIT,
|
|
1348
|
+
IDLE_PING_MISSES,
|
|
1349
|
+
IDLE_PING_MS,
|
|
1321
1350
|
MATCH_CODE_LENGTH,
|
|
1322
1351
|
MAX_AWAKE_MAX,
|
|
1323
1352
|
MSG_KIND_TYPED,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@irtio/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "irtio wire protocol: frames, framing, session payloads, error codes, built-in presence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@irtio/schema": "0.
|
|
23
|
+
"@irtio/schema": "0.9.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsup",
|