• message.js

  • ¶
    define(function () {
  • ¶

    Messages

    new Message(user, text, id, createdAt, done)

    Public: Represents an incoming message from the chat.

    user - A User instance that sent the message.

    text - A String message.

    id - A String of the message ID.

    createdAt - A String of the message creation date.

    done - Indicates that no other Listener should be called on this object. Default to false.

        Message = (function() {
            function Message(user, text, id, createdAt, done) {
                this.user = user;
                this.text = text;
                this.id = id;
                this.createdAt = createdAt;
                this.done = done != null ? done : false;
            }
  • ¶

    finish

    message.finish()

    Indicates that no other Listener should be called on this object.

    Returns nothing.

            Message.prototype.finish = function() {
                return this.done = true;
            };
  • ¶

    match

    message.match(regex)

    Determines if the message matches the given regex.

    regex - A regular expression to check.

    Returns a Match object or null.

            Message.prototype.match = function(regex) {
                return this.text.match(regex);
            }
    
            return Message;
        })();
        return Message;
    });