             @emitter.trigger 'chat.message', message
 
     newMessage : (event, message) =>
+        #Append a timestamp to the object
         message.time = do (new Date).getTime
+        #Push the object into the watched array
         @messages.push message
 
     me : (user, data) =>

    constructor     : (emitter) ->
        super emitter

        @markdown     = new Showdown.converter { extensions : ['voicious'] }
        @content = ($ '#textChat')
        @content.messages = @content.find '#chatContent > ul'
        @content.form = @content.find 'form'
        @content.form.textarea = @content.form.find 'textarea'

        @scrollPane   = @content.messages.jScrollPane horizontalDragMaxWidth : 0
        @scrollPane   = @content.messages.data 'jsp'

        @content.form.textarea.on 'keypress', (event) =>
            if event.keyCode is 13 and not event.shiftKey
                do event.preventDefault
                @content.form.trigger 'submit'

        @content.form.submit @submit

        (@messages = []).watch 'length', @update

        ($ window).resize () =>
            do @scrollPane.reinitialise

        @emitter.trigger 'cmd.register',
            name : 'me'
            callback : @me

        @emitter.on 'chat.message', @newMessage

        @emitter.on 'peer.create', (event, data) =>
            @emitter.trigger 'chat.message', { text : "#{data.name} arrives in the room." }
        @emitter.on 'peer.remove', (event, data) =>
            @emitter.trigger 'chat.message', { text : "#{data.name} leaves the room. (#{data.reason})" }

    submit : (event) =>
        do event.preventDefault
        message = (do @content.form.textarea.val).replace /\n/g, '<br />'
        @content.form.textarea.val ''
        # We check if it's a command or a message

            @sendCommand command
        else
            @sendMessage message
        #Do not send the form
        no

    # Update the text chat with a new message.
    update          : () =>
        #Empty the message list
        container = (do @scrollPane.getContentPane)
        do container.empty

        prevMessage = undefined
        #Loop through all messages
        @messages.map (message) =>
            #Humanize the timestamp
            formatedTime = (do (new Date message.time).toTimeString).substr 0, 5
            #Group message sent by a user
            if prevMessage? and prevMessage.message.from is message.from and message.time - prevMessage.message.time < 3000
                prevMessage.message = message
                (($ prevMessage.html[2]).find '.chatmessage').append message.text
            else
                html = undefined
                #If message.from is not defined, thew it is a server message
                if message.from?
                    html = """
                        <div class='chatmetadata'>
