示例#1
0
 def SupplierSendFile(self, fileName, packetID, ownerID, callOnAck=None, callOnFail=None):
     if self.shutdown: 
         dhnio.Dprint(10, "io_throttle.SupplierSendFile finishing to %s, shutdown is True" % self.remoteName)
         return        
     if contact_status.isOffline(self.remoteID):
         dhnio.Dprint(10, "io_throttle.SupplierSendFile %s is offline, so packet %s is failed" % (self.remoteName, packetID))
         if callOnFail is not None:
             reactor.callLater(0, callOnFail, self.remoteID, packetID, 'offline')
         return
     if packetID in self.fileSendQueue:
         # dhnio.Dprint(4, "io_throttle.SupplierSendFile WARNING packet %s already in the queue for %s" % (packetID, self.remoteName))
         if callOnFail is not None:
             reactor.callLater(0, callOnFail, self.remoteID, packetID, 'in queue')
         return
     self.fileSendQueue.append(packetID)
     self.fileSendDict[packetID] = FileToSend(
         fileName, 
         packetID, 
         self.remoteID, 
         ownerID, 
         callOnAck,
         callOnFail,)
     dhnio.Dprint(10, "io_throttle.SupplierSendFile %s to %s, queue=%d" % (packetID, self.remoteName, len(self.fileSendQueue)))
     # reactor.callLater(0, self.DoSend)
     self.DoSend()
示例#2
0
def TransportUDPSessionStateChanged(automatindex, oldstate, newstate):
    if newstate != 'CONNECTED':
        return
    sess = automat.objects().get(automatindex, None)
    if sess is None:
        return
    idurl = sess.remote_idurl
    if idurl is None:
        return
    if contact_status.isOffline(idurl):
        A('ping-contact', idurl)