示例#1
0
 def _onConnect(self, connector):
     self.connectOp = None
     if connector.getError() != 0:
         self.shutdown(notity=True)
         return
     self.stream = TCPLineStream(connector.getSock(), self.reactor)
     self.stream.setCloseCallback(self._onClose)
     self.stream.setErrorCallback(self._onError)
     self.stream.setInputCallback(self._onInput)
     self.stream.enableRead(True)
     if self.state == self.CONNECTING:
         self.stream.writeData('CONNECTPUBKEY %s TextChat\r\n' %
                               self.peerPubKey)
     else:
         assert self.state == self.ACCEPTING
         self.stream.writeData('ACCEPT %s\r\n' % self.connectionId)
示例#2
0
 def _onConnect(self, connector):
     self.connectOp = None
     if connector.getError() != 0:
         self.op.notify(-1, None)
         return
     self.stream = TCPLineStream(connector.getSock(), self.reactor)
     self.stream.setCloseCallback(self._onClose)
     self.stream.setErrorCallback(self._onError)
     self.stream.setInputCallback(self._onInput)
     self.stream.enableRead(True)
     if env.isContactAction:
         self.stream.writeData('GETPUBKEY %s\r\n' % env.contactName)
     else:
         self.stream.writeData('GETINCOMINGPUBKEY %s\r\n' %
                               env.connectionId)
     self.state = self.GETTINGKEY
示例#3
0
 def _onTCPConnect(self, connector):
     self.tcpConnectOp = None
     if connector.getError() != 0:
         self.chatOutputView.append('ERROR')
         return
     self.sock = connector.getSock()
     self.stream = TCPLineStream(self.sock, self.reactor)
     self.stream.setCloseCallback(self._onClose)
     self.stream.setErrorCallback(self._onError)
     self.stream.setInputCallback(self._onInput)
     self.stream.enableRead(True)
     if self.isClient:
         self.stream.writeData('CONNECT %s test\r\n' %
                               cspaceContactNickName)
     else:
         self.stream.writeData('ACCEPT %s\r\n' % cspaceConnectionId)