Interface RealtimeAnnotations

Functionality for annotating messages with small pieces of data, such as emoji reactions, that the server will roll up into the message as a summary.

Hierarchy

  • RealtimeAnnotations

Methods

  • Publish an annotation removal request for a message, to remove it from the message's annotation summary. The semantics of a delete, and the fields it requires, differ by annotation type.

    It sets action to annotation.delete on the annotation object you pass, overwriting any action you set.

    The supplied Message must carry a populated serial. A newly constructed Message has none, so the call rejects with an ErrorInfo.

    Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.

    Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.

    Parameters

    • message: Message

      The message which has an annotation that you want to delete.

    • annotation: OutboundAnnotation

      The annotation deletion request. It must include at least the type. Other required fields depend on the type.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

    Example

    await channel.annotations.delete(message, { type: 'emoji:distinct.v1', name: '👍' });
    

    See

    https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-delete

  • Publish an annotation removal request for a message, to remove it from the message's annotation summary. The semantics of a delete, and the fields it requires, differ by annotation type.

    It sets action to annotation.delete on the annotation object you pass, overwriting any action you set.

    The supplied serial must be a non-empty string, otherwise the call rejects with an ErrorInfo.

    Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.

    Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.

    Parameters

    • messageSerial: string

      The serial field of the message which has an annotation that you want to delete.

    • annotation: OutboundAnnotation

      The annotation deletion request. It must include at least the type. Other required fields depend on the type.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

    Example

    await channel.annotations.delete(message.serial, { type: 'emoji:distinct.v1', name: '👍' });
    

    See

    https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-delete

  • Publish a new annotation for a message. If the annotation specifies no action, it defaults to annotation.create.

    The supplied Message must carry a populated serial. A newly constructed Message has none, so the call rejects with an ErrorInfo.

    Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.

    Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.

    Annotation data is never encrypted, even when cipher is set, because the server must be able to read it to build summaries.

    Parameters

    • message: Message

      The message to annotate.

    • annotation: OutboundAnnotation

      The annotation to publish. It must include at least the type. Other required fields depend on the annotation type.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

    Example

    await channel.annotations.publish(message, { type: 'emoji:distinct.v1', name: '👍' });
    

    See

    https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-publish

  • Publish a new annotation for a message. If the annotation specifies no action, it defaults to annotation.create.

    The supplied serial must be a non-empty string, otherwise the call rejects with an ErrorInfo.

    Message annotations must be enabled for the channel's namespace by a rule, and the key or token must have the annotation-publish capability. Without either the server rejects the operation, so the call rejects with an ErrorInfo.

    Does not implicitly attach the channel. It rejects with an ErrorInfo on a channel in the failed or suspended state, or when the connection is unusable.

    Annotation data is never encrypted, even when cipher is set, because the server must be able to read it to build summaries.

    Parameters

    • messageSerial: string

      The serial field of the message to annotate.

    • annotation: OutboundAnnotation

      The annotation to publish. It must include at least the type. Other required fields depend on the annotation type.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

    Example

    await channel.annotations.publish(message.serial, { type: 'emoji:distinct.v1', name: '👍' });
    

    See

    https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-publish

  • Registers a listener that is called each time an Annotation matching a given type is received on the channel. Implicitly attaches the channel unless attachOnSubscribe is false.

    Individual annotations are delivered only to clients that request the annotation_subscribe mode via modes, since most clients can rely on the rolled-up summary updates instead. The server grants the mode only if the key or token has the annotation-subscribe capability, and silently drops it otherwise.

    Message annotations must be enabled for the channel's namespace by a rule. Without it the attach rejects with an ErrorInfo.

    On a channel in the failed state the call rejects before the listener is registered. If the channel attaches without the mode it also rejects, but the listener stays registered and will fire if the mode is granted later. Remove it with unsubscribe() if that is not what you want. When attachOnSubscribe is false and the channel is not yet attached, the call resolves and a listener that lacks the mode never fires.

    Parameters

    • type: string | string[]

      A specific type string or an array of them to register the listener for.

    • Optional listener: messageCallback<Annotation>

      An event listener function.

    Returns Promise<void>

    A promise which resolves upon success of the channel attach() operation and rejects with an ErrorInfo object upon its failure. When attachOnSubscribe is false, no attach is performed.

    Example

    await channel.annotations.subscribe('emoji:distinct.v1', (annotation) => console.log(annotation.name));
    

    See

    https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-subscribe

  • Registers a listener that is called each time an Annotation is received on the channel. Implicitly attaches the channel unless attachOnSubscribe is false.

    Individual annotations are delivered only to clients that request the annotation_subscribe mode via modes, since most clients can rely on the rolled-up summary updates instead. The server grants the mode only if the key or token has the annotation-subscribe capability, and silently drops it otherwise.

    Message annotations must be enabled for the channel's namespace by a rule. Without it the attach rejects with an ErrorInfo.

    On a channel in the failed state the call rejects before the listener is registered. If the channel attaches without the mode it also rejects, but the listener stays registered and will fire if the mode is granted later. Remove it with unsubscribe() if that is not what you want. When attachOnSubscribe is false and the channel is not yet attached, the call resolves and a listener that lacks the mode never fires.

    Parameters

    Returns Promise<void>

    A promise which resolves upon success of the channel attach() operation and rejects with an ErrorInfo object upon its failure. When attachOnSubscribe is false, no attach is performed.

    Example

    await channel.annotations.subscribe((annotation) => console.log(annotation.name));
    

    See

    https://ably.com/docs/pub-sub/api/javascript/realtime/realtime-annotations#annotations-subscribe

Generated using TypeDoc