Пример #1
0
        /// <summary>
        /// 设置等待响应状态
        /// </summary>
        /// <param name="messageId">消息id</param>
        /// <param name="response">响应实体</param>
        public void Set(string messageId, MessageResponse response)
        {
            ResponseWait wait = _waits[messageId];

            wait.Response = response;
            wait.Set();
        }
Пример #2
0
 /// <summary>
 /// 添加响应
 /// </summary>
 /// <param name="messageId">消息id</param>
 /// <param name="channelId">信道id</param>
 public void Add(string messageId, string channelId)
 {
     _waits[messageId] = new ResponseWait()
     {
         ChannelId = channelId
     };
     _messageChannelMap[channelId] = messageId;
 }
Пример #3
0
        /// <summary>
        /// 等待响应
        /// </summary>
        /// <param name="messageId">消息id</param>
        /// <returns></returns>
        public ResponseWait Wait(string messageId)
        {
            ResponseWait wait = _waits[messageId];

            wait.Wait();
            _messageChannelMap.TryRemove(wait.ChannelId, out _);
            _waits.TryRemove(messageId, out _);
            return(wait);
        }
Пример #4
0
        /// <summary>
        /// 设置等待响应状态
        /// </summary>
        /// <param name="channelId">信道Id</param>
        /// <param name="response">响应实体</param>
        public void SetByChannelId(string channelId, MessageResponse response)
        {
            string       messageId = _messageChannelMap[channelId];
            ResponseWait wait      = _waits[messageId];

            response.MessageId = messageId;
            wait.Response      = response;
            wait.Set();
        }