def handleMessage(self,message): #TODO: this needs to be fast if message.header.verb == VERB_SYN: synMsg = polyp_util.deserialize(GossipSynMessage(),message.body) self.syn(message.header.sender,synMsg) elif message.header.verb == VERB_ACK: ackMsg = polyp_util.deserialize(GossipAckMessage(),message.body) self.ack(message.header.sender,ackMsg) elif message.header.verb == VERB_ACKBACK: ackBackMsg = polyp_util.deserialize( GossipAckBackMessage(),message.body) self.ackBack(message.header.sender,ackBackMsg) elif message.header.verb == VERB_NEWSTATE: newStateMsg = polyp_util.deserialize(NewStateMessage(),message.body) self.add_application_state(newStateMsg.key,newStateMsg.value) elif message.header.verb == VERB_GETSTATE: getStateMsg = polyp_util.deserialize(GetStateMessage(),message.body) self.get_state(message.header.sender,getStateMsg) elif message.header.verb == VERB_RETURNSTATE: returnStateMsg = polyp_util.deserialize(ReturnStateMessage(),message.body) self.return_state(message.header.sender,returnStateMsg)
def handleMessage(self,message): echoHeader = polyp_util.deserialize(Header(),message.body) print "Echo: ", echoHeader.verb