Skip to content

Commit

Permalink
Add ANNOTATION_PUBLISH and ANNOTATION_SUBSCRIBE channel modes
Browse files Browse the repository at this point in the history
and new ProtocolMessage action
  • Loading branch information
SimonWoolf committed Jan 23, 2025
1 parent f8047f6 commit 5880ced
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
16 changes: 13 additions & 3 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,17 +855,25 @@ declare namespace ChannelModes {
*/
type PUBLISH = 'PUBLISH';
/**
* The client can subscribe to messages.
* The client will receive messages.
*/
type SUBSCRIBE = 'SUBSCRIBE';
/**
* The client can enter the presence set.
*/
type PRESENCE = 'PRESENCE';
/**
* The client can receive presence messages.
* The client will receive presence messages.
*/
type PRESENCE_SUBSCRIBE = 'PRESENCE_SUBSCRIBE';
/**
* The client can publish annotations
*/
type ANNOTATION_PUBLISH = 'ANNOTATION_PUBLISH';
/**
* The client will receive annotations
*/
type ANNOTATION_SUBSCRIBE = 'ANNOTATION_SUBSCRIBE';
}

/**
Expand All @@ -875,7 +883,9 @@ export type ChannelMode =
| ChannelModes.PUBLISH
| ChannelModes.SUBSCRIBE
| ChannelModes.PRESENCE
| ChannelModes.PRESENCE_SUBSCRIBE;
| ChannelModes.PRESENCE_SUBSCRIBE
| ChannelModes.ANNOTATION_PUBLISH
| ChannelModes.ANNOTATION_SUBSCRIBE;

/**
* Passes additional properties to a {@link Channel} or {@link RealtimeChannel} object, such as encryption, {@link ChannelMode} and channel parameters.
Expand Down
12 changes: 11 additions & 1 deletion src/common/lib/types/protocolmessagecommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const actions = {
SYNC: 16,
AUTH: 17,
ACTIVATE: 18,
STATE: 19,
STATE_SYNC: 20,
ANNOTATION: 21,
};

export const ActionName: string[] = [];
Expand All @@ -40,10 +43,17 @@ export const flags: { [key: string]: number } = {
PUBLISH: 1 << 17,
SUBSCRIBE: 1 << 18,
PRESENCE_SUBSCRIBE: 1 << 19,
ANNOTATION_PUBLISH: 1 << 21,
ANNOTATION_SUBSCRIBE: 1 << 22,
};

export const flagNames = Object.keys(flags);

flags.MODE_ALL = flags.PRESENCE | flags.PUBLISH | flags.SUBSCRIBE | flags.PRESENCE_SUBSCRIBE;
flags.MODE_ALL = flags.PRESENCE
| flags.PUBLISH
| flags.SUBSCRIBE
| flags.PRESENCE_SUBSCRIBE
| flags.ANNOTATION_PUBLISH
| flags.ANNOTATION_SUBSCRIBE;

export const channelModes = ['PRESENCE', 'PUBLISH', 'SUBSCRIBE', 'PRESENCE_SUBSCRIBE'];

0 comments on commit 5880ced

Please sign in to comment.