HXMPP is a haXe library for building XMPP/jabber based clients and components. [js,neko,flash,php,cpp]

Source code.

Source code can be cloned from a git repository or browsed online.
git clone git://83.64.208.21/hxmpp.git

Documentation.

API documentation.
UML diagrams.

Usage.


Compiler flags.



A simple echo client.

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.



Using BOSH with apache.

BOSH essentially provides a "drop-in" alternative to a long-lived, bidirectional TCP connection using a request-response mechansim over HTTP. To use it you have to connect your client to the BOSH adress of your jabber server. Your webserver doesn’t know about your jabber server .. you have to setup a proxy to forward requests:
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-enabled
Add following line to proxy.load to load the module.
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
Add 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 restart
Refer to the documentation of the HTTP connection manager of your jabber server.

XEPs implemented.

XEPs marked with an asterisk are in a experimental state.
Checkout the latest source code for updates not listed here.

Related projects.

HXMPP.console, XMPP transfer debug console for browser targets.
HXMPP.test, libraries unit tests.

Contribute.

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^

License.

HXMPP is licensed under GNU Lesser General Public License v3.

Credits.

xmpp://tong@jabber.spektral.at
http://disktree.net