May 13, 2013

Experiment with Websockets

Sermonis, an experimentation with Websockets

For the past week I did some experimentations with some interesting technologies, and at the end I had some kind of real time webchat application platform where users could create chat rooms (with or without passwords) and share URLs to friends so that they could join the discussion.

The Sermonis application was born. Its goal is to provide users an easy way to deploy a simple web application that let users talk with each other without the need to install an application like Skype.

Sermonis supports Markdown and password protected rooms. It‘s not aimed to grow bigger than that for the moment.

Get the code

The code is on Github [@agrison/sermonis][1] and you can already download it and build it.

First run

In order to test Sermonis on your local machine all you need is Java, Maven and mongoDB. If you want to test rapidly just type the following command:

Install a mongoDB on your machine, by downloading it [here][2], then open a shell and type the following to run it:

$ cd mongodb/bin
$ mkdir data
$ mongod --dbpath data

Download Sermonis and run it like this:

$ cd sermonis
$ mvn compile exec:java -Dexec.mainClass=me.grison.sermonis.SermonisInit jetty:run

During the execution of the command you will be asked for an administrator password. This very password will be stored in a file called sermonis.properties in an encrypted way (md5 hash of an AES password encrypted with a secret token generated previously).

Here is a sample of sermonis.properties file

#                                          _     
#    ________  _________ ___  ____  ____  (_)____
#   / ___/ _ \/ ___/ __ `__ \/ __ \/ __ \/ / ___/
#  (__  )  __/ /  / / / / / / /_/ / / / / (__  ) 
# /____/\___/_/  /_/ /_/ /_/\____/_/ /_/_/____/  
#                                               

# Sermonis property file generated on Mon May 13 10:11:44 CEST 2013

# Sermonis secret token used to encrypt password and browser request information into cookies
# to secure access to password protected room and admin interface
secretKey=0b388F1ab18EA5-7426E2-2e2C-8f1781683f-68Da1b1eA2C8-b5BD161Fb2f4140D06

# MD5 hash of the admin password AES encrypted with the above secret token
adminPassword=E591B207FA96239F368382E45BC55816

and a sample of the execution of the previous mvn command.

$ mvn compile exec:java -Dexec.mainClass=me.grison.sermonis.SermonisInit jetty:run
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building sermonis Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
                                              _     
        ________  _________ ___  ____  ____  (_)____
       / ___/ _ \/ ___/ __ `__ \/ __ \/ __ \/ / ___/
      (__  )  __/ /  / / / / / / /_/ / / / / (__  )
     /____/\___/_/  /_/ /_/ /_/\____/_/ /_/_/____/  


You're about to generate a secret key and admin password for sermonis.

Generating the secret key...
Please provide an admin password:
foobar
Updating sermonis.properties...
All done!
[INFO]
[INFO] >>> jetty-maven-plugin:8.1.0.v20120127:run (default-cli) @ sermonis >>>
[INFO] Configuring Jetty for project: sermonis Maven Webapp
...
[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 1 seconds.

Play with it

Just hit http://localhost:9001 and you will be redirected to a newly created room asking you for your username. Just share that same URL to someone else so that he can join you, and finally have some chat with your friend.

Project page

I‘ve set up a special page for Sermonis on my website at [grison.me/sermonis][3]

Enjoy :)

[1]: https://github.com/agrison/sermonis “” [2]: http://www.mongodb.org/downloads “” [3]: http://grison.me/sermonis “”

Alexandre Grison - //grison.me - @algrison