Commit 0ca05810 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 RevCtrl_Proxy 继承于 Reflect_Proxy, 全部 代理服务逻辑写再 WsServiceProxy

parent 1b3c276f
...@@ -34,8 +34,8 @@ namespace WSCF.RevCtrl.Test.Server ...@@ -34,8 +34,8 @@ namespace WSCF.RevCtrl.Test.Server
public void SendMsgToGroupChat(string msg, AsyncCBHandler asyncDelegate, object asyncContext) public void SendMsgToGroupChat(string msg, AsyncCBHandler asyncDelegate, object asyncContext)
{ {
var cc = asyncContext as WSCF.RevCtrl.CC; var cc = asyncContext as WSCF.CC;
var customerContext = customerContexts.Find(c => c.revCtrl_Proxy == cc.revCtrl_Proxy); var customerContext = customerContexts.Find(c => c.revCtrl_Proxy == cc.proxy);
if (customerContext == null) { if (customerContext == null) {
//异常,居然之前没有记录 //异常,居然之前没有记录
throw new Exception("有人在群聊,居然之前没有记录"); throw new Exception("有人在群聊,居然之前没有记录");
...@@ -56,8 +56,8 @@ namespace WSCF.RevCtrl.Test.Server ...@@ -56,8 +56,8 @@ namespace WSCF.RevCtrl.Test.Server
public void SendMsgToPrivateChat(string targetGuid, string msg, AsyncCBHandler asyncDelegate, object asyncContext) public void SendMsgToPrivateChat(string targetGuid, string msg, AsyncCBHandler asyncDelegate, object asyncContext)
{ {
var cc = asyncContext as WSCF.RevCtrl.CC; var cc = asyncContext as WSCF.CC;
var customerContext = customerContexts.Find(c => c.revCtrl_Proxy == cc.revCtrl_Proxy); var customerContext = customerContexts.Find(c => c.revCtrl_Proxy == cc.proxy);
if (customerContext == null) if (customerContext == null)
{ {
//异常,居然之前没有记录 //异常,居然之前没有记录
...@@ -80,10 +80,10 @@ namespace WSCF.RevCtrl.Test.Server ...@@ -80,10 +80,10 @@ namespace WSCF.RevCtrl.Test.Server
asyncDelegate?.Invoke(asyncContext, new SendMsgToPrivateChatReponse() { isSuccess = true }); asyncDelegate?.Invoke(asyncContext, new SendMsgToPrivateChatReponse() { isSuccess = true });
} }
public void OnOpen(RevCtrl_Proxy behavior) public void OnOpen(RevCtrl_Proxy proxy)
{ {
//有人上线了 //有人上线了
var customerContext = customerContexts.Find(cc => cc.revCtrl_Proxy == behavior); var customerContext = customerContexts.Find(cc => cc.revCtrl_Proxy == proxy);
if (customerContext == null) if (customerContext == null)
{ {
//这是个新顾客 //这是个新顾客
...@@ -101,13 +101,13 @@ namespace WSCF.RevCtrl.Test.Server ...@@ -101,13 +101,13 @@ namespace WSCF.RevCtrl.Test.Server
updateCustomerInfos(); updateCustomerInfos();
} }
}; };
behavior.AddClient("Customer", customer); proxy.AddClient("Customer", customer);
//记录这个顾客的上下文 //记录这个顾客的上下文
customerContext = new CustomerContext() customerContext = new CustomerContext()
{ {
revCtrl_Proxy = behavior, revCtrl_Proxy = proxy,
customer = customer, customer = customer,
guid = Guid.NewGuid().ToString() guid = Guid.NewGuid().ToString()
}; };
...@@ -140,10 +140,10 @@ namespace WSCF.RevCtrl.Test.Server ...@@ -140,10 +140,10 @@ namespace WSCF.RevCtrl.Test.Server
} }
public void OnClose(RevCtrl_Proxy behavior) public void OnClose(RevCtrl_Proxy proxy)
{ {
//有人下线了 //有人下线了
var customerContext = customerContexts.Find(cc => cc.revCtrl_Proxy == behavior); var customerContext = customerContexts.Find(cc => cc.revCtrl_Proxy == proxy);
if (customerContext == null) if (customerContext == null)
{ {
//异常,居然之前没有记录 //异常,居然之前没有记录
...@@ -159,9 +159,9 @@ namespace WSCF.RevCtrl.Test.Server ...@@ -159,9 +159,9 @@ namespace WSCF.RevCtrl.Test.Server
} }
} }
public void OnDispose(RevCtrl_Proxy behavior) public void OnDispose(RevCtrl_Proxy proxy)
{ {
OnClose(behavior); OnClose(proxy);
} }
} }
......
...@@ -7,7 +7,7 @@ using WSCF.RevCtrl.Test.IService; ...@@ -7,7 +7,7 @@ using WSCF.RevCtrl.Test.IService;
namespace WSCF.RevCtrl.Test.Server.ServiceClient namespace WSCF.RevCtrl.Test.Server.ServiceClient
{ {
public class CustomerServiceClient: WsSeviceClient,ICustomerService public class CustomerServiceClient: WsServiceClient,ICustomerService
{ {
protected override Type InterfaceType => typeof(ICustomerService); protected override Type InterfaceType => typeof(ICustomerService);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<PackageProjectUrl>http://private.flyautomation.net:82/panruising/wscf</PackageProjectUrl> <PackageProjectUrl>http://private.flyautomation.net:82/panruising/wscf</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>2.0.1</Version> <Version>2.1.0</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
<Compile Include="..\WSCF\Reflect_Proxy.cs" Link="Reflect_Proxy.cs" /> <Compile Include="..\WSCF\Reflect_Proxy.cs" Link="Reflect_Proxy.cs" />
<Compile Include="..\WSCF\Reflect_SeviceClient.cs" Link="Reflect_SeviceClient.cs" /> <Compile Include="..\WSCF\Reflect_SeviceClient.cs" Link="Reflect_SeviceClient.cs" />
<Compile Include="..\WSCF\WebSocketClient.cs" Link="WebSocketClient.cs" /> <Compile Include="..\WSCF\WebSocketClient.cs" Link="WebSocketClient.cs" />
<Compile Include="..\WSCF\ReflectSeviceClientCore.cs" Link="ReflectSeviceClientCore.cs" /> <Compile Include="..\WSCF\IReflectSeviceClientCore.cs" Link="IReflectSeviceClientCore.cs" />
<Compile Include="..\WSCF\WsServiceProxy.cs" Link="WsServiceProxy.cs" />
<Compile Include="..\WSCF\WsServiceClient.cs" Link="WsServiceClient.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
...@@ -35,4 +37,10 @@ ...@@ -35,4 +37,10 @@
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" /> <PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="..\WSCF\RevCtrl\IRevCtrlAdmin.cs" Link="RevCtrl\IRevCtrlAdmin.cs" />
<Compile Include="..\WSCF\RevCtrl\RevCtrl_Proxy.cs" Link="RevCtrl\RevCtrl_Proxy.cs" />
<Compile Include="..\WSCF\RevCtrl\RevCtrl_ServiceClient.cs" Link="RevCtrl\RevCtrl_ServiceClient.cs" />
</ItemGroup>
</Project> </Project>
...@@ -27,7 +27,7 @@ namespace WSCF ...@@ -27,7 +27,7 @@ namespace WSCF
bool IsInPushValue { get; set; } bool IsInPushValue { get; set; }
} }
public class ReflectSeviceClientAssistant: IDisposable class ReflectSeviceClientAssistant: IDisposable
{ {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
......
...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; ...@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1.0")] [assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.0.1.0")] [assembly: AssemblyFileVersion("2.1.0.0")]
This diff is collapsed.
...@@ -11,9 +11,10 @@ namespace WSCF.RevCtrl ...@@ -11,9 +11,10 @@ namespace WSCF.RevCtrl
/// </summary> /// </summary>
public interface IRevCtrlAdmin public interface IRevCtrlAdmin
{ {
void OnOpen(RevCtrl_Proxy revCtrl_Proxy); void OnOpen(RevCtrl_Proxy proxy);
void OnClose(RevCtrl_Proxy revCtrl_Proxy);
void OnDispose(RevCtrl_Proxy revCtrl_Proxy); void OnClose(RevCtrl_Proxy proxy);
void OnDispose(RevCtrl_Proxy proxy);
} }
} }
...@@ -10,21 +10,16 @@ using static WSCF.Reflect_OBJ_INTERFACE; ...@@ -10,21 +10,16 @@ using static WSCF.Reflect_OBJ_INTERFACE;
namespace WSCF.RevCtrl namespace WSCF.RevCtrl
{ {
public class RevCtrl_Proxy : WebSocketBehavior, IDisposable public class RevCtrl_Proxy : Reflect_Proxy
{ {
public event PropertyChangedEventHandler PropertyChanged; public bool IsConnected { get; private set; }
public bool IsConnected { get; set; }
/// <summary>
/// 服务器中, 提供的全部服务
/// </summary>
WsServiceProxy Proxy;
IRevCtrlAdmin admin; IRevCtrlAdmin admin;
/// <summary> /// <summary>
/// 服务器中,反向控制客户端,对于客户端每个服务的客户端 /// 服务器中,反向控制客户端,对于客户端每个服务的客户端
/// </summary> /// </summary>
Dictionary<string, WsSeviceClient> Clients = new Dictionary<string, WsSeviceClient>(); Dictionary<string, WsServiceClient> Clients = new Dictionary<string, WsServiceClient>();
public RevCtrl_Proxy() public RevCtrl_Proxy()
...@@ -34,10 +29,7 @@ namespace WSCF.RevCtrl ...@@ -34,10 +29,7 @@ namespace WSCF.RevCtrl
public void Init(Type interfaceType, IRevCtrlAdmin admin) public void Init(Type interfaceType, IRevCtrlAdmin admin)
{ {
this.admin = admin; this.admin = admin;
var proxy = new WsServiceProxy(); base.Init(interfaceType, admin);
proxy.Init(interfaceType, admin);
proxy.SetSendEx(SendTo, null);
Proxy = proxy;
} }
protected override void OnOpen() protected override void OnOpen()
...@@ -102,14 +94,14 @@ namespace WSCF.RevCtrl ...@@ -102,14 +94,14 @@ namespace WSCF.RevCtrl
public void SendTo(string msg) public override void SendTo(string msg)
{ {
if (IsConnected == false) if (IsConnected == false)
return; return;
base.Send(msg); base.Send(msg);
} }
public void AddClient(string serviceName, WsSeviceClient client) public void AddClient(string serviceName, WsServiceClient client)
{ {
client.SetSendEx(SendTo, serviceName); client.SetSendEx(SendTo, serviceName);
Clients.Add(serviceName, client); Clients.Add(serviceName, client);
...@@ -119,12 +111,5 @@ namespace WSCF.RevCtrl ...@@ -119,12 +111,5 @@ namespace WSCF.RevCtrl
} }
} }
public void Dispose()
{
//TODO
//卸载全部
//Proxys, 与 Clients
}
} }
} }
...@@ -56,6 +56,5 @@ namespace WSCF.RevCtrl ...@@ -56,6 +56,5 @@ namespace WSCF.RevCtrl
proxy.OnMessage(null, pkgData); proxy.OnMessage(null, pkgData);
} }
} }
} }
} }
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<Compile Include="RevCtrl\RevCtrl_ServiceClient.cs" /> <Compile Include="RevCtrl\RevCtrl_ServiceClient.cs" />
<Compile Include="RevCtrl\RevCtrl_Proxy.cs" /> <Compile Include="RevCtrl\RevCtrl_Proxy.cs" />
<Compile Include="RevCtrl\IRevCtrlAdmin.cs" /> <Compile Include="RevCtrl\IRevCtrlAdmin.cs" />
<Compile Include="WsSeviceClient.cs" /> <Compile Include="WsServiceClient.cs" />
<Compile Include="WsServiceProxy.cs" /> <Compile Include="WsServiceProxy.cs" />
<Compile Include="CallAttribute.cs" /> <Compile Include="CallAttribute.cs" />
<Compile Include="COMMON.cs" /> <Compile Include="COMMON.cs" />
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<Compile Include="Reflect_Proxy.cs" /> <Compile Include="Reflect_Proxy.cs" />
<Compile Include="Reflect_SeviceClient.cs" /> <Compile Include="Reflect_SeviceClient.cs" />
<Compile Include="WebSocketClient.cs" /> <Compile Include="WebSocketClient.cs" />
<Compile Include="ReflectSeviceClientCore.cs" /> <Compile Include="IReflectSeviceClientCore.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
......
...@@ -11,7 +11,7 @@ using System.Threading.Tasks; ...@@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace WSCF.RevCtrl namespace WSCF.RevCtrl
{ {
public abstract class WsSeviceClient : IReflectSeviceClientCore public abstract class WsServiceClient : IReflectSeviceClientCore
{ {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
...@@ -38,7 +38,7 @@ namespace WSCF.RevCtrl ...@@ -38,7 +38,7 @@ namespace WSCF.RevCtrl
ReflectSeviceClientAssistant assistant; ReflectSeviceClientAssistant assistant;
public WsSeviceClient() public WsServiceClient()
{ {
assistant = new ReflectSeviceClientAssistant(); assistant = new ReflectSeviceClientAssistant();
assistant.Init(InterfaceType, this); assistant.Init(InterfaceType, this);
......
...@@ -5,11 +5,9 @@ using System.Collections.Generic; ...@@ -5,11 +5,9 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using WebSocketSharp;
using WebSocketSharp.Server;
using static WSCF.Reflect_OBJ_INTERFACE; using static WSCF.Reflect_OBJ_INTERFACE;
namespace WSCF.RevCtrl namespace WSCF
{ {
/// <summary> /// <summary>
/// obj 服务代理; /// obj 服务代理;
...@@ -227,7 +225,7 @@ namespace WSCF.RevCtrl ...@@ -227,7 +225,7 @@ namespace WSCF.RevCtrl
//ignoreSet = false; //ignoreSet = false;
} }
void request_CALL_MethodInvoke(ReflectData rData, string guid, RevCtrl_Proxy revCtrl_Proxy) void request_CALL_MethodInvoke(ReflectData rData, string guid, Reflect_Proxy proxy)
{ {
var type = obj.GetType(); var type = obj.GetType();
var paramNames_req = rData.data.Children().OfType<JProperty>().Select(p => p.Name); var paramNames_req = rData.data.Children().OfType<JProperty>().Select(p => p.Name);
...@@ -250,7 +248,7 @@ namespace WSCF.RevCtrl ...@@ -250,7 +248,7 @@ namespace WSCF.RevCtrl
} }
else if (string.Compare(pname, Reflect_OBJ_INTERFACE.paramName_asyncContext, true) == 0) else if (string.Compare(pname, Reflect_OBJ_INTERFACE.paramName_asyncContext, true) == 0)
{ {
parameters[i] = new CC() { revCtrl_Proxy = revCtrl_Proxy, guid = guid, methodName = rData.name }; parameters[i] = new CC() { proxy = proxy, guid = guid, methodName = rData.name };
} }
else else
{ {
...@@ -368,7 +366,7 @@ namespace WSCF.RevCtrl ...@@ -368,7 +366,7 @@ namespace WSCF.RevCtrl
#region WsService 调用 #region WsService 调用
public void OnMessage(RevCtrl_Proxy revCtrl_Proxy, PkgData pkgData) public void OnMessage(Reflect_Proxy proxy, PkgData pkgData)
{ {
var pkgName = Enum.Parse(typeof(PkgName), pkgData.name); var pkgName = Enum.Parse(typeof(PkgName), pkgData.name);
switch (pkgName) switch (pkgName)
...@@ -392,7 +390,7 @@ namespace WSCF.RevCtrl ...@@ -392,7 +390,7 @@ namespace WSCF.RevCtrl
{ {
var rData = pkgData.data.ToObject<ReflectData>(); var rData = pkgData.data.ToObject<ReflectData>();
request_CALL_MethodInvoke(rData, pkgData.guid, revCtrl_Proxy); request_CALL_MethodInvoke(rData, pkgData.guid, proxy);
} }
break; break;
...@@ -430,7 +428,7 @@ namespace WSCF.RevCtrl ...@@ -430,7 +428,7 @@ namespace WSCF.RevCtrl
/// <summary> /// <summary>
/// json包装后的ReflectData 推送 /// json包装后的ReflectData 推送
/// </summary> /// </summary>
public Action<Reflect_OBJ_INTERFACE.ReflectData> PushObjInfoEx; public Action<ReflectData> PushObjInfoEx;
/// <summary> /// <summary>
/// 给 EventInfo 调用 /// 给 EventInfo 调用
/// </summary> /// </summary>
...@@ -441,7 +439,7 @@ namespace WSCF.RevCtrl ...@@ -441,7 +439,7 @@ namespace WSCF.RevCtrl
} }
void Obj_AnyEvent(object sender, EventArgs e) void Obj_AnyEvent(object sender, EventArgs e)
{ {
var rData = new Reflect_OBJ_INTERFACE.ReflectData() var rData = new ReflectData()
{ {
name = eventName, name = eventName,
data = JObject.FromObject(e) data = JObject.FromObject(e)
...@@ -455,7 +453,8 @@ namespace WSCF.RevCtrl ...@@ -455,7 +453,8 @@ namespace WSCF.RevCtrl
/// <summary> /// <summary>
/// 连接 /// 连接
/// </summary> /// </summary>
public RevCtrl_Proxy revCtrl_Proxy; public Reflect_Proxy proxy;
public string guid; public string guid;
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment