Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides a set of predefined communication events to transfer Coaty objects between distributed Coaty agents based on publish-subscribe messaging.

Hierarchy

  • CommunicationManager

Implements

  • IDisposable

Index

Constructors

constructor

Accessors

options

  • Gets the communication manager's current effective communication options (read-only).

    remarks

    The effective options are based on the communication options specified in the configuration, augmented by local partial communication options specified in the start() method. So, effective options may change whenever this communication manager is restarted.

    Returns Readonly<CommunicationOptions>

runtime

Methods

createAssociatingRoute

  • createAssociatingRoute(ioSource: IoSource): string
  • Creates a new IO route for routing IO values of the given IO source to associated IO actors.

    This method is called by IO routers to associate IO sources with IO actors. An IO source publishes IO values on this route; an associated IO actor observes this route to receive these values.

    Parameters

    • ioSource: IoSource

      the IO source object

    Returns string

    an associating topic for routing IO values

getIoNodeByContext

  • getIoNodeByContext(contextName: string): Readonly<IoNode>
  • Gets the IO node for the given IO context name, as configured in the configuration common options.

    Returns undefined if no IO node is configured for the context name.

    Parameters

    • contextName: string

    Returns Readonly<IoNode>

observeAdvertiseWithCoreType

  • Observe Advertise events for the given core type.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    • coreType: CoreType

      core type of objects to be observed.

    Returns Observable<AdvertiseEvent>

    an observable emitting inbound Advertise events

observeAdvertiseWithObjectType

  • observeAdvertiseWithObjectType(objectType: string): Observable<AdvertiseEvent>
  • Observe Advertise events for the given object type.

    The given object type must be a non-empty string that does not contain the following characters: NULL (U+0000), # (U+0023), + (U+002B), / (U+002F).

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    throws

    if given objectType is not in a valid format

    Parameters

    • objectType: string

      object type of objects to be observed.

    Returns Observable<AdvertiseEvent>

    an observable emitting inbound Advertise events

observeCall

  • Observe Call events for the given operation and context object.

    The operation must be a non-empty string that does not contain the following characters: NULL (U+0000), # (U+0023), + (U+002B), / (U+002F).

    The given context object is matched against the context filter specified in inbound Call event data to determine whether the Call event should be emitted or skipped by the observable.

    A Call event is not emitted by the observable if:

    • context filter and context object are both specified and they do not match (checked by using ObjectMatcher.matchesFilter), or
    • context filter is not supplied and context object is specified.

    In all other cases, the Call event is emitted.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    remarks

    You can also invoke observeCall without context parameter and realize a custom matching logic with an RxJS filter operator.

    throws

    if given operation name is not in a valid format

    Parameters

    • operation: string

      the name of the operation to be invoked

    • Optional context: CoatyObject

      a context object to be matched against the Call event data's context filter (optional)

    Returns Observable<CallEvent>

    an observable emitting inbound Call events whose context filter matches the given context

observeChannel

  • Observe Channel events for the given channel identifier.

    The channel identifier must be a non-empty string that does not contain the following characters: NULL (U+0000), # (U+0023), + (U+002B), / (U+002F).

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    throws

    if given channelId is not in a valid format

    Parameters

    • channelId: string

      a channel identifier

    Returns Observable<ChannelEvent>

    an observable emitting inbound Channel events

observeCommunicationState

observeDeadvertise

  • Observe Deadvertise events.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Returns Observable<DeadvertiseEvent>

    an observable emitting inbound Deadvertise events

observeDiscover

  • Observe Discover events.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Returns Observable<DiscoverEvent>

    an observable emitting inbound Discover events

observeIoState

  • Observe IO state events for the given IO source or actor.

    When subscribed the subject immediately emits the current association state.

    Subscriptions to the returned subject are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    Returns BehaviorSubject<IoStateEvent>

    a subject emitting IO state events for the given IO source or actor

observeIoValue

  • observeIoValue(ioActor: IoActor): Observable<any>
  • Observe IO values for the given IO actor.

    Depending on the data format specification of the IO actor (IoActor.useRawIoValues), values emitted by the observable are either raw binary (Uint8Array, or Buffer in Node.js) or decoded as JSON objects.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    Returns Observable<any>

    an observable emitting inbound values for the IO actor

