The creation of the Session data structure is the bulk of the code. xmerl:export_simple and ssl:send pretty much take care of all the rest.
A small utility function named export_text exports just the text nodes from an XHTML data structure, which is sent as a fallback to non-XHTML-IM aware clients. Of course, xmerl supports more patterns, but for the moment, this is enough for my purposes.
Longer term, this needs to be split up into a module which spawns threads and exports separate interfaces for things like authenticating, sending messages to a server, and registering callbacks for presence changes.
Sam Ruby: XHTML-IM over TLS via Erlang
jabberdemo.erl constructs and sends an XHTML-IM message over TLS using xmlerl and Erlang. Tested with gaim and ejabberd....
Unforunately it just hangs for me, in ssl:connect, but I probably deserve it for attempting to run it under Windows. I’ll have to either stop doing that or try and debug my Erlang->OpenSSL setup.
Thanks for that suggestion, but I just got it working in secure mode anyway. I was trying to use port 5222, but it seems that a secure connection on 5222 requires TLS handshaking, while 5223 is non-handshaked. I opened up 5223 on the server’s firewall and switched the code back to that and it’s now working nicely.
I was under the impression that using 5223 was a bit non-standard/old-fashioned, but a brief Google around leads me to believe that getting TLS and Erlang to play nicely is not totally straightforward (e.g. here: [link]) , so I will stick with my working setup for now - I’m only experimenting with things at the moment anyway.
Thanks again. Consider it tested with Openfire on the server, and Smack, Pidgin and Jabber.NET (C# library) at the receiving end. All working.
By the way (and I don’t know if you find this irritating or not, so I won’t do it again unless you say otherwise).... s/xmlerl/xmerl/ and s/ulitity/utility/
A simple program for parsing memes.atom. Below is an annotated version. -module(memes). -export([scan/0]). -include_lib("xmerl/include/xmerl.hrl"). Define a module named memes that exports a single function named...
[more]
Previous status: I’ve shown Erlang code that sends a Jabber message. I’ve shown Erlang code that parses a planet Venus generated Mememes feed. Now, lets consider the problem of sending notifications for new items. Typically...
[more]
For part 3 of this ‘exciting’ series, I’m adding Jabberlang onto the existing setup to provide easy access to two-way XMPP messaging. If I was just sending, I would have restricted myself to tinkering with the code that Sam Ruby...
Asisto con una mezcla de envidia y escepticismo a la conversión a Erlang de Sam Ruby . Sam Ruby es un típico goleor tecnológico ™ Siempre está a la última en cuanto a estándares y lenguajes sobre la web. De hecho, algunos los hace él :) Como...
For part 3 of this ‘exciting’ series, I’m adding Jabberlang onto the existing setup to provide easy access to two-way XMPP messaging. If I was just sending, I would have restricted myself to tinkering with the code that Sam Ruby...