def _first_ping(self): """ Send first ping, usually after first connect. """ self.pushPacket( Ping(Ping.UNKNOWN_8, [0, 1, int(_time.seconds() * 1000) & 0x7fffffff]))
def __init__(self): """ Constructor. """ RTMPBaseProtocol.__init__(self) self.bytesReceived = 0 self.lastReceived = _time.seconds() self.pingTask = None self.nextInvokeId = 2.0 self.invokeReplies = {}
def dataReceived(self, data): """ Some data was received from peer. @param data: bytes received @type data: C{str} """ self.lastReceived = _time.seconds() self.bytesReceived += len(data) RTMPBaseProtocol.dataReceived(self, data)
def _pinger(self): """ Regular 'ping' service. We send 'pings' to other end of RTMP protocol, expecting to receive 'pong'. If we receive some data, we assume 'ping' is sent. If other end of protocol doesn't send anything in reply to our 'ping' for some timeout, we disconnect connection. """ noDataInterval = _time.seconds() - self.lastReceived if noDataInterval > config.getint('RTMP', 'keepAliveTimeout'): log.msg('Closing connection due too much inactivity (%d)' % noDataInterval) self.transport.loseConnection() return if noDataInterval > config.getint('RTMP', 'pingInterval'): self.pushPacket(Ping(Ping.PING_CLIENT, [int(_time.seconds()*1000) & 0x7fffffff])) self.pushPacket(BytesRead(self.bytesReceived))
def _pinger(self): """ Regular 'ping' service. We send 'pings' to other end of RTMP protocol, expecting to receive 'pong'. If we receive some data, we assume 'ping' is sent. If other end of protocol doesn't send anything in reply to our 'ping' for some timeout, we disconnect connection. """ noDataInterval = _time.seconds() - self.lastReceived if noDataInterval > config.getint('RTMP', 'keepAliveTimeout'): log.msg('Closing connection due too much inactivity (%d)' % noDataInterval) self.transport.loseConnection() return if noDataInterval > config.getint('RTMP', 'pingInterval'): self.pushPacket( Ping(Ping.PING_CLIENT, [int(_time.seconds() * 1000) & 0x7fffffff])) self.pushPacket(BytesRead(self.bytesReceived))
def _first_ping(self): """ Send first ping, usually after first connect. """ self.pushPacket(Ping(Ping.UNKNOWN_8, [0, 1, int(_time.seconds()*1000) & 0x7fffffff]))