@haxall/haxall
    Preparing search index...

    Class MqttClient

    MQTT Client (Asynchronous)

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Client configuration

      Returns ClientConfig

    • Open a connection to the server using the given configuration.

      Returns a future that will be completed:

      1. when the CONNACK is received
      2. with an error if the connect times out

      Parameters

      Returns Future

    • Disconnect from the server.

      Returns a future that will be completed after the DISCONNECT message is actually sent to the server.

      Returns Future

    • Configure the client to auto-reconnect and return this

      Parameters

      Returns this

    • Compare this object to the specified for equality. This method may be accessed via the == and != shortcut operators. If not overridden the default implementation compares for reference equality using the === operator. If this method is overridden, then hash() must also be overridden such that any two objects which return true for equals() must return the same value for hash(). This method must accept null and return false.

      Parameters

      Returns boolean

    • Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.

      Returns number

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Is the client terminated

      Returns boolean

    • Client log

      Returns Log

    • The pool used to control execution of this actor.

      Returns ActorPool

    • Publish a message to the given topic. See publishWith to use a "fluent" API for publishing.

      Returns a future that will be completed when the message is confirmed to be received by the server accoring to the specified QoS.

      Parameters

      Returns Future

    • Get a publish builder to configure and send your request

      Returns PubSend

    • Asynchronously send a message to this actor for processing. If msg is not immutable, then NotImmutableErr is thrown. Throw Err if this actor's pool has been stopped. Return a future which may be used to obtain the result once it the actor has processed the message. If the message is coalesced then this method returns the original message's future reference. Also see sendLater and sendWhenComplete.

      Parameters

      Returns Future

    • Schedule a message for delivery after the specified period of duration has elapsed. Once the period has elapsed the message is appended to the end of this actor's queue. Accuracy of scheduling is dependent on thread coordination and pending messages in the queue. Scheduled messages are not guaranteed to be processed if the actor's pool is stopped. Scheduled messages are never coalesced. Also see send and sendWhenComplete.

      Parameters

      Returns Future

    • Schedule a message for delivery after the given future has completed. Completion may be due to the future returning a result, throwing an exception, or cancellation. Send-when-complete messages are never coalesced. The given future must be an actor based future. Also see send and sendLater.

      Parameters

      Returns Future

    • The current connection state

      Returns ClientState

    • Subscribe to the given topic filter. You are responsible for setting the option flags correctly. See subscribeWith to use a "fluent" API for subscribing.

      Return a future that will be completed when the SUBACK is received.

      Parameters

      Returns Future

    • Get a subscription builder to configure and send your request.

      Returns SubSend

    • Disconnect and terminate all resources used by the client. After this method is called the client can no longer be used. When you are done with the client it is strongly recommended to call this method to clean up all resources.

      Returns this

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Return a string representation of this object.

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • Unsubscribe from the given topic filter.

      Returns a future that will be completed when the UNSUBACK is received.

      Parameters

      • topicFilter: string

      Returns Future

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Return the map of "global" variables visibile only to the current actor (similar to how thread locals work in Java). These variables are keyed by a string name - by convention use a dotted notation beginning with your pod name to avoid naming collisions.

      Returns Map<string, JsObj>

    • Create an actor whose execution is controlled by the given ActorPool. If receive is non-null, then it is used to process messages sent to this actor. If receive is specified then it must be an immutable function (it cannot capture state from the calling thread), otherwise NotImmutableErr is thrown. If receive is null, then you must subclass Actor and override the receive method.

      Parameters

      Returns MqttClient

    • Create an actor with a coalescing message loop. This constructor follows the same semantics as make, but has the ability to coalesce the messages pending in the thread's message queue. Coalesced messages are merged into a single pending message with a shared Future.

      The toKey function is used to derive a key for each message, or if null then the message itself is used as the key. If the toKey function returns null, then the message is not considered for coalescing. Internally messages are indexed by key for efficient coalescing.

      If an incoming message has the same key as a pending message in the queue, then the coalesce function is called to coalesce the messages into a new merged message. If coalesce function itself is null, then we use the incoming message (last one wins). The coalesced message occupies the same position in the queue as the original and reuses the original message's Future instance.

      Both the toKey and coalesce functions are called while holding an internal lock on the queue. So the functions must be efficient and never attempt to interact with other actors.

      Parameters

      Returns Actor

    • Put the currently executing actor thread to sleep for the specified period. If the thread is interrupted for any reason while sleeping, then InterruptedErr is thrown.

      Parameters

      Returns void