Instant Messaging with Arbitrary Content
In a desktop session, load a package that creates an instant messaging demo channel ("WIM") and start listening on it.
In[1]:=
Needs["DemoChannels`WIM`"]
Create your WIM channel and start listening on it.
In[2]:=
channel = CreateWIMChannel[]
Out[2]=
In[3]:=
listener = ChannelListen[channel]
Out[3]=
Send yourself a WIM, and notice your message in a new dialog notebook.
In[4]:=
ChannelSend["WIM", "Hi there."]
Out[4]=
Out[5]=
Attach the current notebook to a message.
In[6]:=
ChannelSend["WIM", {"Sending a notebook.", InputNotebook[]}]
Out[6]=
Out[7]=
Other users can send you a WIM by referencing your fully qualified channel.
In[8]:=
yourWIM = $WolframID <> ":WIM"
Out[8]=
In[9]:=
ChannelSend[yourWIM, "hello"]
Out[9]=
Or your WIM URL.
In[10]:=
listener["URL"]
Out[10]=
In[11]:=
listener["URL"];
ChannelSend[%, "another message"]
Out[11]=
Anyone can also send you a message from a web browser (or any other HTTP client) by making an HTTP request to the following URL.
In[12]:=
URLBuild[listener["URL"], {"operation" -> "send",
"Message" -> "yet another message"}]
Out[12]=
In[13]:=
URLBuild[listener["URL"], {"operation" -> "send",
"Message" -> "yet another message"}];
URLFetch[%]
Out[13]=
To reply to the incoming messages from other users, authorize communication on user channels.
In[14]:=
Unprotect[$AllowExternalChannelFunctions];
$AllowExternalChannelFunctions = True;
Stop listening and restore the security setting.
In[15]:=
RemoveChannelListener[listener]
Out[15]=
In[16]:=
$AllowExternalChannelFunctions = False;
Protect[$AllowExternalChannelFunctions];