HXMPP is a haXe library for building XMPP/jabber based clients and components. [js,neko,flash,php,cpp]
git clone git://83.64.208.21/hxmpp.git
Below is the haXe source code of a simple jabber client which responds with a dumb "Hello" to every message.
class EchoRoboter {
static var stream : jabber.client.Stream;
static function main() {
var cnx = new jabber.SocketConnection( "localhost", 5222 );
var jid = new jabber.JID( "account@domain.net" );
stream = new jabber.client.Stream( jid, cnx );
stream.onOpen = function() {
var auth = new jabber.client.SASLAuth( stream, [cast new jabber.sasl.MD5Mechanism()] );
auth.onSuccess = function() {
new jabber.MessageListener( stream, handleMessage );
stream.sendPresence();
}
auth.authenticate( "mypassword", "HXMPP" );
}
stream.open();
}
static function handleMessage( m : xmpp.Message ) {
var response = new xmpp.Message( m.from, "Hello" );
stream.sendPacket( response );
}
}
Build the application:
haxe -neko echo.n -main EchoRoboter -cp ../hxmpp -D XMPP_DEBUG -D JABBER_DEBUG haxe -swf9 echo.swf -main EchoRoboter -cp ../hxmpp -D XMPP_DEBUG -D JABBER_DEBUG haxe -js echo.js -main EchoRoboter -cp ../hxmpp -D XMPP_DEBUG -D JABBER_DEBUG -D JABBER_SOCKETBRIDGE haxe -php . --php-front echo.php -main EchoRoboter -cp ../hxmpp -D XMPP_DEBUG -D JABBER_DEBUG
The XMPP_DEBUG flag is set to print the XMPP transfer for debugging.
The JABBER_DEBUG flag prints verbose debug messages and allows you to use local (invalid) domain names.
For the JS target the JABBER_SOCKETBRIDGE flag is required to use a (invisible) flash movie as bridge for the socket connection.
http://localhost/http/ to http://localhost:7070/http-bind/Activate the mod_proxy apache module if required.
sudo ln /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabledAdd following line to proxy.load to load the module.
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.soAdd the proxy directive to the host settings in your http.conf.
ProxyRequests Off ProxyPass /http http://localhost:7070/http-bind/ ProxyPassReverse /http http://localhost:7070/http-bind/Restart apache.
sudo /etc/init.d/apache2 restartRefer to the documentation of the HTTP connection manager of your jabber server.
Patches are always welcome, the process is simple:
git clone git://83.64.208.21/hxmpp.git cd hxmpp # edit file gid add [file] git commit -m "Description of what your patch does" git format-patch HEAD^