@crowdedkingdoms/crowdyjs 8.4.6 → 8.6.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/MIGRATION.md +27 -0
- package/README.md +2 -1
- package/dist/crowdy-client.d.ts +13 -0
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +6 -2
- package/dist/domains/compute.d.ts +175 -0
- package/dist/domains/compute.d.ts.map +1 -0
- package/dist/domains/compute.js +232 -0
- package/dist/domains/udp.d.ts +5 -1
- package/dist/domains/udp.d.ts.map +1 -1
- package/dist/domains/udp.js +14 -1
- package/dist/generated/graphql.d.ts +893 -1
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +22 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/kit/npcs.d.ts.map +1 -1
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/metrics.d.ts +90 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +158 -0
- package/dist/realtime.d.ts +5 -1
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +26 -1
- package/package.json +1 -1
package/dist/domains/udp.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConnectUdpProxyDocument, DisconnectUdpProxyDocument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendTextPacketDocument, SendClientEventDocument, SendSingleActorMessageDocument, SendChannelMessageDocument, } from '../generated/graphql.js';
|
|
2
|
+
import { payloadBytesOf } from '../metrics.js';
|
|
2
3
|
import { SequenceAllocator } from '../utils.js';
|
|
3
4
|
/**
|
|
4
5
|
* UDP proxy access for browser-style clients that can't open raw UDP sockets.
|
|
@@ -34,11 +35,16 @@ import { SequenceAllocator } from '../utils.js';
|
|
|
34
35
|
* `...AndWait` echo or notification you must have an active {@link subscribe}.
|
|
35
36
|
*/
|
|
36
37
|
export class UdpAPI {
|
|
37
|
-
constructor(gql, subs) {
|
|
38
|
+
constructor(gql, subs, metrics) {
|
|
38
39
|
this.gql = gql;
|
|
39
40
|
this.subs = subs;
|
|
41
|
+
this.metrics = metrics;
|
|
40
42
|
this.sequences = new SequenceAllocator();
|
|
41
43
|
}
|
|
44
|
+
/** Count a message accepted for sending (see `client.metrics`). */
|
|
45
|
+
record(kind, input) {
|
|
46
|
+
this.metrics?.recordSent(kind, payloadBytesOf(input));
|
|
47
|
+
}
|
|
42
48
|
/**
|
|
43
49
|
* Open (or re-fetch) the UDP proxy session for this game token. Idempotent:
|
|
44
50
|
* if a session is already open it returns the existing status; on first open
|
|
@@ -115,6 +121,7 @@ export class UdpAPI {
|
|
|
115
121
|
*/
|
|
116
122
|
async sendActorUpdate(input) {
|
|
117
123
|
const data = await this.gql.request(SendActorUpdateDocument, { input });
|
|
124
|
+
this.record('actorUpdate', input);
|
|
118
125
|
return data.sendActorUpdate;
|
|
119
126
|
}
|
|
120
127
|
/**
|
|
@@ -188,6 +195,7 @@ export class UdpAPI {
|
|
|
188
195
|
*/
|
|
189
196
|
async sendVoxelUpdate(input) {
|
|
190
197
|
const data = await this.gql.request(SendVoxelUpdateDocument, { input });
|
|
198
|
+
this.record('voxelUpdate', input);
|
|
191
199
|
return data.sendVoxelUpdate;
|
|
192
200
|
}
|
|
193
201
|
/**
|
|
@@ -240,6 +248,7 @@ export class UdpAPI {
|
|
|
240
248
|
*/
|
|
241
249
|
async sendAudioPacket(input) {
|
|
242
250
|
const data = await this.gql.request(SendAudioPacketDocument, { input });
|
|
251
|
+
this.record('audio', input);
|
|
243
252
|
return data.sendAudioPacket;
|
|
244
253
|
}
|
|
245
254
|
/**
|
|
@@ -288,6 +297,7 @@ export class UdpAPI {
|
|
|
288
297
|
*/
|
|
289
298
|
async sendTextPacket(input) {
|
|
290
299
|
const data = await this.gql.request(SendTextPacketDocument, { input });
|
|
300
|
+
this.record('text', input);
|
|
291
301
|
return data.sendTextPacket;
|
|
292
302
|
}
|
|
293
303
|
/**
|
|
@@ -340,6 +350,7 @@ export class UdpAPI {
|
|
|
340
350
|
*/
|
|
341
351
|
async sendClientEvent(input) {
|
|
342
352
|
const data = await this.gql.request(SendClientEventDocument, { input });
|
|
353
|
+
this.record('clientEvent', input);
|
|
343
354
|
return data.sendClientEvent;
|
|
344
355
|
}
|
|
345
356
|
/**
|
|
@@ -392,6 +403,7 @@ export class UdpAPI {
|
|
|
392
403
|
const data = await this.gql.request(SendSingleActorMessageDocument, {
|
|
393
404
|
input,
|
|
394
405
|
});
|
|
406
|
+
this.record('singleActorMessage', input);
|
|
395
407
|
return data.sendSingleActorMessage;
|
|
396
408
|
}
|
|
397
409
|
/**
|
|
@@ -416,6 +428,7 @@ export class UdpAPI {
|
|
|
416
428
|
*/
|
|
417
429
|
async sendChannelMessage(input) {
|
|
418
430
|
const data = await this.gql.request(SendChannelMessageDocument, { input });
|
|
431
|
+
this.record('channelMessage', input);
|
|
419
432
|
return data.sendChannelMessage;
|
|
420
433
|
}
|
|
421
434
|
/**
|