# Path: src/lifeRaft/messages/base.py
# class BaseMessage(object):
#     AppendEntries = 0
#     RequestVote = 1
#     RequestVoteResponse = 2
#     Response = 3
# 
#     def __init__(self, sender, receiver, term, data):
#         self._timestamp = int(time.time())
# 
#         self._sender = sender
#         self._receiver = receiver
#         self._data = data
#         self._term = term
# 
#     @property
#     def receiver(self):
#         return self._receiver
# 
#     @property
#     def sender(self):
#         return self._sender
# 
#     @property
#     def data(self):
#         return self._data
# 
#     @property
#     def timestamp(self):
#         return self._timestamp
# 
#     @property
#     def term(self):
#         return self._term
# 
#     @property
#     def type(self):
#         return self._type
# 
# Path: src/lifeRaft/messages/response.py
# class ResponseMessage(BaseMessage):
# 
#     _type = BaseMessage.Response
# 
#     def __init__(self, sender, receiver, term, data):
#         BaseMessage.__init__(self, sender, receiver, term, data)


import random
from ..messages.base import BaseMessage
from ..messages.response import ResponseMessage
            from .follower import Follower
        self._timeout = timeout

    def set_server(self, server):
        self._server = server

    def on_message(self, message):
        """This method is called when a message is received,
        and calls one of the other corrosponding methods
        that this state reacts to.

        """
        _type = message.type
        # Convert to follower if heigher term received
        if(message.term > self._server._currentTerm):
            self._server._currentTerm = message.term
            if not issubclass(type(self), Follower):
                follower = Follower(timeout=self._timeout)
                follower.set_server(self._server)
                return follower.on_message(message)

        # Is the messages.term < ours? If so we need to tell
        #   them this so they don't get left behind.
        elif(message.term < self._server._currentTerm):
            self._send_response_message(message, yes=False)
            return self, None

        if(_type == BaseMessage.AppendEntries):
            return self.on_append_entries(message)
        elif(_type == BaseMessage.RequestVote):
            return self.on_vote_request(message)

# Path: src/lifeRaft/messages/base.py
# class BaseMessage(object):
#     AppendEntries = 0
#     RequestVote = 1
#     RequestVoteResponse = 2
#     Response = 3
# 
#     def __init__(self, sender, receiver, term, data):
#         self._timestamp = int(time.time())
# 
#         self._sender = sender
#         self._receiver = receiver
#         self._data = data
#         self._term = term
# 
#     @property
#     def receiver(self):
#         return self._receiver
# 
#     @property
#     def sender(self):
#         return self._sender
# 
#     @property
#     def data(self):
#         return self._data
# 
#     @property
#     def timestamp(self):
#         return self._timestamp
# 
#     @property
#     def term(self):
#         return self._term
# 
#     @property
#     def type(self):
#         return self._type
# 
# Path: src/lifeRaft/messages/response.py
# class ResponseMessage(BaseMessage):
# 
#     _type = BaseMessage.Response
# 
#     def __init__(self, sender, receiver, term, data):
#         BaseMessage.__init__(self, sender, receiver, term, data)


# Path: src/lifeRaft/states/state.py
import random
from ..messages.base import BaseMessage
from ..messages.response import ResponseMessage
            from .follower import Follower

        self._timeout = timeout

    def set_server(self, server):
        self._server = server

    def on_message(self, message):
        """This method is called when a message is received,
        and calls one of the other corrosponding methods
        that this state reacts to.

        """
        _type = message.type
        # Convert to follower if heigher term received
        if(message.term > self._server._currentTerm):
            self._server._currentTerm = message.term
            if not issubclass(type(self), Follower):
                follower = Follower(timeout=self._timeout)
                follower.set_server(self._server)
                return follower.on_message(message)

        # Is the messages.term < ours? If so we need to tell
        #   them this so they don't get left behind.
        elif(message.term < self._server._currentTerm):
            self._send_response_message(message, yes=False)
            return self, None

        if(_type == BaseMessage.AppendEntries):
            return self.on_append_entries(message)
        elif(_type == BaseMessage.RequestVote):
            return self.on_vote_request(message)

        elif(_type == BaseMessage.RequestVoteResponse):