Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
W
WSCF
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
WSCF
Commits
0ca05810
Commit
0ca05810
authored
Nov 11, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 RevCtrl_Proxy 继承于 Reflect_Proxy, 全部 代理服务逻辑写再 WsServiceProxy
parent
1b3c276f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
66 additions
and
469 deletions
+66
-469
Chat.cs
RevCtrl.Test/WSCF.RevCtrl.Test.Server/Chat.cs
+12
-12
CustomerServiceClient.cs
...evCtrl.Test.Server/ServiceClient/CustomerServiceClient.cs
+1
-1
WSCF.standard.csproj
WSCF.standard/WSCF.standard.csproj
+10
-2
IReflectSeviceClientCore.cs
WSCF/IReflectSeviceClientCore.cs
+1
-1
AssemblyInfo.cs
WSCF/Properties/AssemblyInfo.cs
+2
-2
Reflect_Proxy.cs
WSCF/Reflect_Proxy.cs
+17
-412
IRevCtrlAdmin.cs
WSCF/RevCtrl/IRevCtrlAdmin.cs
+4
-3
RevCtrl_Proxy.cs
WSCF/RevCtrl/RevCtrl_Proxy.cs
+6
-21
RevCtrl_ServiceClient.cs
WSCF/RevCtrl/RevCtrl_ServiceClient.cs
+0
-1
WSCF.csproj
WSCF/WSCF.csproj
+2
-2
WsServiceClient.cs
WSCF/WsServiceClient.cs
+2
-2
WsServiceProxy.cs
WSCF/WsServiceProxy.cs
+9
-10
No files found.
RevCtrl.Test/WSCF.RevCtrl.Test.Server/Chat.cs
View file @
0ca05810
...
...
@@ -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_P
roxy
);
var
cc
=
asyncContext
as
WSCF
.
CC
;
var
customerContext
=
customerContexts
.
Find
(
c
=>
c
.
revCtrl_Proxy
==
cc
.
p
roxy
);
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_P
roxy
);
var
cc
=
asyncContext
as
WSCF
.
CC
;
var
customerContext
=
customerContexts
.
Find
(
c
=>
c
.
revCtrl_Proxy
==
cc
.
p
roxy
);
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
);
}
}
...
...
RevCtrl.Test/WSCF.RevCtrl.Test.Server/ServiceClient/CustomerServiceClient.cs
View file @
0ca05810
...
...
@@ -7,7 +7,7 @@ using WSCF.RevCtrl.Test.IService;
namespace
WSCF.RevCtrl.Test.Server.ServiceClient
{
public
class
CustomerServiceClient
:
WsSeviceClient
,
ICustomerService
public
class
CustomerServiceClient
:
WsSe
r
viceClient
,
ICustomerService
{
protected
override
Type
InterfaceType
=>
typeof
(
ICustomerService
);
...
...
WSCF.standard/WSCF.standard.csproj
View file @
0ca05810
...
...
@@ -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>
WSCF/ReflectSeviceClientCore.cs
→
WSCF/
I
ReflectSeviceClientCore.cs
View file @
0ca05810
...
...
@@ -27,7 +27,7 @@ namespace WSCF
bool
IsInPushValue
{
get
;
set
;
}
}
public
class
ReflectSeviceClientAssistant
:
IDisposable
class
ReflectSeviceClientAssistant
:
IDisposable
{
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
WSCF/Properties/AssemblyInfo.cs
View file @
0ca05810
...
...
@@ -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")]
WSCF/Reflect_Proxy.cs
View file @
0ca05810
This diff is collapsed.
Click to expand it.
WSCF/RevCtrl/IRevCtrlAdmin.cs
View file @
0ca05810
...
...
@@ -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
);
}
}
WSCF/RevCtrl/RevCtrl_Proxy.cs
View file @
0ca05810
...
...
@@ -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
,
WsSe
viceClient
>
Clients
=
new
Dictionary
<
string
,
WsSe
viceClient
>();
Dictionary
<
string
,
WsSe
rviceClient
>
Clients
=
new
Dictionary
<
string
,
WsSer
viceClient
>();
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
,
WsSe
r
viceClient
client
)
{
client
.
SetSendEx
(
SendTo
,
serviceName
);
Clients
.
Add
(
serviceName
,
client
);
...
...
@@ -119,12 +111,5 @@ namespace WSCF.RevCtrl
}
}
public
void
Dispose
()
{
//TODO
//卸载全部
//Proxys, 与 Clients
}
}
}
WSCF/RevCtrl/RevCtrl_ServiceClient.cs
View file @
0ca05810
...
...
@@ -56,6 +56,5 @@ namespace WSCF.RevCtrl
proxy
.
OnMessage
(
null
,
pkgData
);
}
}
}
}
WSCF/WSCF.csproj
View file @
0ca05810
...
...
@@ -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=
"WsSe
r
viceClient.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=
"
I
ReflectSeviceClientCore.cs"
/>
</ItemGroup>
<ItemGroup>
<PackageReference
Include=
"Newtonsoft.Json"
>
...
...
WSCF/WsSeviceClient.cs
→
WSCF/WsSe
r
viceClient.cs
View file @
0ca05810
...
...
@@ -11,7 +11,7 @@ using System.Threading.Tasks;
namespace
WSCF.RevCtrl
{
public
abstract
class
WsSeviceClient
:
IReflectSeviceClientCore
public
abstract
class
WsSe
r
viceClient
:
IReflectSeviceClientCore
{
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
@@ -38,7 +38,7 @@ namespace WSCF.RevCtrl
ReflectSeviceClientAssistant
assistant
;
public
WsSeviceClient
()
public
WsSe
r
viceClient
()
{
assistant
=
new
ReflectSeviceClientAssistant
();
assistant
.
Init
(
InterfaceType
,
this
);
...
...
WSCF/WsServiceProxy.cs
View file @
0ca05810
...
...
@@ -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
,
Re
vCtrl_Proxy
revCtrl_P
roxy
)
void
request_CALL_MethodInvoke
(
ReflectData
rData
,
string
guid
,
Re
flect_Proxy
p
roxy
)
{
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_P
roxy
,
guid
=
guid
,
methodName
=
rData
.
name
};
parameters
[
i
]
=
new
CC
()
{
proxy
=
p
roxy
,
guid
=
guid
,
methodName
=
rData
.
name
};
}
else
{
...
...
@@ -368,7 +366,7 @@ namespace WSCF.RevCtrl
#
region
被
WsService
调用
public
void
OnMessage
(
Re
vCtrl_Proxy
revCtrl_P
roxy
,
PkgData
pkgData
)
public
void
OnMessage
(
Re
flect_Proxy
p
roxy
,
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_P
roxy
);
request_CALL_MethodInvoke
(
rData
,
pkgData
.
guid
,
p
roxy
);
}
break
;
...
...
@@ -430,7 +428,7 @@ namespace WSCF.RevCtrl
/// <summary>
/// json包装后的ReflectData 推送
/// </summary>
public
Action
<
Reflect
_OBJ_INTERFACE
.
Reflect
Data
>
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
.
Reflect
Data
()
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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment