Ejemplo n.º 1
0
 def _first_ping(self):
     """
     Send first ping, usually after first connect.
     """
     self.pushPacket(
         Ping(Ping.UNKNOWN_8,
              [0, 1, int(_time.seconds() * 1000) & 0x7fffffff]))
Ejemplo n.º 2
0
 def __init__(self):
     """
     Constructor.
     """
     RTMPBaseProtocol.__init__(self)
     self.bytesReceived = 0
     self.lastReceived = _time.seconds()
     self.pingTask = None
     self.nextInvokeId = 2.0
     self.invokeReplies = {}
Ejemplo n.º 3
0
 def __init__(self):
     """
     Constructor.
     """
     RTMPBaseProtocol.__init__(self)
     self.bytesReceived = 0
     self.lastReceived = _time.seconds()
     self.pingTask = None
     self.nextInvokeId = 2.0
     self.invokeReplies = {}
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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))
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    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))
Ejemplo n.º 8
0
 def _first_ping(self):
     """
     Send first ping, usually after first connect.
     """
     self.pushPacket(Ping(Ping.UNKNOWN_8, [0, 1, int(_time.seconds()*1000) & 0x7fffffff]))