Server ~ ChatInterface - UofM-COMP4350-4/NBGI GitHub Wiki

Draft 1

Interprets and sends raw Socket.IO data for client side chat, managing each individual chatroom instance; directing chat messages to proper chatrooms, and allowing for server intervention.

##Socket.IO Emits Event name: "chat"

Sends a text chat message to the client.

  • Event data:
{
    instanceID:0, // {Number} - Instance ID for the match chatroom
    text:"" // {String} - Chat message text
    userName:"" // {String} - Chat message sender's user name
}

##Socket.IO Receives Event name: "chat"

Receives a text chat message from the client.

  • Event data:
{
    instanceID:0, // {Number} - Instance ID for the match chatroom
    text:"" // {String} - Chat message text
}

##Component API announcement(instance, text)

  • instance {Number} - Instance ID for the match chatroom
  • text {String} - Chat message text

scanner(fn)

  • fn {Function(instance, userID, text)} - A function that can scan each chat room's messages as they arrive

    • instance {Number} - Instance ID for the match chatroom
    • userID {Number} - User ID who is sending the message
    • text {String} - Chat message text
    • Function can optionally return:
      • {Boolean} - Returns true if the message should not be forwarded to the chatroom (filtered out)

logFetcher(fn)

  • fn {Function(instance)} - A function that will retrieve and return the chat log for a chatroom

    • instance {Number} - Instance ID for the match chatroom
    • Function should return:
      • {Object} - Chatroom log data, in the following format:
{
    instance:0, // {Number} - Instance ID for the match chatroom
    log:[ // {Array} - Ordered list of message entries
        {
            userID:0, // {Number} - User ID who is sending the message
            userName:"", // {String} - Displayable username for who is sending the message
            text:"", // {String} - Chat message text
            timestample:0 // {Number} - Numeric timestamp of the message
        },
        ... // Rest of the chat message entries in the log
    ]
}