@crowdedkingdomstudios/crowdyjs 4.0.0 → 5.0.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.
@@ -1,4 +1,4 @@
1
- import { ConnectUdpProxyDocument, DisconnectUdpProxyDocument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendTextPacketDocument, SendClientEventDocument, SendSingleActorMessageDocument, } from '../generated/graphql.js';
1
+ import { ConnectUdpProxyDocument, DisconnectUdpProxyDocument, UdpProxyConnectionStatusDocument, SendActorUpdateDocument, SendVoxelUpdateDocument, SendAudioPacketDocument, SendTextPacketDocument, SendClientEventDocument, SendSingleActorMessageDocument, SendChannelMessageDocument, } from '../generated/graphql.js';
2
2
  import { SequenceAllocator } from '../utils.js';
3
3
  /**
4
4
  * UDP proxy access for browser-style clients that can't open raw UDP
@@ -89,13 +89,28 @@ export class UdpAPI {
89
89
  return data.sendSingleActorMessage;
90
90
  }
91
91
  /**
92
- * Subscribe to udpNotifications. Pass any combination of typename
93
- * handlers; the returned function detaches all of them. The first
94
- * subscriber opens the shared WebSocket; the last one to leave closes
95
- * it.
92
+ * Publish a message to a channel. Delivered to every active member of the
93
+ * channel (regardless of location) as a `ChannelMessageNotification` on their
94
+ * `udpNotifications` subscription. Requires the channel `send_messages`
95
+ * permission; the server drops the message otherwise. Fire-and-forget: the
96
+ * sender receives no echo.
96
97
  */
97
- subscribe(handlers) {
98
- return this.subs.subscribe(handlers);
98
+ async sendChannelMessage(input) {
99
+ const data = await this.gql.request(SendChannelMessageDocument, { input });
100
+ return data.sendChannelMessage;
101
+ }
102
+ /**
103
+ * Subscribe to udpNotifications for a single app. Pass any combination of
104
+ * typename handlers; the returned function detaches all of them. The first
105
+ * subscriber opens the shared WebSocket; the last one to leave closes it.
106
+ *
107
+ * `appId` is required and scopes the subscription to one app: the game-api
108
+ * only delivers that app's spatial notifications and rejects app-agnostic
109
+ * subscriptions (a single game token reused across apps would otherwise
110
+ * cross-deliver). Use a separate client per app (sharing the token store).
111
+ */
112
+ subscribe(handlers, appId) {
113
+ return this.subs.subscribe(handlers, appId);
99
114
  }
100
115
  withSequence(input) {
101
116
  return {