def beforeReplyTimeout(self, interest, onVerified, onVerifyFailed, onTimeout): newInterest = Interest(interest) newInterest.refreshNonce() self._face.expressInterest(newInterest, lambda i, d : self.onData(i, d, onVerified, onVerifyFailed, onTimeout), lambda i: self.beforeReplyTimeout(i, onVerified, onVerifyFailed, onTimeout)) onTimeout(interest) return
def onTrustSchemaTimeout(self, interest, onUpdateSuccess, onUpdateFailed): print("Trust schema interest times out: " + interest.getName().toUri()) newInterest = Interest(interest) newInterest.refreshNonce() self._face.expressInterest(newInterest, lambda interest, data: self.onTrustSchemaData(interest, data, onUpdateSuccess, onUpdateFailed), lambda interest: self.onTrustSchemaTimeout(interest, onUpdateSuccess, onUpdateFailed)) return
def test_refresh_nonce(self): interest = Interest(self.referenceInterest) oldNonce = interest.getNonce() self.assertEqual(4, oldNonce.size()) interest.refreshNonce() self.assertEqual(oldNonce.size(), interest.getNonce().size(), "The refreshed nonce should be the same size") self.assertFalse(interest.getNonce().equals(oldNonce), "The refreshed nonce should be different")
def beforeReplyVerificationFailed(self, data, interest, onVerified, onVerifyFailed, onTimeout): # for now internal to the library: verification failed cause the library to retransmit the interest after some time newInterest = Interest(interest) newInterest.refreshNonce() dummyInterest = Interest(Name("/local/timeout")) dummyInterest.setInterestLifetimeMilliseconds(self._verifyFailedRetransInterval) self._face.expressInterest(dummyInterest, self.onDummyData, lambda i: self.retransmitInterest(newInterest, onVerified, onVerifyFailed, onTimeout)) onVerifyFailed(data) return
def onMemberCertificateTimeout(self, interest, accessInterest): print "Member certificate interest times out: " + interest.getName( ).toUri() newInterest = Interest(interest) newInterest.refreshNonce() self.face.expressInterest( newInterest, lambda memberInterest, memberData: self.onMemberCertificateData( memberInterest, memberData, accessInterest), lambda memberInterest: self.onMemberCertificateTimeout( memberInterest, accessInterest)) return
def onControllerCertTimeout(self, interest, onSetupComplete, onSetupFailed, controllerCertRetries): print "Controller certificate interest times out" newInterest = Interest(interest) newInterest.refreshNonce() if controllerCertRetries == 0: if onSetupFailed: onSetupFailed("Controller certificate interest times out") else: print "Set up failed: controller certificate interest times out" else: self._face.expressInterest(newInterest, lambda interest, data: self.onControllerCertData(interest, data, onSetupComplete, onSetupFailed), lambda interest: self.onControllerCertTimeout(interest, onSetupComplete, onSetupFailed, controllerCertRetries - 1)) return
def onAppRequestTimeout(self, interest, onSetupComplete, onSetupFailed, appRequestTimeoutCnt): print "Application publishing request times out" newInterest = Interest(interest) newInterest.refreshNonce() if appRequestTimeoutCnt == 0: if onSetupFailed: onSetupFailed("Application publishing request times out") else: print "Setup failed: application publishing request times out" else: self._face.expressInterest(newInterest, lambda interest, data : self.onAppRequestData(interest, data, onSetupComplete, onSetupFailed), lambda interest : self.onAppRequestTimeout(interest, onSetupComplete, onSetupFailed, appRequestTimeoutCnt - 1)) return
def expressHeartbeatInterest(self, dummyInterest, entityInterest): newInterest = Interest(entityInterest) newInterest.refreshNonce() self._face.expressInterest(newInterest, self.onHeartbeatData, self.onHeartbeatTimeout)