/// <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 Service server from this connection /// </summary> /// <param name="serviceProvider"></param> public void Unadvertise(ROSBridgeServiceProvider serviceProvider) { if (this.IsConnected) { this.webSocket.Send(ROSBridgeMsg.UnadvertiseService(serviceProvider.Name)); } this.serviceProviders.Remove(serviceProvider); }