def StatusChanged(self, status): '''Client status has been changed''' client_log.info('[dbus] client status changed: %s' % status) self._status = status # Connect to web server OK if self._status == constants.CLIENT_STATUS_PAGE_READY: self.connected_to_webserver = True # Connect to web server failed elif self._status == constants.CLIENT_STATUS_CONNECT_FAILED: self.Stop() # Peer id is invalid elif self._status == constants.CLIENT_STATUS_UNAVAILABLE: self.Stop() # Connect to remote peer OK elif self._status == constants.CLIENT_STATUS_CONNECT_OK: self.remoting_connected = True # Disconnected, by remote peer or network failed elif self._status == constants.CLIENT_STATUS_DISCONNECTED: notify(_('Remoting service terminated!')) self.Stop()
def init_remoting(remote_peer_id): '''Connect to remote peer''' client_log.info('[cmd] init_remoting: %s' % remote_peer_id) send_message(json.dumps({ 'Type': constants.CLIENT_MSG_INIT, 'Payload': remote_peer_id, }))
def start(self): print('[wssd] start') client_log.info('[wssd] controller started') if self.worker_started: return self.worker_started = True self.started.emit()
def stop(self): print('[wssd] stopped') client_log.info('[wssd] controller stopped') if self.worker_started: self.worker.stop_server() if not self.workerThread.isFinished(): self.workerThread.quit() self.workerThread.wait(1)
def Connect(self, remote_peer_id): '''Connect to remote peer''' # Send remote peer id to browser side client_log.info('[dbus] Connect: %s' % remote_peer_id) self.StatusChanged(constants.CLIENT_STATUS_CONNECTING) cmd.init_remoting(remote_peer_id) # Init webrtc-connection-timeout timer QtCore.QTimer.singleShot(constants.WEBRTC_CONNECTION_TIMEOUT, self.on_webrtc_connection_timeout)
def stop_server(self): client_log.info('[wssd] worker stop') if self.loop: self.loop.stop()