def connectionLost(cl_self, reason): logger.debug("Connection closed with reason {reason}".format(reason=reason)) self.client = None if self.pinger: self.pinger.stop() self.on_close() WebSocketClientProtocol.connectionLost(cl_self, reason)
def send(msg): binaries, jsonMsg = recursiveBinarySearch(msg) WebSocketClientProtocol.sendMessage(self, json.dumps(jsonMsg)) for data in binaries: msg = data[0] + data[1].getvalue() WebSocketClientProtocol.sendMessage(self, msg, binary=True)
def _send(self, msg, binaries): """ Internally used method to send messages via WebSocket connection. Handles the actual sending of the message. (Not thread-safe; use sendMessage instead.) """ WebSocketClientProtocol.sendMessage(self, msg) for data in binaries: binMsg = data[0] + data[1].getvalue() WebSocketClientProtocol.sendMessage(self, binMsg, binary=True)
def connectionMade(self): FuzzingProtocol.connectionMade(self) WebSocketClientProtocol.connectionMade(self) self.caseAgent = self.factory.agent self.case = self.factory.currentCaseIndex self.Case = Cases[self.case - 1] self.runCase = self.Case(self) self.caseStarted = utcnow() print "Running test case ID %s for agent %s from peer %s" % (caseClasstoId(self.Case), self.caseAgent, self.peerstr)
def connectionMade(self): FuzzingProtocol.connectionMade(self) WebSocketClientProtocol.connectionMade(self) self.caseStarted = utcnow() print "Running test case ID %s for agent %s from peer %s" % (self.factory.CaseSet.caseClasstoId(self.Case), self.caseAgent, self.peerstr)
def connectionLost(self, reason): print "connection lost" WebSocketClientProtocol.connectionLost(self, reason) self.factory.unregister(self) reactor.callLater(2, self.factory.connect)
def sendMessage(self, payload): WebSocketClientProtocol.sendMessage(self, json.dumps(payload))
def sendMessage(self, payload, binary=False): session_id = self.session_id if hasattr(self, "session_id") else None now = round(1000000 * (time.clock() - self.factory.case.started)) rec = (now, session_id, "TX", payload) self.factory.case.wampLog.append(rec) WebSocketClientProtocol.sendMessage(self, payload, binary)
def onMessageFrameBegin(self, length, reserved): #log.msg('onMessageFrameBegin: %s' % length) WebSocketClientProtocol.onMessageFrameBegin(self, length, reserved) if self.frame_num == WSCP_DATA and self.buffer_filled is not None: self.file_decoders[self.path].registerProducer(self, True)
def onMessageBegin(self, opcode): log.msg('onMessageBegin') WebSocketClientProtocol.onMessageBegin(self, opcode)
def connectionLost(self, reason): WebSocketClientProtocol.connectionLost(self, reason) FuzzingProtocol.connectionLost(self, reason)
def sendMessage(self, msg, binary, cb): assert self._cb is None self._cb = cb WebSocketClientProtocol.sendMessage(self, msg, binary)
def connectionLost(self,reason): self.factory.connections.remove(self) WebSocketClientProtocol.connectionLost(self, reason)#always after your code reactor.stop()
def connectionMade(self): WebSocketClientProtocol.connectionMade(self)#always before your code self.factory.connections.append(self)
def failHandshake(self, reason): """ This method is called by twisted when the connection could not be initialized. """ print(reason) WebSocketClientProtocol.failHandshake(self, reason)
def connectionLost(self, reason): print 'connection lost' WebSocketClientProtocol.connectionLost(self, reason) self.factory.unregister(self) reactor.callLater(2, self.factory.connect)