/// <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(); }
/// <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; }
/// <summary> /// 等待响应 /// </summary> /// <param name="messageId">消息id</param> /// <returns></returns> public ResponseWait Wait(string messageId) { ResponseWait wait = _waits[messageId]; wait.Wait(_timeoutSeconds); _messageChannelMap.TryRemove(wait.ChannelId, out _); _waits.TryRemove(messageId, out _); return(wait); }
/// <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(); }