/// <summary>
 /// 关闭并释放通道
 /// </summary>
 public void Dispose()
 {
     if (PublishChannel.IsOpen)
     {
         PublishChannel.Close();
     }
     PublishChannel.Dispose();
 }
Example #2
0
        /// <summary>
        ///     Disconnect disconnects the Client from the Amqp Server.
        /// </summary>
        /// <param name="code">The status code of the disconnect.</param>
        /// <param name="text">The status text of the disconnect.</param>
        public void Disconnect(ushort code, string text)
        {
            lock (PublishChannel)
            {
                PublishChannel.Close(code, text);
            }

            foreach (var value in SubscribeChannels.Values)
            {
                value.Close();
            }
            WriteConnection.Close(code, text);
            ReadConnection.Close(code, text);
        }