Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.0.6 #3

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions ChatRoom/ChatRoom.Service/ChannelGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ public async Task Join(AgentInfo agentInfo, IChannelObserver callBack)
return;
}

var agentObserver = new ObserverManager<IChannelObserver>(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);
}
}

Expand All @@ -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<bool> 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")
Expand Down Expand Up @@ -96,7 +94,7 @@ public async Task<AgentInfo[]> GetOnlineMembers()
var agents = new List<AgentInfo>();
foreach (var agent in _agents.Keys)
{
var observer = _agents[agent].Observers.First().Value;
var observer = _agents[agent];
var ping = await observer.Ping();
if (ping)
{
Expand Down Expand Up @@ -159,8 +157,8 @@ public async Task<AgentInfo[]> 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)
Expand All @@ -182,8 +180,8 @@ public async Task<AgentInfo[]> 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;
}

Expand Down
2 changes: 1 addition & 1 deletion eng/MetaInfo.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>0.0.4</VersionPrefix>
<VersionPrefix>0.0.6</VersionPrefix>
<Authors>LittleLittleCloud</Authors>
<RepositoryType>git</RepositoryType>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
Loading