ChannelListener

ChannelListener[]

represents a channel listener created by ChannelListen.

Details

  • ChannelListener[]["prop"] gives the property prop of a channel listener.
  • ChannelListener[]["prop",n] gives a list of properties for the n most recently received messages.
  • ChannelListener[]["prop",All] gives a list of properties for all messages stored.
  • ChannelListener[][{"prop1","prop2",},] gives a list of results for the propi.
  • Possible properties related to individual messages include:
  • "Message"contents of the message
    "MetaInformation"metainformation accompanying the message
    "FullMessage"message and metainformation
    "MessageID"ID for the message
    "Timestamp"server timestamp for the message
    "RequesterWolframID"Wolfram ID of the sender
    "RequesterWolframUUID"Wolfram UUID of the sender
  • The contents of a message are given literally if the message is a string, Real, Integer, ByteArray, True, False, Null, Image or Image3D, or a list or association of such objects. All other messages are given either in the form HoldComplete[DisableFormatting[expr]] or as a list or association of delayed rules of the form "name"DisableFormatting[val].
  • For security reasons, you should exercise caution in accessing unevaluated message contents, such as parts of held expressions, right-hand sides of delayed rules, or applying ToExpression to string messages.
  • Possible properties related to sets of messages include:
  • "TimeSeries"association of time series of elements in messages
    "Dataset"dataset of elements in messages
  • Properties related to the channel listener and channel:
  • "ReceivedMessageCount"total number of messages received by the listener
    "AvailableMessageCount"number of messages currently stored by the listener (as limited by ChannelHistoryLength)
    "HandlerFunction"handler function applied to messages
    "Databin"databin (if any) associated with the channel
    "ChannelObject"the channel object being listened on
    "URL"the URL of the channel being listened on
  • Information of a ChannelListener may include the following properties:
  • "Status"status of the listener as a string
    "ChannelPath"path on the channel broker server of the channel being listened on
    "ChannelBase"base URL of channel broker server for the channel being listened on
    "ChannelObject"ChannelObject representing the channel being listened on
    "ChannelOwner"Wolfram ID of the user who owns the channel being listened on
    "ChannelProtocol"communication protocol used to connect to the channel being listened on
    "ReceivedMessageCount"total number of messages received by the listener
    "AvailableMessageCount"number of messages currently stored by the listener (as limited by ChannelHistoryLength)

Examples

open allclose all

Basic Examples  (1)

Create a ChannelListener object by starting to listen on a channel:

Send a message to the channel and retrieve it from the listener object:

Server timestamp for the message:

Send more messages:

Retrieve all messages:

Retrieve two latest messages:

Delete the channel, which removes the listener:

Scope  (8)

Last Message  (1)

The content of the last received message of a listener:

Metainformation:

Content with metainformation:

Several properties:

Delete the channel, which removes the listener:

Recent Messages  (3)

The number of received messages and their content:

All messages and timestamps:

The last two messages:

Delete the channel, which removes the listener:

Time series of a number of messages sent in the form of an association, with a delay between messages:

Plot the data:

A Dataset of received messages:

Clean up:

TimeSeries of raw data sent without a named key:

Clean up:

Atomic Messages  (1)

Messages consisting of certain atomic expressions, such as strings and numbers, are given verbatim:

Lists, rules and associations containing such atomic expressions are also given verbatim:

Clean up:

Symbolic Messages  (2)

Symbolic messages with immediately executable Wolfram Language code are kept unevaluated:

Formatting of unevaluated messages is also disabled:

Evaluate the message after examining its content:

Clean up:

Delayed rules in a message are given verbatim, as long as the left-hand side is a string, a number or one of a small set of atomic expressions like the symbols True, False or Null:

However, the formatting of right-hand sides of delayed rules is still disabled:

Evaluating the right-hand sides restores the normal formatting:

Clean up:

Listener & Channel Properties  (1)

The URL representing the channel on which the listener is listening:

The ChannelObject representing the channel on which the listener is listening:

The handler function of the listener:

Clean up:

Properties & Relations  (1)

Unevaluated parts of messages cached in ChannelListener are wrapped in DisableFormatting:

Evaluating held parts removes the wrapper:

Clean up:

Possible Issues  (1)

Non-string keys in left-hand sides of rules typically cause messages to be held unevaluated:

Resend the messages in a form that is safe to evaluate:

Now the messages are given literally:

Clean up:

Wolfram Research (2016), ChannelListener, Wolfram Language function, https://reference.wolfram.com/language/ref/ChannelListener.html.

Text

Wolfram Research (2016), ChannelListener, Wolfram Language function, https://reference.wolfram.com/language/ref/ChannelListener.html.

CMS

Wolfram Language. 2016. "ChannelListener." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ChannelListener.html.

APA

Wolfram Language. (2016). ChannelListener. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ChannelListener.html

BibTeX

@misc{reference.wolfram_2023_channellistener, author="Wolfram Research", title="{ChannelListener}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/ChannelListener.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_channellistener, organization={Wolfram Research}, title={ChannelListener}, year={2016}, url={https://reference.wolfram.com/language/ref/ChannelListener.html}, note=[Accessed: 19-March-2024 ]}