transport/code.py
def receive(self, message):
        """ To be called whenever a message is recevied """
        
        # Check the message type
        try:
            tp = message["type"]
        except ValueError:
            return False
        
        if tp != "DATA":
            return False
        
        # Check the id
        try:
            mid = message["id"]
        except ValueError:
            return False
        
        # message matches
        if mid == self.id:
            # send an ACK
            self.send({
                'type': 'ACK', 
                'id': mid
            })
            
            # increase the counter
            self.id += 1
            
            # handle the message            
            self.handle(message["data"])
        
        # future message, send an EXP
        elif mid > self.id:
            self.send({
                'type': 'EXP', 
                'id': self.id
            })
 To be called whenever a message is recevied 
To be called whenever a message is recevied
To be called whenever a message is recevied
def receive(self, message):
        try:
            tp = message["type"]
        except ValueError:
            return False
        if tp != "DATA":
            return False
        try:
            mid = message["id"]
        except ValueError:
            return False
        if mid == self.id:
            self.send({
                'type': 'ACK', 
                'id': mid
            })
            self.id += 1
            self.handle(message["data"])
        elif mid > self.id:
            self.send({
                'type': 'EXP', 
                'id': self.id
            })
def receive ( self , message ) : try : tp = message [ "type" ] except ValueError : return False if tp != "DATA" : return False try : mid = message [ "id" ] except ValueError : return False if mid == self . id : self . send ( { 'type' : 'ACK' , 'id' : mid } ) self . id += 1 self . handle ( message [ "data" ] ) elif mid > self . id : self . send ( { 'type' : 'EXP' , 'id' : self . id } )
To be called whenever a message is recevied
To be called whenever a message is recevied
""" To be called whenever a message is recevied """ # Check the message type # Check the id # message matches # send an ACK # increase the counter # handle the message             # future message, send an EXP
self
message