Tags

, , ,

My friend Pritam and I have embarked on a small walk to chat-world. The objects are XMPP based Openfire, and Pidgin. Our objective is to create a XMPP based private chat server that we would later host on a private IP. We plan to develop a plugin for customized behavior of server towards a client.

Why XMPP?

Because it is widely used standard for message-oriented communication. XMPP wiki is here.

Why Openfire? Because it is popular, free and open.

Our first day

– Installing Openfire is simple and so is configuring, adding users, and going online. In your local network, it is advisable to turn-off firewall. Read more here about cryptic Openfire parameters.

– Installing Pidgin is simple. You should be able to connect to your local chat server in an hour.

– We wanted our server to interact with all users and we found “Message of the Day” plugin. This plugin is part of Openfire sources. Code is in Java. We played with the code of this plugin and enjoyed different behaviors.

– Building Openfire sources requires Apache ANT and JRE 1.5 or higher. You can find more details here.

After downloading the Openfire sources, you would find “plugin” directory that has sources for “Message of the Day”. We have to build it. A build for plugin is as following which builds all plugins:

xyz@localhost:~/Downloads/openfire/src/openfire_src/build> ~/apps/netbeans-6.9.1/java/ant/bin/ant plugins

– This run will build all plugins. Our plugin is created as “motd.jar”. Check if the “JAR” is created.

xyz@localhost:~/Downloads/openfire/src/openfire_src/build> ll ../target/openfire/plugins/motd.jar

– Now we have your plugin ready and we deploy it in our Openfire instance. Deployment is trivial. We have to copy the new JAR file to plugins directory of Openfire. It will automatically create the necessary directory structure for our plugin.

xyz@localhost:~/Downloads/openfire/src/openfire_src/build> cp ../target/openfire/plugins/motd.jar ~/Downloads/openfire/plugins/
xyz@localhost:~/Downloads/openfire/src/openfire_src/build> ll !$
ll ~/Downloads/openfire/plugins/
total 60
drwxr-xr-x 3 xyz users 4096 2011-10-02 03:22 admin
drwxr-xr-x 5 xyz users 4096 2012-05-06 20:16 motd
-rw-r--r-- 1 xyz users 12621 2012-05-06 20:28 motd.jar
xyz@localhost:~/Downloads/openfire/src/openfire_src/build> ll ~/Downloads/openfire/plugins/
total 60
drwxr-xr-x 3 xyz users 4096 2011-10-02 03:22 admin
drwxr-xr-x 5 xyz users 4096 2012-05-06 20:28 motd
-rw-r--r-- 1 xyz users 12621 2012-05-06 20:28 motd.jar

– We played with different type of messages that we can send to a newly joined client. Then we dissected the Session type, hostname and many other useful attributes including Packets, Messages. One example is that the message of the day now tells the user his name 😛

(8:30:27 PM) localhost: vishal@localhost/59b71259

This is the message from the Openfire server to a client as soon as the client creates a session.

– You should keep Openfire API handy with you.

– We have planned to do a few more experiments in coming weeks to understand:

  • How XMPP server processes client connections?
  • How to receive and send packet to a client?
  • Could it be possible to get a slimmer Openfire 😉
Advertisements