observeOperatingState

observeQuery

  • Observe Query events.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Returns Observable<QueryEvent>

    an observable emitting inbound Query events

observeRaw

  • observeRaw(topic: string, options?: {}): Observable<[string, Uint8Array]>
  • Observe matching inbound messages on a raw subscription topic.

    This method returns an observable that emits messages as tuples including the actual publication topic and the payload. Payload is represented as Uint8Array (or Buffer in Node.js, a subclass thereof) and needs to be decoded by the application. Use the toString method on a payload to convert the raw data to a UTF8 encoded string.

    Use this method to interoperate with external systems that publish messages on external topics. Use this method together with publishRaw() to transfer arbitrary binary data between Coaty agents.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    remarks

    To unobserve a given raw subscription topic, simply unsubscribe any subscriptions on the returned observable, either explicitely or implicitely (by using RX operators such as take or takeUntil).

    remarks

    Inbound non-raw Coaty events are not dispatched to raw observers.

    remarks

    The specified subscription topic must be in a valid, binding-specific format that corresponds with the configured communication binding.

    remarks

    Depending on the communication binding used, pattern-based subscription topics may include all wildcards in the topic string (e.g. MQTT) or may be specified in the subscription options (e.g. WAMP).

    Parameters

    • topic: string

      binding-specific subscription topic

    • Optional options: {}

      binding-specific subscription options (optional)

      • [key: string]: any

    Returns Observable<[string, Uint8Array]>

    an observable emitting any matching inbound messages as tuples containing the actual topic and the payload as Uint8Array (or Buffer in Node.js, a subclass thereof)

observeUpdateWithCoreType

  • Observe Update events for the given core type.

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    • coreType: CoreType

      core type of objects to be observed.

    Returns Observable<UpdateEvent>

    an observable emitting inbound Update events

observeUpdateWithObjectType

  • observeUpdateWithObjectType(objectType: string): Observable<UpdateEvent>
  • Observe Update events for the given object type.

    The given object type must be a non-empty string that does not contain the following characters: NULL (U+0000), # (U+0023), + (U+002B), / (U+002F).

    Subscriptions to the returned observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    throws

    if given objectType is not in a valid format

    Parameters

    • objectType: string

      object type of objects to be observed

    Returns Observable<UpdateEvent>

    an observable emitting inbound Update events

onDispose

  • onDispose(): void
  • Perform clean-up side effects, such as stopping the communication manager and deallocating resources.

    Returns void

publishAdvertise

publishAssociate

  • Called by an IO router to associate or disassociate an IO source with an IO actor.

    internal

    Used by framework internally. Do not call in application code.

    Parameters

    Returns void

publishCall

  • Publish a Call event to request execution of a remote operation and receive results.

    Note that the Call event is lazily published when the first observer subscribes to the observable.

    After all initial subscribers have unsubscribed no more response events will be emitted on the observable and an error will be emitted on resubscription.

    Subscriptions to the observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    • event: CallEvent

      the Call event to be published

    Returns Observable<ReturnEvent>

    an observable of associated Return events

publishChannel

publishDeadvertise

publishDiscover

  • Find discoverable objects and receive Resolve events for them.

    Note that the Discover event is lazily published when the first observer subscribes to the observable.

    After all initial subscribers have unsubscribed no more response events will be emitted on the observable and an error will be emitted on resubscription.

    Subscriptions to the observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    Returns Observable<ResolveEvent>

    an observable on which associated Resolve events are emitted

publishIoValue

  • publishIoValue(event: IoValueEvent): any
  • publishIoValue(ioSource: IoSource, value: any): any
  • Publish the given IoValue event.

    No publication is performed if the event's IO source is currently not associated with any IO actor.

    Parameters

    • event: IoValueEvent

      the IoValue event for publishing

    Returns any

  • deprecated

    since 2.1.0. Use publishIoValue(event: IoValueEvent) instead.

    Publish the given IO value sourced from the specified IO source.

    No publication is performed if the IO source is currently not associated with any IO actor.

    Parameters

    • ioSource: IoSource

      the IO source for publishing

    • value: any

      a JSON compatible or binary value to be published

    Returns any

