({{, (RefLink[ChannelObject, paclet:ref/ChannelObject])[]
gives a new anonymous channel specification.}, {, (RefLink[CloudObject, paclet:ref/CloudObject])["http:// …"]
represents a channel specified by a given URI.}, {, (RefLink[ChannelObject, paclet:ref/ChannelObject])["relpath"] 
represents a channel for the currently authenticated user at a relative path.}, {, (RefLink[ChannelObject, paclet:ref/ChannelObject])["id"]
represents the home channel of the user with Wolfram ID id. }, {, (RefLink[ChannelObject, paclet:ref/ChannelObject])["id:path"]
represents a channel for the user with the specified ID at the given path.}, {, (RefLink[ChannelObject, paclet:ref/ChannelObject])["/abspath"] 
represents a channel at an absolute path on the channel broker.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ChannelObject, paclet:ref/ChannelObject]) does not create a channel but merely provides an object that can be used to refer to a channel. (RefLink[CreateChannel, paclet:ref/CreateChannel]) actually creates channels.

New anonymous channel objects are created for the channel broker specified by (RefLink[$ChannelBase, paclet:ref/$ChannelBase]).

In (RefLink[ChannelObject, paclet:ref/ChannelObject])["id"], the id is typically an email address.

(RefLink[ChannelObject, paclet:ref/ChannelObject])[(RefLink[CloudObject, paclet:ref/CloudObject])[…]] returns the associated channel object of a cloud object that represents a deployed (RefLink[ChannelReceiverFunction, paclet:ref/ChannelReceiverFunction]).

(RefLink[ChannelObject, paclet:ref/ChannelObject]) allows the following options:

A handler function for received messages can be given in the form (RefLink[HandlerFunctions, paclet:ref/HandlerFunctions])-><|"MessageReceived":>func|>. func is applied to the association containing elements specified for (RefLink[ChannelListen, paclet:ref/ChannelListen]).

(RefLink[Options, paclet:ref/Options])[(RefLink[ChannelObject, paclet:ref/ChannelObject])[…],…] gives the current options of a previously created (RefLink[ChannelObject, paclet:ref/ChannelObject]). (RefLink[SetOptions, paclet:ref/SetOptions]) can be used to reset them.

A list or association of channel object options can contain delayed rules of the form opt:>(RefLink[DisableFormatting, paclet:ref/DisableFormatting])[val].

OpenersPrimaryExamplesSection(Spacer1)Examples  (22)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

A new anonymous channel:

ChannelObject[]

A named channel of the currently authenticated user:

ChannelObject["x"]

OpenersExampleSection1(Spacer1)Scope  (10)

A new unnamed channel:

ChannelObject[]

A channel in the home area of the currently authenticated user:

ChannelObject["name"]

A named channel in a subdirectory of the home area:

ChannelObject["x/y"]

The home channel of the currently authenticated user:

ChannelObject[$WolframID]

The home channel of another user:

ChannelObject["another-user@sample.com"]

A named channel of another user:

ChannelObject["another-user@sample.com:name"]

A channel referred to by the absolute path on the channel broker server:

ChannelObject["/users/user@sample.com/name"]

A channel referred to by the URL:

ChannelObject["https://channelbroker.wolframcloud.com:443/users/user@sample.com/name"]

A channel associated with a cloud object deployed for a channel receiver:

CloudDeploy[ChannelReceiverFunction[#&]]

ChannelObject[%]

A channel with options:

ChannelObject["x",HandlerFunctions-><|"MessageReceived"->Print|>,ChannelPreSendFunction->(Compress[#]&)]

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection0(Spacer1)HandlerFunctions  (1)

Create a channel with a custom message handler:

channel=ChannelObject["speak",HandlerFunctions-><|"MessageReceived"->(Speak["Arrived "<>#Message]&)|>]

CreateChannel[%]

Start listening on the channel:

listener=ChannelListen[channel]

The custom handler function is executed when a message arrives:

ChannelSend[channel,"hello"]

OpenersExampleSubsection1(Spacer1)Permissions  (2)

Create a public channel:

channel=ChannelObject["x",Permissions->"Public"]

CreateChannel[%]

Start listening on the channel and send some data:

listener=ChannelListen[channel]

ChannelSend[channel,"hello"]

The received message:

listener["Message"]

Other users can send data to your channel by referring to your (RefLink[$WolframID, paclet:ref/$WolframID]):

$WolframID<>":x"

ChannelSend[%,"hello again"]

A channel to which you can listen and everyone can send messages:

ChannelObject["x",Permissions-><|"All"->"Write","Owner"->{"Read","Execute"}|>]

OpenersExampleSection3(Spacer1)Properties & Relations  (6)

(RefLink[ChannelObject, paclet:ref/ChannelObject]) creates a reference to the channel without creating a channel on the server:

obj=ChannelObject["x"]

Check that the channel does not exist:

Options[%]

Create a channel and verify that it exists on the server:

CreateChannel[obj]

Options[%]

Delete the channel from the server:

DeleteChannel[obj]

(RefLink[CreateChannel, paclet:ref/CreateChannel]) returns a (RefLink[ChannelObject, paclet:ref/ChannelObject]):

obj=CreateChannel[]

(RefLink[ChannelObject, paclet:ref/ChannelObject]) is used by (RefLink[ChannelListen, paclet:ref/ChannelListen]), (RefLink[ChannelSend, paclet:ref/ChannelSend]), and other functions:

obj=CreateChannel["x"]

listener=ChannelListen[%]

ChannelSend[%%,"hello"]

DeleteChannel["x"]

You can listen on the URL associated with the channel object, even if the channel does not exist on the server:

obj=ChannelObject["x"]

Options[obj]

listener=ChannelListen[obj]

Since there was no channel, and no handler function given to (RefLink[ChannelListen, paclet:ref/ChannelListen]), there is no handler for the listener:

listener["HandlerFunction"]

You can still use the channel normally:

ChannelSend[obj,"hello"]

listener["Message"]

(RefLink[ChannelObject, paclet:ref/ChannelObject]) can be retrieved from the (RefLink[ChannelListener, paclet:ref/ChannelListener]) object:

ChannelListen["x"]

%["ChannelObject"]

When retrieved from the server, custom handlers can be wrapped in (RefLink[DisableFormatting, paclet:ref/DisableFormatting]):

channel=ChannelObject["f",HandlerFunctions-><|"MessageReceived"->(Speak[Uncompress[#Message]]&)|>,ChannelPreSendFunction->(Compress[#]&)]//CreateChannel

Options[channel,{HandlerFunctions,ChannelPreSendFunction}]

%//InputForm

OpenersExampleSection4(Spacer1)Possible Issues  (1)

An email address is interpreted as a home channel of the user:

ChannelObject["foo@bar.com"]

Use a fully qualified name to refer to a channel whose name looks like an email address:

ChannelObject["user@sample.com:foo@bar.com"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[CreateChannel, paclet:ref/CreateChannel])  ▪  (RefLink[FindChannels, paclet:ref/FindChannels])  ▪  (RefLink[DeleteChannel, paclet:ref/DeleteChannel])  ▪  (RefLink[Options, paclet:ref/Options])  ▪  (RefLink[SetOptions, paclet:ref/SetOptions])  ▪  (RefLink[ChannelReceiverFunction, paclet:ref/ChannelReceiverFunction])  ▪  (RefLink[ChannelListener, paclet:ref/ChannelListener])  ▪  (RefLink[CloudObject, paclet:ref/CloudObject])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Channel-Based Communication, paclet:guide/Channel-BasedCommunication])}})}})