Chatterl – Erlang based chat engineJanuary 1, 2009
Well I’ve been hacking around for the past few months trying to get my head around Erlang. After playing around with Twitterl I decided I should start a new project (OTP based) which I have a decent understanding of & have wanted to work on for some time. A chat system was the first thing that came to mind, I’ve worked on and built a few in my time and thought Erlang would be a good language to build a chat engine from scratch.
For those not interested in the long description and prefer to dive in source, you can find a copy of the project at github.
A chat system that can be housed over a number of nodes and track clients over varying devices, at the time of the writing the system works over multiple nodes and is able to do the basics (connect to a group, send message to other clients and connected groups).
The main focus of this project is to create a chat system that is highly reliable as well as scaleable. Other developers will be able to create add-on modules that are able to interact with chatterl and further enhance the functionality of chatterl and the chatterl clients experience.
As mentioned the system is OTP based, of which it uses Sinan to maintain its builds.
At the moment of this writing Chatterl is still in alpha so their is no real release at the moment, to get it running you will need to do the following:
git-clone git://github.com/baphled/chatterl.git && cd chatterl && sinan doc && sinan dist && cd _/build/development/tar && sudo faxien install-release chatterl-0.1.0.2.tar.gz
The above presumes that you have Sinan configured & installed, if you haven’t refer to erlware.
You will need to change to cookie & name values to something else, doing so should drop you into the erlang shell & ready to run the Chatterl application. To run a client on a different machine you will need to do the above if (making sure that the -sname is not the same as any other connected nodes & that the cookie is the same) if connecting on the same box simply cd to the ebin directory and run the following command:
erl -name bar -setcookie abc
From here you will need to make sure that they nodes can connect via:
Where foo is the node name & bar.net is the tld of the node box (indicated within yout hosts file or dns server).
Once you receive the infamous pong response you are ready to roll.
- Client login/logout to Chatterl.
- List Chatterl groups.
- List Chatterl users.
- Login/logout of a chatterl group.
- Send message to a group and other clients.
- Centralised Error logging and data storage.
- Client customisable routines (able to poll RSS feeds, twitter, FB and the such like).
- Better handling of errors.
- User registration.
- FB Connect.
- Chat bots (AIML based).
- Web interface/API.
- Chat modules handler(banning, censorship, chatbots).
Starting the server
Chatterl server runs as an OTP application and uses a supervisor to manage it (in later versions there will be options to spawn multiple servers, allowing for a more fault tolerant chat system). To start up the server you simply need to run the following command:
Which will initialise the server allowing clients to connect and groups to be created. Groups can be created on differing nodes as long as the node can communicate with the chatterl_serv.
Starting a group
Chatterl groups can be started on any node that can communicate with the server, this allows the user to create a number of groups on varying nodes, helping with general organisation as well a performance and reliablity.
A group can be initialised by calling the command:
which will spawn a group process which users can connect to.
Connection to chatterl
At the time of this writing chatterl_clients can only spawn a client per node, this will later be changed once the web interface has been fully implemented, possibly to a refactoring the client to a parameterised module.
For the moment node users must follow the basic OTP configurations (same cookie, valid DNS name, etc). Creating a connection to the server is done by using the following command.
This will initialise a user and connect them to chatterl_serv (must be done before users can join a group or communicate with other chatterl users).
Disconnecting from chatterl
Chatterl clients can simply disconnect from chatterl by issuing the following command:
This will disconnect the user from all the groups they are currently connected to as well as the actual Chatterl server.
Joining a group
This can be done by using the following command:
If the group exists the user is able to join the group allowing them to send message to the room.
Dropping from a group
This is as simple as connection, simply supply the following command:
This will send a message to the group, which will handle the termination.
Sending group message
GroupName being the name of the group the client is connected to, Message being the message that you want to send to the receiving client. If the message is sent successfully all users connected to the group will receive the message.
Sending a private message
This allows a Chatterl client to send a private message to another client, by executing the following:
If the message is sent successfully then the sender will receive follow message:
in turn sending the message to the receipients node.