/// <summary> /// Disconnect from the remote ros environment. /// </summary> public void Disconnect() { if (!this.IsConnected) { return; } // this.sendMsgThread.Abort(); this.isConnected = false; Thread.Sleep(15); foreach (var sub in this.subscribers) { this.webSocket.Send(ROSBridgeMsg.UnSubscribe(sub.Key.Topic)); } foreach (var pub in this.publishers) { this.webSocket.Send(ROSBridgeMsg.UnAdvertiseTopic(pub.Topic)); } foreach (var srv in this.serviceProviders) { this.webSocket.Send(ROSBridgeMsg.UnadvertiseService(srv.Key.Name)); } this.webSocket.Close(); this.msgQueue.Clear(); }
/// <summary> /// Remove a publisher from this connection /// </summary> /// <param name="publisher"></param> public void Unadvertise(ROSBridgePublisher publisher) { if (this.IsConnected) { this.webSocket.Send(ROSBridgeMsg.UnAdvertiseTopic(publisher.Topic)); } this.publishers.Remove(publisher); }