Class Message



    Purpose

    Messages are used for communication between a client and the server. Each kind of message is used to represent a certain kind of information. And the class Message is the super class of all those messages.

    Functionality

    Different type of messages have different variables recording the certain information needed for that type of message. But when sending a message, the message should be first transfered to a string and then sent out.

    All the message strings have the similar format. A message string starts with an integer identifying the type of the message, followed by a type seperater symbol "@", then comes several pieces of information each seperated by a certain seperate symbol "&" and ends with the symbol "#" to indicate the end of the message string.

    When a server (or a client) wants to send a message, it should first transfer the message to a string of the format discussed above. And when a server (or a client) receives a message, it can easily parse the string according to the format and get the certain information in the message and take the corresponding action.

    Structure

    All the messages have two constructors and one method: toString().

    Constructors:One of the constructors gets the value of the message from the input parameters while the other builds the message by parsing the input string.

    toString(): This method is used to convert the message to a string format. This string can either be stored in a file or sent to a socket. It can be converted back by using the second constructor mentioned above.

    Many type of messages also have a method Action(). This method specifys what to do when a server (or a client) get this type of message.

    Extension



    See also

    MsgMazeObject
    MsgBlock
    MsgRoom
    MsgDoor
    MsgItem
    MsgPlayer
    MsgMoveReq
    MsgMoveAck
    MsgPlayerUpdate
    MsgItemTake
    MsgItemDrop
    MsgTakeReq
    MsgTakeAck
    MsgTalkToReq
    MsgTalkFromReq
    MsgTalkToAck
    MsgTalkFromAck
    MsgMapReq
    MsgLeave
    MsgNewPlayer
    MsgFirstPlayer
    MsgOtherPlayer
    MsgSimplayer
    MsgQuitPlayer




    [Go to Class Index Table] [Go back to Program Architecture Diagram]
    [Source Code of Message.java]