From 71720ca73bb67412748e4b64a5166721fab840cd Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 20 May 2024 13:04:24 -0700 Subject: [PATCH 1/2] update --- ChatRoom/ChatRoom.Service/ChannelGrain.cs | 26 +++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ChatRoom/ChatRoom.Service/ChannelGrain.cs b/ChatRoom/ChatRoom.Service/ChannelGrain.cs index 71f1884..7747adf 100644 --- a/ChatRoom/ChatRoom.Service/ChannelGrain.cs +++ b/ChatRoom/ChatRoom.Service/ChannelGrain.cs @@ -37,13 +37,11 @@ public async Task Join(AgentInfo agentInfo, IChannelObserver callBack) return; } - var agentObserver = new ObserverManager(TimeSpan.FromMinutes(1), _logger); - agentObserver.Subscribe(callBack, callBack); - _agents[agentInfo] = agentObserver; + _agents[agentInfo] = callBack; - foreach (var observer in _agents.Values) + foreach (var cb in _agents.Values) { - await observer.Notify(x => x.Join(agentInfo, _channelInfo)); + await cb.Join(agentInfo, _channelInfo); } } @@ -56,17 +54,17 @@ public async Task Leave(AgentInfo agentInfo) _agents.Remove(agentInfo); - foreach (var observer in _agents.Values) + foreach (var cb in _agents.Values) { - await observer.Notify(x => x.Leave(agentInfo, _channelInfo)); + await cb.Leave(agentInfo, _channelInfo); } } public async Task Message(ChatMsg msg) { - foreach (var observer in _agents.Values) + foreach (var cb in _agents.Values) { - await observer.Notify(x => x.NewMessage(msg)); + await cb.NewMessage(msg); } if (msg.From != "System") @@ -96,7 +94,7 @@ public async Task GetOnlineMembers() var agents = new List(); foreach (var agent in _agents.Keys) { - var observer = _agents[agent].Observers.First().Value; + var observer = _agents[agent]; var ping = await observer.Ping(); if (ping) { @@ -159,8 +157,8 @@ public async Task GetOnlineMembers() if (nextAvailableAgents.Count() == 1 && onlineMembers.Any(x => x.Name == nextAvailableAgents.First().Name)) { var nextSpeaker = onlineMembers.First(x => x.Name == nextAvailableAgents.First().Name); - var agentObserver = _agents[nextSpeaker]; - await agentObserver.Notify(x => GenerateNextReply(x, nextSpeaker, _messages.ToArray())); + var cb = _agents[nextSpeaker]; + var _ = GenerateNextReply(cb, nextSpeaker, _messages.ToArray()); return nextSpeaker; } else if (nextAvailableAgents.Count() > 1) @@ -182,8 +180,8 @@ public async Task GetOnlineMembers() var nextSpeaker = onlineMembers.First(x => x.Name == lastMessage.From); if (nextAvailableAgents.Any(x => x.Name == nextSpeaker.Name)) { - var agentObserver = _agents[nextSpeaker]; - await agentObserver.Notify(x => GenerateNextReply(x, nextSpeaker, _messages.ToArray())); + var cb = _agents[nextSpeaker]; + var _ = GenerateNextReply(cb, nextSpeaker, _messages.ToArray()); return nextSpeaker; } From 53a1ded2c4e659da1d1e1e8de5379c4a3c1ad7fd Mon Sep 17 00:00:00 2001 From: XiaoYun Zhang Date: Mon, 20 May 2024 13:05:13 -0700 Subject: [PATCH 2/2] update version --- eng/MetaInfo.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/MetaInfo.props b/eng/MetaInfo.props index 3cceb0a..8cf77fb 100644 --- a/eng/MetaInfo.props +++ b/eng/MetaInfo.props @@ -1,7 +1,7 @@ - 0.0.4 + 0.0.6 LittleLittleCloud git false