def _finish(self, channelID): ep = self.eps[channelID] if ep: if ep.closed: # `ep` is also closed in the reverse direction del self.eps[channelID] loop.run(self.epControl.requestCloseChannel(channelID, ep.myIDF))
async def _connect_p1(self): conST = await self._connectToServer() if not conST: return False conST.setKeepAlive() self.log(Etypes.ConnectAuth) ok = await self._authenticate(conST) if not ok: return False self.conST = conST self.reminderRX.skipNext = True self.reminderRX.enabled = True loop.run(self.rtask()) return True
def actionNewChannel(self, data): assert len(data) > 12 loop.run(self._actionNewChannel(data))
def runConnect(self): if not self.connect.isPendingOrComplete(): loop.run(self.connect())
def handleRemindTX(self): if self.connect.isComplete(): loop.run(self.requestKA())
def _remove(self, channelID): ep = self.eps[channelID] if ep: del self.eps[channelID] loop.run(self.epControl.requestDeleteChannel(channelID, ep.myIDF))
def connectionLost(self, reason='N/A'): self.log(Etypes.ConnectionLost, reason) if self.isIdle(): self.disconnect() else: loop.run(self.reconnect())
def connectToRelay(self, tokenP, tokenR, relayPort, relayAddr): # Todo: uncomment isIdle() condition # if self.isIdle(): self.disconnect() loop.run(self.connect(info=(tokenP, tokenR, relayPort, relayAddr))) return True
def rtask(self): self.log(Etypes.NewConnection) self.readable.off() loop.run(self.main())