Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Libp2pTopic

Represents libp2p pub-sub topics for Coaty communication events (except Raw and external IoValue events).

Hierarchy

  • Libp2pTopic

Index

Accessors

correlationId

  • get correlationId(): string

eventType

  • get eventType(): CommunicationEventType

eventTypeFilter

  • get eventTypeFilter(): string

namespace

  • get namespace(): string

version

  • get version(): number

Methods

Static createByName

  • Create a new topic instance from the given libp2p publication topic name.

    Parameters

    • topicName: string

      the structured name of a Coaty publication topic

    Returns Libp2pTopic

    a Coaty communication topic instance or undefined if the topic name represents a Raw or external IoValue event.

Static getTopicFilter

  • getTopicFilter(version: number, namespace: string, eventType: CommunicationEventType, eventTypeFilter: string, correlationId: Uuid): string
  • Gets a libp2p topic for subscription.

    Parameters

    • version: number

      the protocol version

    • namespace: string
    • eventType: CommunicationEventType

      the event type

    • eventTypeFilter: string

      the event filter or undefined

    • correlationId: Uuid

      correlation ID for two-way message, otherwise undefined

    Returns string

Static getTopicName

  • getTopicName(version: number, namespace: string, eventType: CommunicationEventType, eventTypeFilter: string, correlationId: Uuid): string
  • Gets the p2p publication topic name for the given topic levels.

    Parameters

    • version: number

      the protocol version

    • namespace: string
    • eventType: CommunicationEventType

      an event type

    • eventTypeFilter: string

      a filter for an event type, or undefined

    • correlationId: Uuid

      correlation ID for two-way message, otherwise undefined

    Returns string

Static isCoatyTopicLike

  • isCoatyTopicLike(topicName: string): boolean
  • Determines whether the given topic name starts with the same topic level as a Coaty topic.

    Parameters

    • topicName: string

      a topic name

    Returns boolean

    true if the given topic name is a potential Coaty topic; false otherwise

Static isTwoWayRequestEvent

  • isTwoWayRequestEvent(eventType: CommunicationEventType): boolean

Static isValidTopic

  • isValidTopic(name: string, forSubscription?: boolean): boolean
  • Determines whether the given name is a valid libp2p topic for publication or subscription.

    Parameters

    • name: string

      a topic name

    • Default value forSubscription: boolean = false

      indicates whether the name is used for subscription (true) or publication (false)

    Returns boolean

    true if the given topic name can be used as requested; false otherwise

Generated using TypeDoc