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

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

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