Messagerie instantanée avec un contenu arbitraire
Dans une session sur le bureau, chargez un progiciel qui crée une démonstration de messagerie instantanée (« WIM ») et commencez à l'écouter.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_34.png)
Needs["DemoChannels`WIM`"]
Créez votre canal WIM et commencez à l'écouter.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_35.png)
channel = CreateWIMChannel[]
![](assets.fr/instant-messaging-with-arbitrary-content/O_38.png)
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_36.png)
listener = ChannelListen[channel]
![](assets.fr/instant-messaging-with-arbitrary-content/O_39.png)
Envoyez-vous un WIM et regardez votre message dans un nouveau notebook de dialogue.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_37.png)
ChannelSend["WIM", "Hi there."]
![](assets.fr/instant-messaging-with-arbitrary-content/O_40.png)
![](assets.fr/instant-messaging-with-arbitrary-content/O_41.png)
Attachez le notebook en cours à un message.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_38.png)
ChannelSend["WIM", {"Sending a notebook.", InputNotebook[]}]
![](assets.fr/instant-messaging-with-arbitrary-content/O_42.png)
![](assets.fr/instant-messaging-with-arbitrary-content/O_43.png)
Les autres utilisateurs peuvent vous envoyer un WIM en référençant votre chaîne pleinement qualifiée.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_39.png)
yourWIM = $WolframID <> ":WIM"
![](assets.fr/instant-messaging-with-arbitrary-content/O_44.png)
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_40.png)
ChannelSend[yourWIM, "hello"]
![](assets.fr/instant-messaging-with-arbitrary-content/O_45.png)
Ou votre URL de WIM.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_41.png)
listener["URL"]
![](assets.fr/instant-messaging-with-arbitrary-content/O_46.png)
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_42.png)
listener["URL"];
ChannelSend[%, "another message"]
![](assets.fr/instant-messaging-with-arbitrary-content/O_47.png)
Tout le monde peut également vous envoyer un message à partir d'un navigateur Web (ou tout autre client HTTP) en faisant une requête HTTP à l'URL suivante.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_43.png)
URLBuild[listener["URL"], {"operation" -> "send",
"Message" -> "yet another message"}]
![](assets.fr/instant-messaging-with-arbitrary-content/O_48.png)
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_44.png)
URLBuild[listener["URL"], {"operation" -> "send",
"Message" -> "yet another message"}];
URLFetch[%]
![](assets.fr/instant-messaging-with-arbitrary-content/O_49.png)
Pour répondre aux messages entrants provenant d'autres utilisateurs, autorisez la communication sur les canaux de l'utilisateur.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_45.png)
Unprotect[$AllowExternalChannelFunctions];
$AllowExternalChannelFunctions = True;
Arrêtez d'écouter et restaurez les paramètres de sécurité.
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_46.png)
RemoveChannelListener[listener]
![](assets.fr/instant-messaging-with-arbitrary-content/O_50.png)
![Click for copyable input](assets.fr/instant-messaging-with-arbitrary-content/In_47.png)
$AllowExternalChannelFunctions = False;
Protect[$AllowExternalChannelFunctions];