@ably/laravel-echo
Version:
Laravel Echo library for beautiful Ably integration
22 lines (20 loc) • 737 B
text/typescript
import { AblyChannel } from './ably-channel';
import { AblyAuth } from './ably/auth';
export class AblyPrivateChannel extends AblyChannel {
constructor(ably: any, name: string, options: any, auth: AblyAuth) {
super(ably, name, options, false);
this.channel.on('failed', auth.onChannelFailed(this));
this.subscribe();
}
/**
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any, callback?: Function): AblyPrivateChannel {
if (callback) {
this.channel.publish(`client-${eventName}`, data, callback as any);
} else {
this.channel.publish(`client-${eventName}`, data);
}
return this;
}
}