"""
@var TYPE_SYN: An initial SYN message, sent by the client
@var TYPE_SYNACK: A SYN acknowledgement message, sent by the server
@var TYPE_SYNRETRY: Indicates the server could not open the requested file
@var TYPE_SYNACKACK: A SYNACK acknowledgement message, sent by the client
@var TYPE_DATA: A mesage containing data, sent by the server
@var TYPE_ACK: A mesage acknowledging data, sent by the client
@var TYPE_FIN: Indicates there is no more data, sent by the server
@var TYPE_FINACK: A message acknowledging a FIN, closes the connection,
                  sent by the client
"""

# message types
TYPE_SYN=0
TYPE_SYNACK=1
TYPE_SYNRETRY=2
TYPE_SYNACKACK=3
TYPE_DATA=4
TYPE_ACK=5
TYPE_FIN=6
TYPE_FINACK=7

class ReliableMessage:
    """Messages sent over the wire by the 6.829 transfer protocol

    @ivar type: Message type (e.g., TYPE_SYN, TYPE_DATA, etc.)
    @ivar seqno: Message sequence number
    @ivar data: Data payload (arbitrary string)
    @ivar timestamp: The UTC time in seconds when this message was created

    """

    def __init__( self, type, seqno=0, timestamp=0, data="" ):
        """
        Initialize data members of a ReliableMessage.

        @param type: What kind of message is this? (e.g., TYPE_SYN, TYPE_DATA,
                     etc.)
        @param seqno: Sequence number identifier for this message (default: 0)
        @param timestamp: What time was this message created?  You should
                          call this with time() in most cases. (default: 0)
        @param data: The data payload to pass across the network (default: "")
        """
        self.type = type
        self.seqno = seqno
        self.data = data
        self.timestamp = timestamp

