wirejs-resources 0.1.74-realtime → 0.1.75-realtime
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.
|
@@ -15,6 +15,6 @@ export declare class RealtimeService<T = any> extends Resource {
|
|
|
15
15
|
* The address the client will need to connect to.
|
|
16
16
|
*/
|
|
17
17
|
get address(): string;
|
|
18
|
-
publish(channel: string,
|
|
18
|
+
publish(channel: string, events: T[]): Promise<void>;
|
|
19
19
|
getStream(channel: string): Promise<MessageStream<T>>;
|
|
20
20
|
}
|
|
@@ -111,13 +111,12 @@ export class RealtimeService extends Resource {
|
|
|
111
111
|
throw new Error('Server address is not available');
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
async publish(channel,
|
|
114
|
+
async publish(channel, events) {
|
|
115
115
|
this.#requireServer();
|
|
116
116
|
this.#validateChannelName(channel);
|
|
117
|
-
console.log('Publishing to channel:', channel,
|
|
117
|
+
console.log('Publishing to channel:', channel, events);
|
|
118
118
|
(this.#channels.get(channel) || []).forEach((ws) => {
|
|
119
119
|
if (ws.readyState === WebSocket.OPEN) {
|
|
120
|
-
const events = Array.isArray(data) ? data : [data];
|
|
121
120
|
for (const event of events) {
|
|
122
121
|
ws.send(JSON.stringify({ data: event }));
|
|
123
122
|
}
|