represents a channel listener created by ChannelListen.
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 all close allBasic Examples (1)
Create a ChannelListener object by starting to listen on a channel:
CreateChannel["example"];
listener = ChannelListen["example"]Send a message to the channel and retrieve it from the listener object:
ChannelSend["example", "hello"]listener["Message"]Server timestamp for the message:
listener["Timestamp"]ChannelSend["example", "there"];
ChannelSend["example", "world"];listener["Message", All]listener["Message", 2]Delete the channel, which removes the listener:
DeleteChannel["example"];Scope (8)
Last Message (1)
The content of the last received message of a listener:
CreateChannel["example"];
listener = ChannelListen["example"]ChannelSend["example", "message"]listener["Message"]listener["MetaInformation"]listener["FullMessage"]listener[{"Timestamp", "Message"}]Delete the channel, which removes the listener:
DeleteChannel["example"];Recent Messages (3)
The number of received messages and their content:
CreateChannel["example"];
listener = ChannelListen["example"]Scan[ChannelSend["example", #]&, {1, 2, 3}]listener["ReceivedMessageCount"]listener["Message", All]listener[{"Message", "Timestamp"}, All]listener["Message", 2]Delete the channel, which removes the listener:
DeleteChannel["example"];Time series of a number of messages sent in the form of an association, with a delay between messages:
CreateChannel["example"];
listener = ChannelListen["example"]ChannelSend["example", #]& /@ Table[<|"sin" -> Sin[x], "cos" -> Cos[x]|>, {x, 0, Pi, .2}];listener["TimeSeries"]DateListPlot[%]A Dataset of received messages:
listener["Dataset"]DeleteChannel["example"];TimeSeries of raw data sent without a named key:
CreateChannel["example"];
listener = ChannelListen["example"]ChannelSend["example", #]& /@ RandomReal[{0, 1}, 5];listener["TimeSeries"]DeleteChannel["example"];Atomic Messages (1)
Messages consisting of certain atomic expressions, such as strings and numbers, are given verbatim:
CreateChannel["example"];
listener = ChannelListen["example"]Scan[ChannelSend["example", #]&, {"string", 100, True}]listener["Message", All]Lists, rules and associations containing such atomic expressions are also given verbatim:
Scan[ChannelSend["example", #]&, {{1, 2, 3}, "a" -> "b", {"c" -> 1}, <|"d" -> True|>}]listener["Message", All]DeleteChannel["example"];Symbolic Messages (2)
Symbolic messages with immediately executable Wolfram Language code are kept unevaluated:
CreateChannel["example"];
listener = ChannelListen["example"]ChannelSend["example", Unevaluated[Print["hello"]]]listener["Message"]Formatting of unevaluated messages is also disabled:
%//InputFormEvaluate the message after examining its content:
ReleaseHold[%]DeleteChannel["example"];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:
CreateChannel["example"];
listener = ChannelListen["example"]ChannelSend["example", <|"a" :> 1 + 1, 2 :> Sin[x ^ 2], True :> Print[1]|>]listener["Message"]However, the formatting of right-hand sides of delayed rules is still disabled:
%//InputFormEvaluating the right-hand sides restores the normal formatting:
2 /. %DeleteChannel["example"];Listener & Channel Properties (1)
The URL representing the channel on which the listener is listening:
CreateChannel["example"];
listener = ChannelListen["example", Print]listener["URL"]The ChannelObject representing the channel on which the listener is listening:
listener["ChannelObject"]The handler function of the listener:
listener["HandlerFunction"]DeleteChannel["example"];Properties & Relations (1)
Unevaluated parts of messages cached in ChannelListener are wrapped in DisableFormatting:
CreateChannel["example"];
listener = ChannelListen["example"]ChannelSend["example", Unevaluated[Print["hello"]]];ChannelSend["example", "x" :> Print["again"]];listener["Message", All]%//InputFormEvaluating held parts removes the wrapper:
{ReleaseHold[%[[1]]], "x" /. %[[2]]}DeleteChannel["example"];Possible Issues (1)
Non-string keys in left-hand sides of rules typically cause messages to be held unevaluated:
CreateChannel["example"];
listener = ChannelListen["example"]Scan[ChannelSend["example", #]&, {a -> 1, <|b -> 2|>}]listener["Message", All]Resend the messages in a form that is safe to evaluate:
Scan[ChannelSend["example", #]&, {"a" -> 1, <|"b" -> 2|>}]Now the messages are given literally:
listener["Message", 2]DeleteChannel["example"];Related Guides
History
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_2026_channellistener, author="Wolfram Research", title="{ChannelListener}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/ChannelListener.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_channellistener, organization={Wolfram Research}, title={ChannelListener}, year={2016}, url={https://reference.wolfram.com/language/ref/ChannelListener.html}, note=[Accessed: 13-June-2026]}