publishQuery

  • Find queryable objects and receive Retrieve events for them.

    Note that the Query event is lazily published when the first observer subscribes to the observable.

    After all initial subscribers have unsubscribed no more response events will be emitted on the observable and an error will be emitted on resubscription.

    Subscriptions to the observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    • event: QueryEvent

      the Query event to be published

    Returns Observable<RetrieveEvent>

    an observable on which associated Retrieve events are emitted

publishRaw

  • publishRaw(event: RawEvent): void
  • publishRaw(topic: string, value: string | Uint8Array, shouldRetain?: boolean): void
  • Publish a raw payload on a given topic.

    Use this method to interoperate with external systems that subscribe on this topic. Use this method together with observeRaw() to transfer arbitrary binary data between Coaty agents.

    remarks

    The publication topic of the Raw event must be in a valid binding-specific format that corresponds with the configured communication binding. The Raw event is not published if the topic is invalid or has a Coaty-like shape.

    Parameters

    • event: RawEvent

      the Raw event for publishing

    Returns void

  • deprecated

    since 2.1.0. Use publishRaw(event: RawEvent) instead.

    Publish a raw payload on a given topic. Used to interoperate with external clients that subscribe on a matching topic.

    The topic is an MQTT publication topic, i.e. a non-empty string that must not contain the following characters: NULL (U+0000), # (U+0023), + (U+002B).

    Parameters

    • topic: string

      the topic on which to publish the given payload

    • value: string | Uint8Array

      a payload string or Uint8Array (or Buffer in Node.js, a subclass thereof) to be published on the given topic

    • Optional shouldRetain: boolean

      whether to publish a retained message (default false)

    Returns void

publishUpdate

  • Request or propose an update of the specified object and receive accomplishments.

    Note that the Update event is lazily published when the first observer subscribes to the observable.

    After all initial subscribers have unsubscribed no more response events will be emitted on the observable and an error will be emitted on resubscription.

    Subscriptions to the observable are automatically unsubscribed when the communication manager is stopped, in order to release system resources and to avoid memory leaks.

    Parameters

    Returns Observable<CompleteEvent>

    an observable of associated Complete events

restart

  • deprecated

    since 2.0.1. Use start(options?) instead.

    Restarts this communication manager using the given options.

    Useful if you want to re-establish communication after changing communication options on the fly.

    The given partial options are merged with the communication options specified in the container configuration. Partial options override configuration options.

    Note that further actions, like publishing or observing events, should only be taken after the returned promise resolves.

    Parameters

    • Optional options: Partial<CommunicationOptions>

      new communication options to be used for a restart (optional)

    Returns Promise<any>

    a promise that is resolved when restart has been completed.

start

  • Starts or restarts this communication manager joining the communication infrastructure with effective communication options specified in the configuration augmented by those in the optional options parameter.

    If no options are given, this operation does nothing if the communication manager is already in Started operating state; otherwise, i.e. in Stopped state, the communication manager is started with the communication options specified in the container configuration.

    If partial options are given, the communication manager is stopped if in Started operating state. Afterwards, it is started (again) with the given partial options merged with the communication options specified in the container configuration. Partial options override configuration options. This is useful if you want to re-establish communication after changing communication options on the fly.

    Note that further actions, like publishing or observing events, should only be taken after the returned promise resolves.

    Parameters

    • Optional options: Partial<CommunicationOptions>

      new communication options to be used for a (re)start (optional)

    Returns Promise<void>

    a promise that is resolved when start-up has been completed.

stop

  • stop(): Promise<void>
  • Stops dispatching and emitting communication events and unjoins from the communication infrastructure.

    To continue processing with this communication manager sometime later, invoke start(), but not before the returned promise resolves.

    Returns Promise<void>

    a promise that is resolved when communication manager has unjoined the communication infrastructure.

Generated using TypeDoc