Skip to content

Commit

Permalink
客户端新增Received事件,接收服务端下发消息
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Sep 2, 2023
1 parent 996e7b1 commit 2eff5f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions NewLife.Remoting/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class ApiClient : ApiHost, IApiClient
/// <summary>最后活跃时间</summary>
public DateTime LastActive { get; set; }

/// <summary>收到服务端主动下发</summary>
public event EventHandler<ReceivedEventArgs> Received;

/// <summary>调用统计</summary>
public ICounter StatInvoke { get; set; }

Expand Down Expand Up @@ -344,6 +347,8 @@ private void Client_Received(Object sender, ReceivedEventArgs e)
{
LastActive = DateTime.Now;

Received?.Invoke(this, e);

// Api解码消息得到Action和参数
if (e.Message is not IMessage msg || msg.Reply) return;

Expand Down
2 changes: 1 addition & 1 deletion XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NewLife.Core" Version="10.5.2023.801" />
<PackageReference Include="NewLife.UnitTest" Version="1.0.2023.718" />
<PackageReference Include="xunit" Version="2.5.0" />
Expand Down

0 comments on commit 2eff5f0

Please sign in to comment.