diff --git a/ClientTest/StarFactoryTests.cs b/ClientTest/StarFactoryTests.cs
index 9898b09c..5a66c83f 100644
--- a/ClientTest/StarFactoryTests.cs
+++ b/ClientTest/StarFactoryTests.cs
@@ -45,13 +45,13 @@ public void Normal()
var dust = star.Service as AppClient;
Assert.NotNull(dust);
- var filter = star.GetValue("_tokenFilter") as TokenHttpFilter;
- Assert.NotNull(filter);
- Assert.Equal(star.AppId, filter.UserName);
- Assert.Equal(star.Secret, filter.Password);
- Assert.Equal(filter, (tracer.Client as ApiHttpClient).Filter);
- Assert.Equal(filter, (config.Client as ApiHttpClient).Filter);
- Assert.Equal(filter, (dust as ApiHttpClient).Filter);
+ //var filter = star.GetValue("_tokenFilter") as TokenHttpFilter;
+ //Assert.NotNull(filter);
+ //Assert.Equal(star.AppId, filter.UserName);
+ //Assert.Equal(star.Secret, filter.Password);
+ //Assert.Equal(filter, (tracer.Client as ApiHttpClient).Filter);
+ //Assert.Equal(filter, (config.Client as ApiHttpClient).Filter);
+ //Assert.Equal(filter, (dust as ApiHttpClient).Filter);
}
[Fact]
diff --git a/DeployAgent/DeployWorker.cs b/DeployAgent/DeployWorker.cs
index de10b340..971a6dc4 100644
--- a/DeployAgent/DeployWorker.cs
+++ b/DeployAgent/DeployWorker.cs
@@ -1,9 +1,9 @@
using NewLife;
using NewLife.Model;
+using NewLife.Remoting.Clients;
using NewLife.Serialization;
using Stardust;
using Stardust.Models;
-using Stardust.Services;
namespace DeployAgent;
diff --git a/Plugins/MySqlAgent/BinlogClear.cs b/Plugins/MySqlAgent/BinlogClear.cs
index 8e8c4083..a8bdacca 100644
--- a/Plugins/MySqlAgent/BinlogClear.cs
+++ b/Plugins/MySqlAgent/BinlogClear.cs
@@ -1,7 +1,7 @@
using NewLife;
using NewLife.Log;
+using NewLife.Remoting.Clients;
using NewLife.Threading;
-using Stardust.Services;
namespace MySqlAgent;
diff --git a/Plugins/MySqlAgent/MySqlPlugin.cs b/Plugins/MySqlAgent/MySqlPlugin.cs
index e695d4fa..631b8e1b 100644
--- a/Plugins/MySqlAgent/MySqlPlugin.cs
+++ b/Plugins/MySqlAgent/MySqlPlugin.cs
@@ -1,9 +1,9 @@
using System.ComponentModel;
using NewLife.Log;
using NewLife.Model;
+using NewLife.Remoting.Clients;
using NewLife.Threading;
using Stardust.Plugins;
-using Stardust.Services;
namespace MySqlAgent;
diff --git a/StarAgent/Program.cs b/StarAgent/Program.cs
index 9d9b2fd5..7d64cc77 100644
--- a/StarAgent/Program.cs
+++ b/StarAgent/Program.cs
@@ -7,6 +7,7 @@
using NewLife.Model;
using NewLife.Reflection;
using NewLife.Remoting;
+using NewLife.Remoting.Clients;
using NewLife.Serialization;
using NewLife.Threading;
using Stardust;
diff --git a/Stardust/AppClient.cs b/Stardust/AppClient.cs
index 83410b7c..ad050493 100644
--- a/Stardust/AppClient.cs
+++ b/Stardust/AppClient.cs
@@ -4,15 +4,19 @@
using NewLife;
using NewLife.Log;
using NewLife.Reflection;
-using NewLife.Remoting;
using NewLife.Serialization;
-using NewLife.Threading;
using Stardust.Models;
using Stardust.Registry;
-using Stardust.Services;
using NewLife.Caching;
using System.Net.NetworkInformation;
using NewLife.Remoting.Models;
+using NewLife.Remoting.Clients;
+using NewLife.Security;
+using NewLife.Remoting;
+using NewLife.Http;
+
+
+
#if NET45_OR_GREATER || NETCOREAPP || NETSTANDARD
using System.Net.WebSockets;
@@ -22,7 +26,7 @@
namespace Stardust;
/// 应用客户端。每个应用有一个客户端连接星尘服务端
-public class AppClient : ApiHttpClient, ICommandClient, IRegistry, IEventProvider
+public class AppClient : ClientBase, IRegistry
{
#region 属性
/// 应用
@@ -37,9 +41,6 @@ public class AppClient : ApiHttpClient, ICommandClient, IRegistry, IEventProvide
/// 节点编码
public String? NodeCode { get; set; }
- /// WebSocket长连接。建立长连接后,可以实时感知配置更新和注册服务更新,默认false
- public Boolean UseWebSocket { get; set; }
-
/// 看门狗超时时间。默认0秒
///
/// 设置看门狗超时时间,超过该时间未收到心跳,将会重启本应用进程。
@@ -50,16 +51,6 @@ public class AppClient : ApiHttpClient, ICommandClient, IRegistry, IEventProvide
/// 星尘工厂
public StarFactory? Factory { get; set; }
- private ConcurrentDictionary _commands = new(StringComparer.OrdinalIgnoreCase);
- /// 命令集合
- public IDictionary Commands => _commands;
-
- /// 收到命令时触发
- public event EventHandler? Received;
-
- /// 最大失败数。超过该数时,新的数据将被抛弃,默认10 * 24 * 60
- public Int32 MaxFails { get; set; } = 10 * 24 * 60;
-
private AppInfo? _appInfo;
private readonly String? _version;
@@ -78,6 +69,10 @@ public class AppClient : ApiHttpClient, ICommandClient, IRegistry, IEventProvide
/// 实例化
public AppClient()
{
+ Features = Features.Login | Features.Ping | Features.Notify;
+ SetActions("App/");
+ Actions[Features.Login] = "App/Register";
+
// 加载已保存数据
var dic = LoadConsumeServicese();
if (dic != null && dic.Count > 0)
@@ -108,17 +103,7 @@ public AppClient()
/// 实例化
///
- public AppClient(String urls) : this()
- {
- if (!urls.IsNullOrEmpty())
- {
- var ss = urls.Split(',', ';');
- for (var i = 0; i < ss.Length; i++)
- {
- Add("service" + (i + 1), new Uri(ss[i]));
- }
- }
- }
+ public AppClient(String urls) : this() => Server = urls;
/// 销毁
///
@@ -126,8 +111,6 @@ protected override void Dispose(Boolean disposing)
{
base.Dispose(disposing);
- StopTimer();
-
foreach (var item in _publishServices)
{
//UnregisterAsync(item.Value).Wait();
@@ -145,7 +128,7 @@ public void Start()
if (AppId != "StarServer")
{
// 等待注册到平台
- var task = TaskEx.Run(Register);
+ var task = TaskEx.Run(Login);
task.Wait(1_000);
}
}
@@ -157,123 +140,50 @@ public void Start()
StartTimer();
}
- private String? _appName;
- /// 注册
+ /// 创建Http客户端
+ ///
///
- public async Task