Пример #1
0
def _open_connection():
    global CONNECTION
    global IP
    global MOSKETCH_PORT

    if CONNECTION is not None:
        _print_error("connection is already opened.")
        return

    # Test IP format
    if (is_valid_ipv4_address(IP) == False):
        _print_error('IP address looks wrong, please enter a valid IP address')
        return
    else:
        _print_success('Connecting to ' + IP)

    # Perform initial settings (pre connection)
    _initial_settings()

    # Try to connect
    CONNECTION = QtNetwork.QTcpSocket(MAIN_WINDOW)
    CONNECTION.readyRead.connect(_got_data)
    CONNECTION.error.connect(_got_error)
    CONNECTION.connected.connect(_connected)
    CONNECTION.disconnected.connect(_disconnected)

    print "Trying to connect to " + _get_connection_name()
    CONNECTION.connectToHost(IP, MOSKETCH_PORT)
Пример #2
0
def _open_connection():
    global CONNECTION
    global IP
    global MOSKETCH_PORT

    if CONNECTION is not None:
        _print_error("connection is already opened.")
        return

    # Try to connect
    CONNECTION = QtNetwork.QTcpSocket(MAIN_WINDOW)
    CONNECTION.readyRead.connect(_got_data)
    CONNECTION.error.connect(_got_error)
    CONNECTION.connected.connect(_connected)
    CONNECTION.disconnected.connect(_disconnected)

    print "Trying to connect to " + _get_connection_name()
    CONNECTION.connectToHost(IP, MOSKETCH_PORT)
Пример #3
0
    def __init__(self, parent=None):
        super(QQtmRt, self).__init__(parent=parent)

        self._connected = False
        self._streaming = False
        self._socket = QtNetwork.QTcpSocket(parent=self)

        self._socket.disconnected.connect(self._disconnected)

        self._handlers = {
            QRTPacketType.PacketData: self._on_data,
            QRTPacketType.PacketEvent: self._on_event,
            QRTPacketType.PacketError: self._on_error,
            QRTPacketType.PacketNoMoreData: self._on_no_data,
        }

        self._receiver = qtm.Receiver(self._handlers)

        self.streamingChanged.connect(self._streaming_changed)