处理任何类型的数据
逐字给出以 JSON 格式(字符串、数字、True、False 或 Null)、列表、规则或包含这些元素的关联表示的消息.
In[1]:=

listener = ChannelListen["example"]
Out[1]=

In[2]:=

(ChannelSend["example", #]) & /@ {"string", 100, True, {1, 2, 3},
"a" -> "b", {"c" -> 1}, <|"d" -> True|>};
In[3]:=

listener["Message", All]
Out[3]=

包含消息的代码被安全封装在 HoldComplete,使你可以在运行之前进行检验.
In[4]:=

ChannelSend["example", Unevaluated[Print["hello"]]];
In[5]:=

listener["Message"]
Out[5]=

In[6]:=

listener["Message"] // ReleaseHold

创建一个发送压缩后的笔记本,然后在新窗口打开收到的笔记本的通道.
In[7]:=

CreateChannel["nb", ChannelPreSendFunction -> (Compress[#1] &),
HandlerFunctions ->
Association[
"MessageReceived" -> (CreateWindow[Uncompress[#Message]] &)]]
Out[7]=

开始在信道侦听.
In[8]:=

listener = ChannelListen["nb"]
Out[8]=

创建一个笔记本并将其发送至信道.
In[9]:=

nb = DocumentNotebook[{TextCell["My Report", "Section"],
TextCell["Lorem ipsum dolor sit amet:", "Text"],
ExpressionCell[
ContourPlot[x + Sin[x^2 + y^2], {x, -4, 4}, {y, -4, 4},
Contours -> 9, ContourShading -> ColorData[35, "ColorList"]]]},
StyleDefinitions -> FrontEnd`FileName[{"Article"}, "Preprint.nb"],
WindowTitle -> "My Report", Background -> LightOrange]
Out[9]=

In[10]:=

ChannelSend["nb", nb]
Out[10]=

收到的笔记本.
Out[11]=
