示例#1
0
文件: base.py 项目: longde123/fmspy
 def _first_ping(self):
     """
     Send first ping, usually after first connect.
     """
     self.pushPacket(
         Ping(Ping.UNKNOWN_8,
              [0, 1, int(_time.seconds() * 1000) & 0x7fffffff]))
示例#2
0
文件: base.py 项目: longde123/fmspy
 def __init__(self):
     """
     Constructor.
     """
     RTMPBaseProtocol.__init__(self)
     self.bytesReceived = 0
     self.lastReceived = _time.seconds()
     self.pingTask = None
     self.nextInvokeId = 2.0
     self.invokeReplies = {}
示例#3
0
文件: base.py 项目: Xkeeper/fmspy
 def __init__(self):
     """
     Constructor.
     """
     RTMPBaseProtocol.__init__(self)
     self.bytesReceived = 0
     self.lastReceived = _time.seconds()
     self.pingTask = None
     self.nextInvokeId = 2.0
     self.invokeReplies = {}
示例#4
0
文件: base.py 项目: longde123/fmspy
    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)
示例#5
0
文件: base.py 项目: Xkeeper/fmspy
    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))
示例#6
0
文件: base.py 项目: Xkeeper/fmspy
    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)
示例#7
0
文件: base.py 项目: longde123/fmspy
    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))
示例#8
0
文件: base.py 项目: Xkeeper/fmspy
 def _first_ping(self):
     """
     Send first ping, usually after first connect.
     """
     self.pushPacket(Ping(Ping.UNKNOWN_8, [0, 1, int(_time.seconds()*1000) & 0x7fffffff]))