Skip to content

Commit

Permalink
支持空命令,可发送 0x0 0x0 0x0 0x0 监测各个服务端健康性
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack authored and Jack committed Jul 31, 2020
1 parent 93a9145 commit 9c2ba6a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions JMS.Gateway.Referee/Impls/RequestReception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public void Interview(Socket socket)
using (var client = new NetClient(socket))
{
var cmd = client.ReadServiceObject<GatewayCommand>();
if (cmd == null)
{
client.Write(Encoding.UTF8.GetBytes("ok"));
return;
}
_logger?.LogDebug("收到命令,type:{0} content:{1}", cmd.Type, cmd.Content);

_manager.AllocHandler(cmd)?.Handle(client, cmd);
Expand Down
5 changes: 5 additions & 0 deletions JMS.Gateway/Impls/RequestReception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public void Interview(Socket socket)
while (true)
{
var cmd = client.ReadServiceObject<GatewayCommand>();
if (cmd == null)
{
client.Write(Encoding.UTF8.GetBytes("ok"));
return;
}
_logger?.LogDebug("type:{0} content:{1}", cmd.Type, cmd.Content);

_manager.AllocHandler(cmd)?.Handle(client, cmd);
Expand Down
6 changes: 6 additions & 0 deletions JMS.Proxy/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public void Dispose()
public void Start()
{
var target = _client.ReadServiceObject<NetAddress>();
if(target == null)
{
_client.Write(Encoding.UTF8.GetBytes("ok"));
_client.Dispose();
return;
}
_logger?.LogDebug("收到转发{0} {1}", target.Address, target.Port);

_targetClient = new CertClient(target, _proxy.ClientCert);
Expand Down
5 changes: 5 additions & 0 deletions JMS.ServiceProvider/Impls/RequestReception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public void Interview(Socket socket)
while (true)
{
var cmd = netclient.ReadServiceObject<InvokeCommand>();
if (cmd == null)
{
netclient.Write(Encoding.UTF8.GetBytes("ok"));
return;
}
if (_processExitHandler.ProcessExited)
return;

Expand Down
2 changes: 1 addition & 1 deletion JMS.ServiceProvider/JMS.ServiceProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>JMS.ServiceProvider</AssemblyName>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/simpleway2016/JMS</RepositoryUrl>
<Version>1.0.0.20</Version>
<Version>1.0.0.21</Version>
<Authors>Jack.T</Authors>
<Company>JMS</Company>
<Product>JMS</Product>
Expand Down

0 comments on commit 9c2ba6a

Please sign in to comment.