transport/code.py
def receive(self, message):
        """ To be called whenever a message is recevied """
        
        # in case of an ACK, first check if the package is still there
        if message["type"] == "ACK":
            mid = message["id"]
            
            # if so, delete it
            if mid in self.cache:
                del self.cache[mid]
            
            # and try to send the next message
            if mid+1 in self.cache:
                self.send({
                    'type': 'DATA', 
                    'id': mid + 1, 
                    'data': self.cache[mid + 1]
                })
        
        # EXP -- send the message
        elif message["type"] == "EXP":
            mid = message["id"]
            
            if mid in self.cache:
                self.send({
                    'type': 'DATA', 
                    'id': mid, 
                    'data': self.cache[mid]
                })
 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):
        if message["type"] == "ACK":
            mid = message["id"]
            if mid in self.cache:
                del self.cache[mid]
            if mid+1 in self.cache:
                self.send({
                    'type': 'DATA', 
                    'id': mid + 1, 
                    'data': self.cache[mid + 1]
                })
        elif message["type"] == "EXP":
            mid = message["id"]
            if mid in self.cache:
                self.send({
                    'type': 'DATA', 
                    'id': mid, 
                    'data': self.cache[mid]
                })
def receive ( self , message ) : if message [ "type" ] == "ACK" : mid = message [ "id" ] if mid in self . cache : del self . cache [ mid ] if mid + 1 in self . cache : self . send ( { 'type' : 'DATA' , 'id' : mid + 1 , 'data' : self . cache [ mid + 1 ] } ) elif message [ "type" ] == "EXP" : mid = message [ "id" ] if mid in self . cache : self . send ( { 'type' : 'DATA' , 'id' : mid , 'data' : self . cache [ mid ] } )
To be called whenever a message is recevied
To be called whenever a message is recevied
""" To be called whenever a message is recevied """ # in case of an ACK, first check if the package is still there # if so, delete it # and try to send the next message # EXP -- send the message
self
message