Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken Typescript presence channel interface "whisper" method #377

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
formatting
  • Loading branch information
taylorotwell committed Apr 19, 2023
commit 663570eb10e7fd7c2a60b2d3bb8ffb6a11c507ad
8 changes: 4 additions & 4 deletions src/channel/null-presence-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ export class NullPresenceChannel extends NullChannel implements PresenceChannel
}

/**
* Listen for someone leaving the channel.
* Send a whisper event to other clients in the channel.
*/
leaving(callback: Function): NullPresenceChannel {
whisper(eventName: string, data: any): NullPresenceChannel {
return this;
}

/**
* Trigger client event on the channel.
* Listen for someone leaving the channel.
*/
whisper(eventName: string, data: any): NullPresenceChannel {
leaving(callback: Function): NullPresenceChannel {
return this;
}
}
2 changes: 1 addition & 1 deletion src/channel/null-private-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NullChannel } from './null-channel';
*/
export class NullPrivateChannel extends NullChannel {
/**
* Trigger client event on the channel.
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): NullPrivateChannel {
return this;
Expand Down
8 changes: 4 additions & 4 deletions src/channel/presence-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export interface PresenceChannel extends Channel {
joining(callback: Function): PresenceChannel;

/**
* Listen for someone leaving the channel.
* Send a whisper event to other clients in the channel.
*/
leaving(callback: Function): PresenceChannel;
whisper(eventName: string, data: any): PresenceChannel;

/**
* Fire a whisper event to clients present in the channel.
* Listen for someone leaving the channel.
*/
whisper(eventName: string, data: any): PresenceChannel;
leaving(callback: Function): PresenceChannel;
}
2 changes: 1 addition & 1 deletion src/channel/pusher-encrypted-private-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PusherChannel } from './pusher-channel';
*/
export class PusherEncryptedPrivateChannel extends PusherChannel {
/**
* Trigger client event on the channel.
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): PusherEncryptedPrivateChannel {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);
Expand Down
16 changes: 8 additions & 8 deletions src/channel/pusher-presence-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ export class PusherPresenceChannel extends PusherChannel implements PresenceChan
}

/**
* Listen for someone leaving the channel.
* Send a whisper event to other clients in the channel.
*/
leaving(callback: Function): PusherPresenceChannel {
this.on('pusher:member_removed', (member) => {
callback(member.info);
});
whisper(eventName: string, data: any): PusherPresenceChannel {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);

return this;
}

/**
* Trigger client event on the channel.
* Listen for someone leaving the channel.
*/
whisper(eventName: string, data: any): PusherPresenceChannel {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);
leaving(callback: Function): PusherPresenceChannel {
this.on('pusher:member_removed', (member) => {
callback(member.info);
});

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/channel/pusher-private-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PusherChannel } from './pusher-channel';
*/
export class PusherPrivateChannel extends PusherChannel {
/**
* Trigger client event on the channel.
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): PusherPrivateChannel {
this.pusher.channels.channels[this.name].trigger(`client-${eventName}`, data);
Expand Down
20 changes: 10 additions & 10 deletions src/channel/socketio-presence-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,7 @@ export class SocketIoPresenceChannel extends SocketIoPrivateChannel implements P
}

/**
* Listen for someone leaving the channel.
*/
leaving(callback: Function): SocketIoPresenceChannel {
this.on('presence:leaving', (member) => callback(member.user_info));

return this;
}

/**
* Trigger client event on the channel.
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): SocketIoPresenceChannel {
this.socket.emit('client event', {
Expand All @@ -46,4 +37,13 @@ export class SocketIoPresenceChannel extends SocketIoPrivateChannel implements P

return this;
}

/**
* Listen for someone leaving the channel.
*/
leaving(callback: Function): SocketIoPresenceChannel {
this.on('presence:leaving', (member) => callback(member.user_info));

return this;
}
}
2 changes: 1 addition & 1 deletion src/channel/socketio-private-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SocketIoChannel } from './socketio-channel';
*/
export class SocketIoPrivateChannel extends SocketIoChannel {
/**
* Trigger client event on the channel.
* Send a whisper event to other clients in the channel.
*/
whisper(eventName: string, data: any): SocketIoChannel {
this.socket.emit('client event', {
Expand Down