Skip to content

Commit

Permalink
use separate field for real channel
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Sep 2, 2024
1 parent 4345212 commit 2179417
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/centrifuge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1699,10 +1699,11 @@ export class Centrifuge extends (EventEmitter as new () => TypedEventEmitter<Cli
private _getPublicationContext(channel: string, pub: any) {
const ctx: any = {
channel: channel,
data: pub.data
data: pub.data,
publicationChannel: channel
};
if (pub.channel) {
ctx.channel = pub.channel;
ctx.publicationChannel = pub.channel;
}
if (pub.offset) {
ctx.offset = pub.offset;
Expand Down
12 changes: 11 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export interface PublicationContext {
offset?: number;
// tags is an extra key-value attached to publication, tags may be set when calling server publish API.
tags?: Record<string, string>;
// publicationChannel may be used to find out the real channel of publication, in most cases it
// matches channel field, but when wildcard subscriptions are used it may be different and contain
// a channel to which publication was published, thus differ from channel field (which is always a
// channel to which client subscribed to).
publicationChannel: string;
}

export interface ClientInfo {
Expand Down Expand Up @@ -260,7 +265,7 @@ export interface UnsubscribedContext {
}

export interface ServerPublicationContext {
// channel from which publication was received.
// subscription channel from which publication was received.
channel: string;
// data contains publication payload.
data: any;
Expand All @@ -273,6 +278,11 @@ export interface ServerPublicationContext {
offset?: number;
// tags is an extra key-value attached to publication, tags may be set when calling server publish API.
tags?: Record<string, string>;
// publicationChannel may be used to find out the real channel of publication, in most cases it
// matches channel field, but when wildcard subscriptions are used it may be different and contain
// a channel to which publication was published, thus differ from channel field (which is always a
// channel to which client subscribed to).
publicationChannel: string;
}

export interface ServerJoinContext {
Expand Down

0 comments on commit 2179417

Please sign in to comment.