コード例 #1
0
        /// <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));
                pub.Unadvertise();
            }
            foreach (var srv in this.serviceProviders)
            {
                this.webSocket.Send(RosBridgeMsg.UnadvertiseService(srv.Key.Name));
            }

            this.webSocket.Close();
            this.msgQueue.Clear();
        }
コード例 #2
0
        /// <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));
            }

            publisher.Unadvertise();
            this.publishers.Remove(publisher);
        }