diff --git a/examples/Adapter/AdapterConsoleApp/AdapterConsoleApp.csproj b/examples/Adapter/AdapterConsoleApp/AdapterConsoleApp.csproj index a6225d6b3..c26f0f9a5 100644 --- a/examples/Adapter/AdapterConsoleApp/AdapterConsoleApp.csproj +++ b/examples/Adapter/AdapterConsoleApp/AdapterConsoleApp.csproj @@ -6,6 +6,6 @@ - + diff --git a/examples/Adapter/AdapterTesterConsoleApp/AdapterTesterConsoleApp.csproj b/examples/Adapter/AdapterTesterConsoleApp/AdapterTesterConsoleApp.csproj index 68d4f239d..63420765e 100644 --- a/examples/Adapter/AdapterTesterConsoleApp/AdapterTesterConsoleApp.csproj +++ b/examples/Adapter/AdapterTesterConsoleApp/AdapterTesterConsoleApp.csproj @@ -7,6 +7,6 @@ - + diff --git a/examples/Adapter/BetweenAndConsoleApp/BetweenAndConsoleApp.csproj b/examples/Adapter/BetweenAndConsoleApp/BetweenAndConsoleApp.csproj index f15f06266..c14a1bc83 100644 --- a/examples/Adapter/BetweenAndConsoleApp/BetweenAndConsoleApp.csproj +++ b/examples/Adapter/BetweenAndConsoleApp/BetweenAndConsoleApp.csproj @@ -9,6 +9,6 @@ - + diff --git a/examples/Adapter/BetweenAndConsoleApp/Program.cs b/examples/Adapter/BetweenAndConsoleApp/Program.cs index 1438c4582..15059a45a 100644 --- a/examples/Adapter/BetweenAndConsoleApp/Program.cs +++ b/examples/Adapter/BetweenAndConsoleApp/Program.cs @@ -82,16 +82,8 @@ namespace BetweenAndConsoleApp } } - /// - /// 以**12##12##,Min=5为例。 - /// class MyBetweenAndRequestInfo : IRequestInfo { - public MyBetweenAndRequestInfo() - { - - } - public MyBetweenAndRequestInfo(byte[] body) { this.Body = body; diff --git a/examples/Adapter/CustomAdapterConsoleApp/CustomAdapterConsoleApp.csproj b/examples/Adapter/CustomAdapterConsoleApp/CustomAdapterConsoleApp.csproj index 1f72dce3c..14f26ed09 100644 --- a/examples/Adapter/CustomAdapterConsoleApp/CustomAdapterConsoleApp.csproj +++ b/examples/Adapter/CustomAdapterConsoleApp/CustomAdapterConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/CustomBigFixedHeaderConsoleApp/CustomBigFixedHeaderConsoleApp.csproj b/examples/Adapter/CustomBigFixedHeaderConsoleApp/CustomBigFixedHeaderConsoleApp.csproj index ac7994f8e..2eb5d1559 100644 --- a/examples/Adapter/CustomBigFixedHeaderConsoleApp/CustomBigFixedHeaderConsoleApp.csproj +++ b/examples/Adapter/CustomBigFixedHeaderConsoleApp/CustomBigFixedHeaderConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/CustomBigUnfixedHeaderConsoleApp/CustomBigUnfixedHeaderConsoleApp.csproj b/examples/Adapter/CustomBigUnfixedHeaderConsoleApp/CustomBigUnfixedHeaderConsoleApp.csproj index de6c6067d..75a6c6bb8 100644 --- a/examples/Adapter/CustomBigUnfixedHeaderConsoleApp/CustomBigUnfixedHeaderConsoleApp.csproj +++ b/examples/Adapter/CustomBigUnfixedHeaderConsoleApp/CustomBigUnfixedHeaderConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/CustomCountSpliterDataHandlingAdapterConsoleApp/CustomCountSpliterDataHandlingAdapterConsoleApp.csproj b/examples/Adapter/CustomCountSpliterDataHandlingAdapterConsoleApp/CustomCountSpliterDataHandlingAdapterConsoleApp.csproj index 2c23b1168..2fa3896f8 100644 --- a/examples/Adapter/CustomCountSpliterDataHandlingAdapterConsoleApp/CustomCountSpliterDataHandlingAdapterConsoleApp.csproj +++ b/examples/Adapter/CustomCountSpliterDataHandlingAdapterConsoleApp/CustomCountSpliterDataHandlingAdapterConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/CustomFixedHeaderConsoleApp/CustomFixedHeaderConsoleApp.csproj b/examples/Adapter/CustomFixedHeaderConsoleApp/CustomFixedHeaderConsoleApp.csproj index ac7994f8e..2eb5d1559 100644 --- a/examples/Adapter/CustomFixedHeaderConsoleApp/CustomFixedHeaderConsoleApp.csproj +++ b/examples/Adapter/CustomFixedHeaderConsoleApp/CustomFixedHeaderConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/CustomJsonDataHandlingAdapterConsoleApp/CustomJsonDataHandlingAdapterConsoleApp.csproj b/examples/Adapter/CustomJsonDataHandlingAdapterConsoleApp/CustomJsonDataHandlingAdapterConsoleApp.csproj index 2c23b1168..2fa3896f8 100644 --- a/examples/Adapter/CustomJsonDataHandlingAdapterConsoleApp/CustomJsonDataHandlingAdapterConsoleApp.csproj +++ b/examples/Adapter/CustomJsonDataHandlingAdapterConsoleApp/CustomJsonDataHandlingAdapterConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/CustomUnfixedHeaderConsoleApp/CustomUnfixedHeaderConsoleApp.csproj b/examples/Adapter/CustomUnfixedHeaderConsoleApp/CustomUnfixedHeaderConsoleApp.csproj index 3640316ef..bb1cf3615 100644 --- a/examples/Adapter/CustomUnfixedHeaderConsoleApp/CustomUnfixedHeaderConsoleApp.csproj +++ b/examples/Adapter/CustomUnfixedHeaderConsoleApp/CustomUnfixedHeaderConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Adapter/JsonPackageAdapterConsoleApp/JsonPackageAdapterConsoleApp.csproj b/examples/Adapter/JsonPackageAdapterConsoleApp/JsonPackageAdapterConsoleApp.csproj index 1f72dce3c..14f26ed09 100644 --- a/examples/Adapter/JsonPackageAdapterConsoleApp/JsonPackageAdapterConsoleApp.csproj +++ b/examples/Adapter/JsonPackageAdapterConsoleApp/JsonPackageAdapterConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/PackageAdapterConsoleApp/PackageAdapterConsoleApp.csproj b/examples/Adapter/PackageAdapterConsoleApp/PackageAdapterConsoleApp.csproj index de6c6067d..75a6c6bb8 100644 --- a/examples/Adapter/PackageAdapterConsoleApp/PackageAdapterConsoleApp.csproj +++ b/examples/Adapter/PackageAdapterConsoleApp/PackageAdapterConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Adapter/TLVWinFormsApp/TLVWinFormsApp.csproj b/examples/Adapter/TLVWinFormsApp/TLVWinFormsApp.csproj index 32e5f0051..983316d30 100644 --- a/examples/Adapter/TLVWinFormsApp/TLVWinFormsApp.csproj +++ b/examples/Adapter/TLVWinFormsApp/TLVWinFormsApp.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/examples/BlogsDemos/AccessRestrictionsConsoleApp/AccessRestrictionsConsoleApp.csproj b/examples/BlogsDemos/AccessRestrictionsConsoleApp/AccessRestrictionsConsoleApp.csproj index 433af7fe5..f3cefad86 100644 --- a/examples/BlogsDemos/AccessRestrictionsConsoleApp/AccessRestrictionsConsoleApp.csproj +++ b/examples/BlogsDemos/AccessRestrictionsConsoleApp/AccessRestrictionsConsoleApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/examples/BlogsDemos/DifferentProtocolConsoleApp/DifferentProtocolConsoleApp.csproj b/examples/BlogsDemos/DifferentProtocolConsoleApp/DifferentProtocolConsoleApp.csproj index 433af7fe5..f3cefad86 100644 --- a/examples/BlogsDemos/DifferentProtocolConsoleApp/DifferentProtocolConsoleApp.csproj +++ b/examples/BlogsDemos/DifferentProtocolConsoleApp/DifferentProtocolConsoleApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/examples/BlogsDemos/HeartbeatConsoleApp/HeartbeatConsoleApp.csproj b/examples/BlogsDemos/HeartbeatConsoleApp/HeartbeatConsoleApp.csproj index 5a429cd4d..e51514650 100644 --- a/examples/BlogsDemos/HeartbeatConsoleApp/HeartbeatConsoleApp.csproj +++ b/examples/BlogsDemos/HeartbeatConsoleApp/HeartbeatConsoleApp.csproj @@ -6,6 +6,6 @@ - + diff --git a/examples/BlogsDemos/LimitNumberOfConnectionsConsoleApp/LimitNumberOfConnectionsConsoleApp.csproj b/examples/BlogsDemos/LimitNumberOfConnectionsConsoleApp/LimitNumberOfConnectionsConsoleApp.csproj index fd80e9dc6..ab4b24665 100644 --- a/examples/BlogsDemos/LimitNumberOfConnectionsConsoleApp/LimitNumberOfConnectionsConsoleApp.csproj +++ b/examples/BlogsDemos/LimitNumberOfConnectionsConsoleApp/LimitNumberOfConnectionsConsoleApp.csproj @@ -6,12 +6,12 @@ - - - - - - + + + + + + diff --git a/examples/BlogsDemos/ThrottlingConsoleApp/ThrottlingConsoleApp.csproj b/examples/BlogsDemos/ThrottlingConsoleApp/ThrottlingConsoleApp.csproj index fd80e9dc6..ab4b24665 100644 --- a/examples/BlogsDemos/ThrottlingConsoleApp/ThrottlingConsoleApp.csproj +++ b/examples/BlogsDemos/ThrottlingConsoleApp/ThrottlingConsoleApp.csproj @@ -6,12 +6,12 @@ - - - - - - + + + + + + diff --git a/examples/BlogsDemos/TrafficCounterConsoleApp/TrafficCounterConsoleApp.csproj b/examples/BlogsDemos/TrafficCounterConsoleApp/TrafficCounterConsoleApp.csproj index 6aa7c5ce8..88d38bce3 100644 --- a/examples/BlogsDemos/TrafficCounterConsoleApp/TrafficCounterConsoleApp.csproj +++ b/examples/BlogsDemos/TrafficCounterConsoleApp/TrafficCounterConsoleApp.csproj @@ -6,11 +6,11 @@ - - - - - - + + + + + + diff --git a/examples/Consul集群示例/ConsulConsoleApp/ConsulConsoleApp.csproj b/examples/Consul集群示例/ConsulConsoleApp/ConsulConsoleApp.csproj index ac879b994..2442add49 100644 --- a/examples/Consul集群示例/ConsulConsoleApp/ConsulConsoleApp.csproj +++ b/examples/Consul集群示例/ConsulConsoleApp/ConsulConsoleApp.csproj @@ -7,12 +7,12 @@ - - - - - - + + + + + + diff --git a/examples/Consul集群示例/TouchRpc Consul集群/ServiceConsoleApp/ServiceConsoleApp.csproj b/examples/Consul集群示例/TouchRpc Consul集群/ServiceConsoleApp/ServiceConsoleApp.csproj index ac879b994..2442add49 100644 --- a/examples/Consul集群示例/TouchRpc Consul集群/ServiceConsoleApp/ServiceConsoleApp.csproj +++ b/examples/Consul集群示例/TouchRpc Consul集群/ServiceConsoleApp/ServiceConsoleApp.csproj @@ -7,12 +7,12 @@ - - - - - - + + + + + + diff --git a/examples/Consul集群示例/TouchRpc Consul集群/WinFormsApp/WinFormsApp.csproj b/examples/Consul集群示例/TouchRpc Consul集群/WinFormsApp/WinFormsApp.csproj index 031bb5c20..7998c363a 100644 --- a/examples/Consul集群示例/TouchRpc Consul集群/WinFormsApp/WinFormsApp.csproj +++ b/examples/Consul集群示例/TouchRpc Consul集群/WinFormsApp/WinFormsApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/examples/Core/AppMessengerWinApp/AppMessengerWinApp.csproj b/examples/Core/AppMessengerWinApp/AppMessengerWinApp.csproj index a85f51a07..fb453f930 100644 --- a/examples/Core/AppMessengerWinApp/AppMessengerWinApp.csproj +++ b/examples/Core/AppMessengerWinApp/AppMessengerWinApp.csproj @@ -9,11 +9,11 @@ - - - - - + + + + + \ No newline at end of file diff --git a/examples/Core/BytePoolConsoleApp/BytePoolConsoleApp.csproj b/examples/Core/BytePoolConsoleApp/BytePoolConsoleApp.csproj index 2b71dff45..8069dcd29 100644 --- a/examples/Core/BytePoolConsoleApp/BytePoolConsoleApp.csproj +++ b/examples/Core/BytePoolConsoleApp/BytePoolConsoleApp.csproj @@ -5,11 +5,11 @@ net8.0 - - - - - - + + + + + + diff --git a/examples/Core/FastBinaryFormatterConsoleApp/FastBinaryFormatterConsoleApp.csproj b/examples/Core/FastBinaryFormatterConsoleApp/FastBinaryFormatterConsoleApp.csproj index 5e7bfcc85..1772a591a 100644 --- a/examples/Core/FastBinaryFormatterConsoleApp/FastBinaryFormatterConsoleApp.csproj +++ b/examples/Core/FastBinaryFormatterConsoleApp/FastBinaryFormatterConsoleApp.csproj @@ -17,6 +17,6 @@ --> - + diff --git a/examples/Core/IocConsoleApp/IocConsoleApp.csproj b/examples/Core/IocConsoleApp/IocConsoleApp.csproj index 579df45d2..42e6ee31f 100644 --- a/examples/Core/IocConsoleApp/IocConsoleApp.csproj +++ b/examples/Core/IocConsoleApp/IocConsoleApp.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/examples/Core/Log4netConsoleApp/Log4netConsoleApp.csproj b/examples/Core/Log4netConsoleApp/Log4netConsoleApp.csproj index f96562d8b..1c0ade50b 100644 --- a/examples/Core/Log4netConsoleApp/Log4netConsoleApp.csproj +++ b/examples/Core/Log4netConsoleApp/Log4netConsoleApp.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/examples/Core/LoggerConsoleApp/LoggerConsoleApp.csproj b/examples/Core/LoggerConsoleApp/LoggerConsoleApp.csproj index de6c6067d..75a6c6bb8 100644 --- a/examples/Core/LoggerConsoleApp/LoggerConsoleApp.csproj +++ b/examples/Core/LoggerConsoleApp/LoggerConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Core/PackageConsoleApp/PackageConsoleApp.csproj b/examples/Core/PackageConsoleApp/PackageConsoleApp.csproj index a38d41c6a..f7abe8e86 100644 --- a/examples/Core/PackageConsoleApp/PackageConsoleApp.csproj +++ b/examples/Core/PackageConsoleApp/PackageConsoleApp.csproj @@ -6,11 +6,11 @@ enable - - - - - - + + + + + + diff --git a/examples/Core/PluginConsoleApp/PluginConsoleApp.csproj b/examples/Core/PluginConsoleApp/PluginConsoleApp.csproj index bb1aefeae..85daffe5f 100644 --- a/examples/Core/PluginConsoleApp/PluginConsoleApp.csproj +++ b/examples/Core/PluginConsoleApp/PluginConsoleApp.csproj @@ -6,6 +6,6 @@ - + diff --git a/examples/Dmtp/CustomDmtpActorConsoleApp/CustomDmtpActorConsoleApp.csproj b/examples/Dmtp/CustomDmtpActorConsoleApp/CustomDmtpActorConsoleApp.csproj index 756418566..1bb88fbca 100644 --- a/examples/Dmtp/CustomDmtpActorConsoleApp/CustomDmtpActorConsoleApp.csproj +++ b/examples/Dmtp/CustomDmtpActorConsoleApp/CustomDmtpActorConsoleApp.csproj @@ -7,6 +7,6 @@ - + diff --git a/examples/Dmtp/DispatchProxyDmtpRpcConsoleApp/DispatchProxyDmtpRpcConsoleApp.csproj b/examples/Dmtp/DispatchProxyDmtpRpcConsoleApp/DispatchProxyDmtpRpcConsoleApp.csproj index ceb9f7292..45af7b475 100644 --- a/examples/Dmtp/DispatchProxyDmtpRpcConsoleApp/DispatchProxyDmtpRpcConsoleApp.csproj +++ b/examples/Dmtp/DispatchProxyDmtpRpcConsoleApp/DispatchProxyDmtpRpcConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Dmtp/DmtpAspnetcoreConsoleApp/DmtpAspnetcoreConsoleApp.csproj b/examples/Dmtp/DmtpAspnetcoreConsoleApp/DmtpAspnetcoreConsoleApp.csproj index 13155d36d..9e322ac0e 100644 --- a/examples/Dmtp/DmtpAspnetcoreConsoleApp/DmtpAspnetcoreConsoleApp.csproj +++ b/examples/Dmtp/DmtpAspnetcoreConsoleApp/DmtpAspnetcoreConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Dmtp/DmtpChannelConsoleApp/DmtpChannelConsoleApp.csproj b/examples/Dmtp/DmtpChannelConsoleApp/DmtpChannelConsoleApp.csproj index ceb9f7292..45af7b475 100644 --- a/examples/Dmtp/DmtpChannelConsoleApp/DmtpChannelConsoleApp.csproj +++ b/examples/Dmtp/DmtpChannelConsoleApp/DmtpChannelConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Dmtp/DmtpConsoleApp/DmtpConsoleApp.csproj b/examples/Dmtp/DmtpConsoleApp/DmtpConsoleApp.csproj index c9b8ef513..99b88966d 100644 --- a/examples/Dmtp/DmtpConsoleApp/DmtpConsoleApp.csproj +++ b/examples/Dmtp/DmtpConsoleApp/DmtpConsoleApp.csproj @@ -26,7 +26,7 @@ --> - + diff --git a/examples/Dmtp/DmtpConsoleApp/Program.cs b/examples/Dmtp/DmtpConsoleApp/Program.cs index a2f2eacef..c82110458 100644 --- a/examples/Dmtp/DmtpConsoleApp/Program.cs +++ b/examples/Dmtp/DmtpConsoleApp/Program.cs @@ -33,13 +33,7 @@ namespace DmtpConsoleApp await action.RunCommandLineAsync(); } - async Task Test() - { - - } - - - + private static void Action_OnException(Exception obj) { Console.WriteLine(obj.Message); diff --git a/examples/Dmtp/DmtpRedisConsoleApp/DmtpRedisConsoleApp.csproj b/examples/Dmtp/DmtpRedisConsoleApp/DmtpRedisConsoleApp.csproj index 13155d36d..9e322ac0e 100644 --- a/examples/Dmtp/DmtpRedisConsoleApp/DmtpRedisConsoleApp.csproj +++ b/examples/Dmtp/DmtpRedisConsoleApp/DmtpRedisConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Dmtp/DmtpRpcClientApp/DmtpRpcClientApp.csproj b/examples/Dmtp/DmtpRpcClientApp/DmtpRpcClientApp.csproj index 8afaf984a..f736e099b 100644 --- a/examples/Dmtp/DmtpRpcClientApp/DmtpRpcClientApp.csproj +++ b/examples/Dmtp/DmtpRpcClientApp/DmtpRpcClientApp.csproj @@ -6,11 +6,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/examples/Dmtp/DmtpRpcClientConsoleApp/DmtpRpcClientConsoleApp.csproj b/examples/Dmtp/DmtpRpcClientConsoleApp/DmtpRpcClientConsoleApp.csproj index a1655f984..a648d26df 100644 --- a/examples/Dmtp/DmtpRpcClientConsoleApp/DmtpRpcClientConsoleApp.csproj +++ b/examples/Dmtp/DmtpRpcClientConsoleApp/DmtpRpcClientConsoleApp.csproj @@ -12,6 +12,6 @@ - + diff --git a/examples/Dmtp/DmtpRpcServerConsoleApp/DmtpRpcServerConsoleApp.csproj b/examples/Dmtp/DmtpRpcServerConsoleApp/DmtpRpcServerConsoleApp.csproj index 13155d36d..9e322ac0e 100644 --- a/examples/Dmtp/DmtpRpcServerConsoleApp/DmtpRpcServerConsoleApp.csproj +++ b/examples/Dmtp/DmtpRpcServerConsoleApp/DmtpRpcServerConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Dmtp/DmtpWebApplication/DmtpWebApplication.csproj b/examples/Dmtp/DmtpWebApplication/DmtpWebApplication.csproj index ccda9e2e4..af8f1b3a8 100644 --- a/examples/Dmtp/DmtpWebApplication/DmtpWebApplication.csproj +++ b/examples/Dmtp/DmtpWebApplication/DmtpWebApplication.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/examples/Dmtp/FileTransferConsoleApp/FileTransferConsoleApp.csproj b/examples/Dmtp/FileTransferConsoleApp/FileTransferConsoleApp.csproj index 3b347689f..c95b2d237 100644 --- a/examples/Dmtp/FileTransferConsoleApp/FileTransferConsoleApp.csproj +++ b/examples/Dmtp/FileTransferConsoleApp/FileTransferConsoleApp.csproj @@ -35,6 +35,6 @@ --> - + diff --git a/examples/Dmtp/GeneratorRpcProxyConsoleApp/GeneratorRpcProxyConsoleApp.csproj b/examples/Dmtp/GeneratorRpcProxyConsoleApp/GeneratorRpcProxyConsoleApp.csproj index 1a96ad503..a9bd33108 100644 --- a/examples/Dmtp/GeneratorRpcProxyConsoleApp/GeneratorRpcProxyConsoleApp.csproj +++ b/examples/Dmtp/GeneratorRpcProxyConsoleApp/GeneratorRpcProxyConsoleApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/examples/Dmtp/NamedPipeDmtpConsoleApp/NamedPipeDmtpConsoleApp.csproj b/examples/Dmtp/NamedPipeDmtpConsoleApp/NamedPipeDmtpConsoleApp.csproj index dcf3465e3..2d7ef90d1 100644 --- a/examples/Dmtp/NamedPipeDmtpConsoleApp/NamedPipeDmtpConsoleApp.csproj +++ b/examples/Dmtp/NamedPipeDmtpConsoleApp/NamedPipeDmtpConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Dmtp/RealityProxyDmtpRpcConsoleApp/RealityProxyDmtpRpcConsoleApp.csproj b/examples/Dmtp/RealityProxyDmtpRpcConsoleApp/RealityProxyDmtpRpcConsoleApp.csproj index 44509dd66..17b19c84a 100644 --- a/examples/Dmtp/RealityProxyDmtpRpcConsoleApp/RealityProxyDmtpRpcConsoleApp.csproj +++ b/examples/Dmtp/RealityProxyDmtpRpcConsoleApp/RealityProxyDmtpRpcConsoleApp.csproj @@ -6,7 +6,7 @@ - + diff --git a/examples/Dmtp/RecommendRpcConsoleApp/RecommendRpcConsoleApp.csproj b/examples/Dmtp/RecommendRpcConsoleApp/RecommendRpcConsoleApp.csproj index 7afb11734..262851b5f 100644 --- a/examples/Dmtp/RecommendRpcConsoleApp/RecommendRpcConsoleApp.csproj +++ b/examples/Dmtp/RecommendRpcConsoleApp/RecommendRpcConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Dmtp/RemoteAccessApp/RemoteAccessApp.csproj b/examples/Dmtp/RemoteAccessApp/RemoteAccessApp.csproj index b1fb4aeb6..b7c1b456e 100644 --- a/examples/Dmtp/RemoteAccessApp/RemoteAccessApp.csproj +++ b/examples/Dmtp/RemoteAccessApp/RemoteAccessApp.csproj @@ -10,11 +10,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/examples/Dmtp/RemoteStreamConsoleApp/RemoteStreamConsoleApp.csproj b/examples/Dmtp/RemoteStreamConsoleApp/RemoteStreamConsoleApp.csproj index dcf3465e3..2d7ef90d1 100644 --- a/examples/Dmtp/RemoteStreamConsoleApp/RemoteStreamConsoleApp.csproj +++ b/examples/Dmtp/RemoteStreamConsoleApp/RemoteStreamConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Dmtp/ReverseRpcConsoleApp/ReverseRpcConsoleApp.csproj b/examples/Dmtp/ReverseRpcConsoleApp/ReverseRpcConsoleApp.csproj index e671266e1..e52e34dfe 100644 --- a/examples/Dmtp/ReverseRpcConsoleApp/ReverseRpcConsoleApp.csproj +++ b/examples/Dmtp/ReverseRpcConsoleApp/ReverseRpcConsoleApp.csproj @@ -6,11 +6,11 @@ - - - - - - + + + + + + diff --git a/examples/Dmtp/RouterPackageConsoleApp/RouterPackageConsoleApp.csproj b/examples/Dmtp/RouterPackageConsoleApp/RouterPackageConsoleApp.csproj index d2b825f75..ede0ce28b 100644 --- a/examples/Dmtp/RouterPackageConsoleApp/RouterPackageConsoleApp.csproj +++ b/examples/Dmtp/RouterPackageConsoleApp/RouterPackageConsoleApp.csproj @@ -7,6 +7,6 @@ - + diff --git a/examples/Dmtp/RpcClassLibrary/RpcClassLibrary.csproj b/examples/Dmtp/RpcClassLibrary/RpcClassLibrary.csproj index 9b994caa9..655b0f594 100644 --- a/examples/Dmtp/RpcClassLibrary/RpcClassLibrary.csproj +++ b/examples/Dmtp/RpcClassLibrary/RpcClassLibrary.csproj @@ -5,7 +5,7 @@ - + diff --git a/examples/Dmtp/RpcFactoryConsoleApp/RpcFactoryConsoleApp.csproj b/examples/Dmtp/RpcFactoryConsoleApp/RpcFactoryConsoleApp.csproj index 1a96ad503..a9bd33108 100644 --- a/examples/Dmtp/RpcFactoryConsoleApp/RpcFactoryConsoleApp.csproj +++ b/examples/Dmtp/RpcFactoryConsoleApp/RpcFactoryConsoleApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/examples/Dmtp/RpcImplementationClassLibrary/RpcImplementationClassLibrary.csproj b/examples/Dmtp/RpcImplementationClassLibrary/RpcImplementationClassLibrary.csproj index 450eeeb73..8c2f9aa92 100644 --- a/examples/Dmtp/RpcImplementationClassLibrary/RpcImplementationClassLibrary.csproj +++ b/examples/Dmtp/RpcImplementationClassLibrary/RpcImplementationClassLibrary.csproj @@ -5,7 +5,7 @@ - + diff --git a/examples/Dmtp/RpcStreamConsoleApp/RpcStreamConsoleApp.csproj b/examples/Dmtp/RpcStreamConsoleApp/RpcStreamConsoleApp.csproj index 433af7fe5..f3cefad86 100644 --- a/examples/Dmtp/RpcStreamConsoleApp/RpcStreamConsoleApp.csproj +++ b/examples/Dmtp/RpcStreamConsoleApp/RpcStreamConsoleApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/examples/Dmtp/SerializationSelectorClassLibrary/SerializationSelectorClassLibrary.csproj b/examples/Dmtp/SerializationSelectorClassLibrary/SerializationSelectorClassLibrary.csproj index 15b097938..9b68ba5b2 100644 --- a/examples/Dmtp/SerializationSelectorClassLibrary/SerializationSelectorClassLibrary.csproj +++ b/examples/Dmtp/SerializationSelectorClassLibrary/SerializationSelectorClassLibrary.csproj @@ -6,12 +6,12 @@ - - - - - - + + + + + + diff --git a/examples/Dmtp/SerializationSelectorConsoleApp/SerializationSelectorConsoleApp.csproj b/examples/Dmtp/SerializationSelectorConsoleApp/SerializationSelectorConsoleApp.csproj index fa2afa8ac..2a2f2df2b 100644 --- a/examples/Dmtp/SerializationSelectorConsoleApp/SerializationSelectorConsoleApp.csproj +++ b/examples/Dmtp/SerializationSelectorConsoleApp/SerializationSelectorConsoleApp.csproj @@ -7,12 +7,12 @@ enable - - - - - - + + + + + + diff --git a/examples/Examples-All.sln b/examples/Examples-All.sln index f355c90da..fce60809e 100644 --- a/examples/Examples-All.sln +++ b/examples/Examples-All.sln @@ -180,8 +180,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NamedPipeServiceConsoleApp" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NamedPipeClientConsoleApp", "NamedPipe\NamedPipeClientConsoleApp\NamedPipeClientConsoleApp.csproj", "{89C3B730-4024-4C76-8CB0-FAA8BF0945B9}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnityServerConsoleApp", "Unity3d\UnityServerConsoleApp\UnityServerConsoleApp.csproj", "{E109E848-54D2-4BCE-808E-F5F3844A1B1D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rpc", "Rpc", "{D01CF5F0-67D0-44E3-B7CE-0BAD4F475C0E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerateProxyFromServerConsoleApp", "Rpc\GenerateProxyFromServerConsoleApp\GenerateProxyFromServerConsoleApp.csproj", "{09ABC5EB-0896-4693-A057-A03B35E0294C}" @@ -301,6 +299,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomJsonDataHandlingAdapt EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomCountSpliterDataHandlingAdapterConsoleApp", "Adapter\CustomCountSpliterDataHandlingAdapterConsoleApp\CustomCountSpliterDataHandlingAdapterConsoleApp.csproj", "{3A76B68F-7C8B-4310-BE2F-434B714DE3F7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityServerConsoleApp_All", "Unity3d\UnityServerConsoleApp_All\UnityServerConsoleApp_All.csproj", "{135C1BF2-2097-60BD-377A-41A9F80EB060}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityServerConsoleApp_2D", "Unity3d\UnityServerConsoleApp_2D\UnityServerConsoleApp_2D.csproj", "{81D2B2B1-0A9C-E81D-789A-A9C2C21FD03E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -499,10 +501,6 @@ Global {89C3B730-4024-4C76-8CB0-FAA8BF0945B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {89C3B730-4024-4C76-8CB0-FAA8BF0945B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {89C3B730-4024-4C76-8CB0-FAA8BF0945B9}.Release|Any CPU.Build.0 = Release|Any CPU - {E109E848-54D2-4BCE-808E-F5F3844A1B1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E109E848-54D2-4BCE-808E-F5F3844A1B1D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E109E848-54D2-4BCE-808E-F5F3844A1B1D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E109E848-54D2-4BCE-808E-F5F3844A1B1D}.Release|Any CPU.Build.0 = Release|Any CPU {09ABC5EB-0896-4693-A057-A03B35E0294C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {09ABC5EB-0896-4693-A057-A03B35E0294C}.Debug|Any CPU.Build.0 = Debug|Any CPU {09ABC5EB-0896-4693-A057-A03B35E0294C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -679,6 +677,14 @@ Global {3A76B68F-7C8B-4310-BE2F-434B714DE3F7}.Debug|Any CPU.Build.0 = Debug|Any CPU {3A76B68F-7C8B-4310-BE2F-434B714DE3F7}.Release|Any CPU.ActiveCfg = Release|Any CPU {3A76B68F-7C8B-4310-BE2F-434B714DE3F7}.Release|Any CPU.Build.0 = Release|Any CPU + {135C1BF2-2097-60BD-377A-41A9F80EB060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {135C1BF2-2097-60BD-377A-41A9F80EB060}.Debug|Any CPU.Build.0 = Debug|Any CPU + {135C1BF2-2097-60BD-377A-41A9F80EB060}.Release|Any CPU.ActiveCfg = Release|Any CPU + {135C1BF2-2097-60BD-377A-41A9F80EB060}.Release|Any CPU.Build.0 = Release|Any CPU + {81D2B2B1-0A9C-E81D-789A-A9C2C21FD03E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81D2B2B1-0A9C-E81D-789A-A9C2C21FD03E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81D2B2B1-0A9C-E81D-789A-A9C2C21FD03E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81D2B2B1-0A9C-E81D-789A-A9C2C21FD03E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -756,7 +762,6 @@ Global {9F96589A-C7F8-4E33-BD6E-3BDA40205D07} = {EFB33E23-9E98-4B85-99E4-865705D5ACD2} {E7FE662C-24E4-4915-9847-26AB4038540D} = {5126C261-9A81-4FBC-8653-7710C1D1D735} {89C3B730-4024-4C76-8CB0-FAA8BF0945B9} = {5126C261-9A81-4FBC-8653-7710C1D1D735} - {E109E848-54D2-4BCE-808E-F5F3844A1B1D} = {59C3DFB0-C6E1-4F7E-AD9D-9857A4153A1E} {09ABC5EB-0896-4693-A057-A03B35E0294C} = {D01CF5F0-67D0-44E3-B7CE-0BAD4F475C0E} {5F141D56-D6ED-45C7-A355-63EC641246DB} = {F8C07F29-7233-4FD3-A3DC-45963071E20A} {E1C1B35D-6336-413B-B7DE-25BC24AE401A} = {F8C07F29-7233-4FD3-A3DC-45963071E20A} @@ -808,6 +813,8 @@ Global {0B5E9F7A-54C9-4A27-964E-5A568E5D7626} = {DB89FCB6-E4F9-4BD4-93F3-4E857741D749} {D470A6E0-597C-4A67-8CEF-BB7D9405626A} = {F8C07F29-7233-4FD3-A3DC-45963071E20A} {3A76B68F-7C8B-4310-BE2F-434B714DE3F7} = {F8C07F29-7233-4FD3-A3DC-45963071E20A} + {135C1BF2-2097-60BD-377A-41A9F80EB060} = {59C3DFB0-C6E1-4F7E-AD9D-9857A4153A1E} + {81D2B2B1-0A9C-E81D-789A-A9C2C21FD03E} = {59C3DFB0-C6E1-4F7E-AD9D-9857A4153A1E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DB787235-A13A-4A3D-B5A8-5DFEB6511EEE} diff --git a/examples/Hosting/HostingWorkerService/HostingWorkerService.csproj b/examples/Hosting/HostingWorkerService/HostingWorkerService.csproj index 7bf497b75..686b7f810 100644 --- a/examples/Hosting/HostingWorkerService/HostingWorkerService.csproj +++ b/examples/Hosting/HostingWorkerService/HostingWorkerService.csproj @@ -9,7 +9,7 @@ - - + + diff --git a/examples/Http/HttpClientConsoleApp/HttpClientConsoleApp.csproj b/examples/Http/HttpClientConsoleApp/HttpClientConsoleApp.csproj index 70f759e0b..90e65de40 100644 --- a/examples/Http/HttpClientConsoleApp/HttpClientConsoleApp.csproj +++ b/examples/Http/HttpClientConsoleApp/HttpClientConsoleApp.csproj @@ -7,7 +7,7 @@ - + - + diff --git a/examples/Http/HttpServiceForCorsConsoleApp/HttpServiceForCorsConsoleApp.csproj b/examples/Http/HttpServiceForCorsConsoleApp/HttpServiceForCorsConsoleApp.csproj index 3c197e9a6..dea033537 100644 --- a/examples/Http/HttpServiceForCorsConsoleApp/HttpServiceForCorsConsoleApp.csproj +++ b/examples/Http/HttpServiceForCorsConsoleApp/HttpServiceForCorsConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/JsonRpc/DispatchProxyJsonRpcClientConsoleApp/DispatchProxyJsonRpcClientConsoleApp.csproj b/examples/JsonRpc/DispatchProxyJsonRpcClientConsoleApp/DispatchProxyJsonRpcClientConsoleApp.csproj index 4a4f22947..2a5dddff6 100644 --- a/examples/JsonRpc/DispatchProxyJsonRpcClientConsoleApp/DispatchProxyJsonRpcClientConsoleApp.csproj +++ b/examples/JsonRpc/DispatchProxyJsonRpcClientConsoleApp/DispatchProxyJsonRpcClientConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/JsonRpc/JsonRpcClientConsoleApp/JsonRpcClientConsoleApp.csproj b/examples/JsonRpc/JsonRpcClientConsoleApp/JsonRpcClientConsoleApp.csproj index 05c5ac208..80c04dc40 100644 --- a/examples/JsonRpc/JsonRpcClientConsoleApp/JsonRpcClientConsoleApp.csproj +++ b/examples/JsonRpc/JsonRpcClientConsoleApp/JsonRpcClientConsoleApp.csproj @@ -12,6 +12,6 @@ - + diff --git a/examples/JsonRpc/JsonRpcConsoleApp/JsonRpcServiceConsoleApp.csproj b/examples/JsonRpc/JsonRpcConsoleApp/JsonRpcServiceConsoleApp.csproj index 1e3a73cc3..881339383 100644 --- a/examples/JsonRpc/JsonRpcConsoleApp/JsonRpcServiceConsoleApp.csproj +++ b/examples/JsonRpc/JsonRpcConsoleApp/JsonRpcServiceConsoleApp.csproj @@ -10,6 +10,6 @@ - + diff --git a/examples/JsonRpc/ReverseJsonRpcConsoleApp/ReverseJsonRpcConsoleApp.csproj b/examples/JsonRpc/ReverseJsonRpcConsoleApp/ReverseJsonRpcConsoleApp.csproj index 99ab1aa80..9eda3d06d 100644 --- a/examples/JsonRpc/ReverseJsonRpcConsoleApp/ReverseJsonRpcConsoleApp.csproj +++ b/examples/JsonRpc/ReverseJsonRpcConsoleApp/ReverseJsonRpcConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/Modbus/ModbusMasterConsoleApp/ModbusMasterConsoleApp.csproj b/examples/Modbus/ModbusMasterConsoleApp/ModbusMasterConsoleApp.csproj index 76865001b..d38c6902d 100644 --- a/examples/Modbus/ModbusMasterConsoleApp/ModbusMasterConsoleApp.csproj +++ b/examples/Modbus/ModbusMasterConsoleApp/ModbusMasterConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Modbus/ModbusObjectConsoleApp/ModbusObjectConsoleApp.csproj b/examples/Modbus/ModbusObjectConsoleApp/ModbusObjectConsoleApp.csproj index 863354277..b566df50e 100644 --- a/examples/Modbus/ModbusObjectConsoleApp/ModbusObjectConsoleApp.csproj +++ b/examples/Modbus/ModbusObjectConsoleApp/ModbusObjectConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/Modbus/ModbusSlaveConsoleApp/ModbusSlaveConsoleApp.csproj b/examples/Modbus/ModbusSlaveConsoleApp/ModbusSlaveConsoleApp.csproj index 863354277..b566df50e 100644 --- a/examples/Modbus/ModbusSlaveConsoleApp/ModbusSlaveConsoleApp.csproj +++ b/examples/Modbus/ModbusSlaveConsoleApp/ModbusSlaveConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/NamedPipe/NamedPipeClientConsoleApp/NamedPipeClientConsoleApp.csproj b/examples/NamedPipe/NamedPipeClientConsoleApp/NamedPipeClientConsoleApp.csproj index 7e2b627a1..1f55db53a 100644 --- a/examples/NamedPipe/NamedPipeClientConsoleApp/NamedPipeClientConsoleApp.csproj +++ b/examples/NamedPipe/NamedPipeClientConsoleApp/NamedPipeClientConsoleApp.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/NamedPipe/NamedPipeServiceConsoleApp/NamedPipeServiceConsoleApp.csproj b/examples/NamedPipe/NamedPipeServiceConsoleApp/NamedPipeServiceConsoleApp.csproj index 1df3bbdc0..97c4c07f5 100644 --- a/examples/NamedPipe/NamedPipeServiceConsoleApp/NamedPipeServiceConsoleApp.csproj +++ b/examples/NamedPipe/NamedPipeServiceConsoleApp/NamedPipeServiceConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/NamedPipe/NamedPipeWebApplication/NamedPipeWebApplication.csproj b/examples/NamedPipe/NamedPipeWebApplication/NamedPipeWebApplication.csproj index a2383b46d..8e4199219 100644 --- a/examples/NamedPipe/NamedPipeWebApplication/NamedPipeWebApplication.csproj +++ b/examples/NamedPipe/NamedPipeWebApplication/NamedPipeWebApplication.csproj @@ -8,8 +8,8 @@ - - + + - + \ No newline at end of file diff --git a/examples/Udp/UdpBroadcastConsoleApp/UdpBroadcastConsoleApp.csproj b/examples/Udp/UdpBroadcastConsoleApp/UdpBroadcastConsoleApp.csproj index 433af7fe5..f3cefad86 100644 --- a/examples/Udp/UdpBroadcastConsoleApp/UdpBroadcastConsoleApp.csproj +++ b/examples/Udp/UdpBroadcastConsoleApp/UdpBroadcastConsoleApp.csproj @@ -8,12 +8,12 @@ - - - - - - + + + + + + diff --git a/examples/Udp/UdpDemoApp/UdpDemoApp.csproj b/examples/Udp/UdpDemoApp/UdpDemoApp.csproj index ad8ed2000..d02a2bc5c 100644 --- a/examples/Udp/UdpDemoApp/UdpDemoApp.csproj +++ b/examples/Udp/UdpDemoApp/UdpDemoApp.csproj @@ -7,11 +7,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/examples/Udp/UdpScreenCapture/ScreenUdpReceiver/ScreenUdpReceiver.csproj b/examples/Udp/UdpScreenCapture/ScreenUdpReceiver/ScreenUdpReceiver.csproj index e090a3048..2f7da6aca 100644 --- a/examples/Udp/UdpScreenCapture/ScreenUdpReceiver/ScreenUdpReceiver.csproj +++ b/examples/Udp/UdpScreenCapture/ScreenUdpReceiver/ScreenUdpReceiver.csproj @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/examples/Udp/UdpScreenCapture/ScreenUdpSender/ScreenUdpSender.csproj b/examples/Udp/UdpScreenCapture/ScreenUdpSender/ScreenUdpSender.csproj index e090a3048..2f7da6aca 100644 --- a/examples/Udp/UdpScreenCapture/ScreenUdpSender/ScreenUdpSender.csproj +++ b/examples/Udp/UdpScreenCapture/ScreenUdpSender/ScreenUdpSender.csproj @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/examples/Unity3d/UnityPackage/TouchSocketAll-v3.0.14.unitypackage b/examples/Unity3d/UnityPackage/TouchSocketAll-v3.0.14.unitypackage new file mode 100644 index 000000000..4557bd77d Binary files /dev/null and b/examples/Unity3d/UnityPackage/TouchSocketAll-v3.0.14.unitypackage differ diff --git a/examples/Unity3d/UnityServerConsoleApp/Program.cs b/examples/Unity3d/UnityServerConsoleApp/Program.cs deleted file mode 100644 index e544668a2..000000000 --- a/examples/Unity3d/UnityServerConsoleApp/Program.cs +++ /dev/null @@ -1,216 +0,0 @@ -//------------------------------------------------------------------------------ -// 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有 -// 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权 -// CSDN博客:https://blog.csdn.net/qq_40374647 -// 哔哩哔哩视频:https://space.bilibili.com/94253567 -// Gitee源代码仓库:https://gitee.com/RRQM_Home -// Github源代码仓库:https://github.com/RRQM -// API首页:https://touchsocket.net/ -// 交流QQ群:234762506 -// 感谢您的下载和使用 -//------------------------------------------------------------------------------ - -using System; -using System.ComponentModel; -using System.IO; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using TouchSocket.Core; -using TouchSocket.Dmtp; -using TouchSocket.Dmtp.Rpc; -using TouchSocket.JsonRpc; -using TouchSocket.Rpc; -using TouchSocket.Sockets; - -namespace UnityServerConsoleApp -{ - internal class Program - { - static UdpSession udpService = new UdpSession(); - static HttpDmtpService httpDmtpService = new HttpDmtpService(); - static TcpService tcpService = new TcpService(); - - private static async Task Main(string[] args) - { - //unitypackage在本级目录下。 - await StartTcpService(7789); - await StartDmtpService(7790); - await StartUdpService(7791); - Console.ReadKey(); - } - - - private static async Task StartUdpService(int port) - { - - udpService.Received = async (c, e) => - { - await udpService.SendAsync(e.EndPoint, e.ByteBlock.Memory); - Console.WriteLine($"收到:{e.ByteBlock.Span.ToString(Encoding.UTF8)}"); - }; - await udpService.SetupAsync(new TouchSocketConfig() - .SetBindIPHost(new IPHost(port)) - .SetUdpDataHandlingAdapter(() => new NormalUdpDataHandlingAdapter())//常规udp - //.SetUdpDataHandlingAdapter(() => new UdpPackageAdapter())//Udp包模式,支持超过64k数据。 - .ConfigureContainer(a => - { - a.AddConsoleLogger();//添加一个日志注入 - })); - await udpService.StartAsync(); - - udpService.Logger.Info($"UdpService已启动,端口:{port}"); - } - - - private static async Task StartDmtpService(int port) - { - - var config = new TouchSocketConfig()//配置 - .SetListenIPHosts(port) - .ConfigureContainer(a => - { - a.AddConsoleLogger();//注册一个日志组 - - //注册rpc服务 - a.AddRpcStore(store => - { - store.RegisterServer(); -#if DEBUG - var code = store.GetProxyCodes("UnityRpcProxy", typeof(DmtpRpcAttribute), typeof(JsonRpcAttribute)); - File.WriteAllText("../../../UnityRpcProxy.cs", code); -#endif - }); - }) - .ConfigurePlugins(a => - { - //启用dmtp rpc插件 - a.UseDmtpRpc(); - - //启用websocket插件 - a.UseWebSocket() - .SetWSUrl("/ws"); - - //启用json rpc插件 - a.UseWebSocketJsonRpc() - .SetAllowJsonRpc((websocket, context) => true);//让所有请求WebSocket都加载JsonRpc插件 - - a.Add(); - }) - .SetDmtpOption(new DmtpOption() - { - VerifyToken = "Dmtp"//设置验证token - }); - - await httpDmtpService.SetupAsync(config); - await httpDmtpService.StartAsync(); - - httpDmtpService.Logger.Info($"{httpDmtpService.GetType().Name}已启动,监听端口:{port}"); - } - - private static async Task StartTcpService(int port) - { - - await tcpService.SetupAsync(new TouchSocketConfig()//载入配置 - .SetListenIPHosts(new IPHost(port)) - .SetTcpDataHandlingAdapter(() => new FixedHeaderPackageAdapter()) - .ConfigurePlugins(a => - { - a.Add();//此处可以添加插件 - }) - .ConfigureContainer(a => - { - a.AddConsoleLogger();//添加一个日志注入 - })); - await tcpService.StartAsync();//启动 - tcpService.Logger.Info($"Tcp服务器已启动,端口{port}"); - } - } - - internal class MyTcpRpcPlguin : PluginBase - { - } - - internal class MyPlguin : PluginBase, ITcpConnectedPlugin, ITcpClosedPlugin, ITcpReceivedPlugin - { - public async Task OnTcpClosed(ITcpSession client, ClosedEventArgs e) - { - client.Logger.Info($"客户端{client.GetIPPort()}已断开"); - await e.InvokeNext(); - } - - public async Task OnTcpConnected(ITcpSession client, ConnectedEventArgs e) - { - client.Logger.Info($"客户端{client.GetIPPort()}已连接"); - await e.InvokeNext(); - } - - - public async Task OnTcpReceived(ITcpSession client, ReceivedDataEventArgs e) - { - client.Logger.Info($"接收到信息:{e.ByteBlock.Span.ToString(Encoding.UTF8)}"); - - if (client is ITcpSessionClient sessionClient) - { - await sessionClient.SendAsync($"服务器已收到你发送的消息:{e.ByteBlock.ToString()}"); - } - - - await e.InvokeNext(); - } - } - - - public partial class MyRpcServer : RpcServer - { - public MyRpcServer(ILog logger) - { - this.m_timer = new Timer((obj) => - { - logger.Info($"count={this.count}"); - }, null, 0, 1000); - this.m_logger = logger; - } - - private Timer m_timer; - private int count; - private readonly ILog m_logger; - - [Description("登录")] - [DmtpRpc(MethodInvoke = true, MethodName = "DmtpRpc_{0}")] - [JsonRpc(MethodInvoke = true, MethodName = "JsonRpc_{0}")] - public MyLoginModelResult Login(ICallContext callContext, MyLoginModel model) - { - if (model.Account == "123" && model.Password == "abc") - { - return new MyLoginModelResult() { ResultCode = ResultCode.Success, Message = "Success" }; - } - - return new MyLoginModelResult() { ResultCode = ResultCode.Fail, Message = "账号或密码错误" }; - } - - [Description("性能测试")] - [DmtpRpc(MethodInvoke = true, MethodName = "DmtpRpc_{0}")] - [JsonRpc(MethodInvoke = true, MethodName = "JsonRpc_{0}")] - public int Performance(int i) - { - Interlocked.Increment(ref this.count); - return ++i; - } - } - - public class MyLoginModel - { - public string Token { get; set; } - public string Account { get; set; } - public string Password { get; set; } - } - - public class MyLoginModelResult - { - public ResultCode ResultCode { get; set; } - public string Message { get; set; } - } - -} \ No newline at end of file diff --git a/examples/Unity3d/UnityServerConsoleApp/UnityRpcProxy.cs b/examples/Unity3d/UnityServerConsoleApp/UnityRpcProxy.cs deleted file mode 100644 index 39dd62cd6..000000000 --- a/examples/Unity3d/UnityServerConsoleApp/UnityRpcProxy.cs +++ /dev/null @@ -1,318 +0,0 @@ -/* -此代码由Rpc工具直接生成,非必要请不要修改此处代码 -*/ -#pragma warning disable -using System; -using TouchSocket.Core; -using TouchSocket.Sockets; -using TouchSocket.Rpc; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text; -using System.Threading.Tasks; -namespace UnityRpcProxy -{ -public interface IMyRpcServer:TouchSocket.Rpc.IRemoteServer -{ -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -MyLoginModelResult DmtpRpc_Login(MyLoginModel model,IInvokeOption invokeOption = default); -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -Task DmtpRpc_LoginAsync(MyLoginModel model,IInvokeOption invokeOption = default); - -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -System.Int32 DmtpRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default); -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -Task DmtpRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default); - -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -MyLoginModelResult JsonRpc_Login(MyLoginModel model,IInvokeOption invokeOption = default); -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -Task JsonRpc_LoginAsync(MyLoginModel model,IInvokeOption invokeOption = default); - -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -System.Int32 JsonRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default); -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -Task JsonRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default); - -} -public class MyRpcServer :IMyRpcServer -{ -public MyRpcServer(IRpcClient client) -{ -this.Client=client; -} -public IRpcClient Client{get;private set; } -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public MyLoginModelResult DmtpRpc_Login(MyLoginModel model,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] @_parameters = new object[]{model}; -MyLoginModelResult returnData=(MyLoginModelResult)this.Client.Invoke("DmtpRpc_Login",typeof(MyLoginModelResult),invokeOption, @_parameters); -return returnData; - -} -/// -///登录 -/// -public async Task DmtpRpc_LoginAsync(MyLoginModel model,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] parameters = new object[]{model}; -return (MyLoginModelResult) await this.Client.InvokeAsync("DmtpRpc_Login",typeof(MyLoginModelResult),invokeOption, parameters); - -} - -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public System.Int32 DmtpRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] @_parameters = new object[]{i}; -System.Int32 returnData=(System.Int32)this.Client.Invoke("DmtpRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); -return returnData; - -} -/// -///性能测试 -/// -public async Task DmtpRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] parameters = new object[]{i}; -return (System.Int32) await this.Client.InvokeAsync("DmtpRpc_Performance",typeof(System.Int32),invokeOption, parameters); - -} - -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public MyLoginModelResult JsonRpc_Login(MyLoginModel model,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] @_parameters = new object[]{model}; -MyLoginModelResult returnData=(MyLoginModelResult)this.Client.Invoke("JsonRpc_Login",typeof(MyLoginModelResult),invokeOption, @_parameters); -return returnData; - -} -/// -///登录 -/// -public async Task JsonRpc_LoginAsync(MyLoginModel model,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] parameters = new object[]{model}; -return (MyLoginModelResult) await this.Client.InvokeAsync("JsonRpc_Login",typeof(MyLoginModelResult),invokeOption, parameters); - -} - -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public System.Int32 JsonRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] @_parameters = new object[]{i}; -System.Int32 returnData=(System.Int32)this.Client.Invoke("JsonRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); -return returnData; - -} -/// -///性能测试 -/// -public async Task JsonRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default) -{ -if(this.Client==null) -{ -throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); -} -object[] parameters = new object[]{i}; -return (System.Int32) await this.Client.InvokeAsync("JsonRpc_Performance",typeof(System.Int32),invokeOption, parameters); - -} - -} -public static class MyRpcServerExtensions -{ -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public static MyLoginModelResult DmtpRpc_Login(this TClient client,MyLoginModel model,IInvokeOption invokeOption = default) where TClient: -TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ -object[] @_parameters = new object[]{model}; -MyLoginModelResult returnData=(MyLoginModelResult)client.Invoke("DmtpRpc_Login",typeof(MyLoginModelResult),invokeOption, @_parameters); -return returnData; - -} -/// -///登录 -/// -public static async Task DmtpRpc_LoginAsync(this TClient client,MyLoginModel model,IInvokeOption invokeOption = default) where TClient: -TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ -object[] parameters = new object[]{model}; -return (MyLoginModelResult) await client.InvokeAsync("DmtpRpc_Login",typeof(MyLoginModelResult),invokeOption, parameters); - -} - -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public static System.Int32 DmtpRpc_Performance(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: -TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ -object[] @_parameters = new object[]{i}; -System.Int32 returnData=(System.Int32)client.Invoke("DmtpRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); -return returnData; - -} -/// -///性能测试 -/// -public static async Task DmtpRpc_PerformanceAsync(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: -TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ -object[] parameters = new object[]{i}; -return (System.Int32) await client.InvokeAsync("DmtpRpc_Performance",typeof(System.Int32),invokeOption, parameters); - -} - -/// -///登录 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public static MyLoginModelResult JsonRpc_Login(this TClient client,MyLoginModel model,IInvokeOption invokeOption = default) where TClient: -TouchSocket.JsonRpc.IJsonRpcClient{ -object[] @_parameters = new object[]{model}; -MyLoginModelResult returnData=(MyLoginModelResult)client.Invoke("JsonRpc_Login",typeof(MyLoginModelResult),invokeOption, @_parameters); -return returnData; - -} -/// -///登录 -/// -public static async Task JsonRpc_LoginAsync(this TClient client,MyLoginModel model,IInvokeOption invokeOption = default) where TClient: -TouchSocket.JsonRpc.IJsonRpcClient{ -object[] parameters = new object[]{model}; -return (MyLoginModelResult) await client.InvokeAsync("JsonRpc_Login",typeof(MyLoginModelResult),invokeOption, parameters); - -} - -/// -///性能测试 -/// -/// 调用超时 -/// Rpc调用异常 -/// 其他异常 -public static System.Int32 JsonRpc_Performance(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: -TouchSocket.JsonRpc.IJsonRpcClient{ -object[] @_parameters = new object[]{i}; -System.Int32 returnData=(System.Int32)client.Invoke("JsonRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); -return returnData; - -} -/// -///性能测试 -/// -public static async Task JsonRpc_PerformanceAsync(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: -TouchSocket.JsonRpc.IJsonRpcClient{ -object[] parameters = new object[]{i}; -return (System.Int32) await client.InvokeAsync("JsonRpc_Performance",typeof(System.Int32),invokeOption, parameters); - -} - -} -public class MyLoginModelResult -{ -public TouchSocket.Core.ResultCode ResultCode { get; set; } -public System.String Message { get; set; } -} - -public class MyLoginModel -{ -public System.String Token { get; set; } -public System.String Account { get; set; } -public System.String Password { get; set; } -} - -} diff --git a/examples/Unity3d/UnityServerConsoleApp/UnityServerConsoleApp.csproj b/examples/Unity3d/UnityServerConsoleApp/UnityServerConsoleApp.csproj deleted file mode 100644 index 836f9c617..000000000 --- a/examples/Unity3d/UnityServerConsoleApp/UnityServerConsoleApp.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - - - - - - diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/Program.cs b/examples/Unity3d/UnityServerConsoleApp_2D/Program.cs new file mode 100644 index 000000000..765e0aa01 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/Program.cs @@ -0,0 +1,18 @@ +using UnityServerConsoleApp_2D.TouchServer; + +namespace UnityServerConsoleApp_2D +{ + internal class Program + { + //适用于unity的package包在同级目录中 + static async Task Main(string[] args) + { + Touch_JsonWebSocket_2D touch_2d = new Touch_JsonWebSocket_2D(); + + await touch_2d.StartService(7794); + + Console.ReadKey(); + + } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/RPCStore/Reverse2DSquareRpcServer.cs b/examples/Unity3d/UnityServerConsoleApp_2D/RPCStore/Reverse2DSquareRpcServer.cs new file mode 100644 index 000000000..50af3453e --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/RPCStore/Reverse2DSquareRpcServer.cs @@ -0,0 +1,297 @@ +/* +此代码由Rpc工具直接生成,非必要请不要修改此处代码 +*/ +#pragma warning disable +using System; +using TouchSocket.Core; +using TouchSocket.Sockets; +using TouchSocket.Rpc; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Threading.Tasks; +namespace UnityRpcProxy +{ +public interface IReverse2DSquareRpcServer:TouchSocket.Rpc.IRemoteServer +{ +/// +///更新位置 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +void UpdatePosition(System.Int32 id,System.Numerics.Vector3 vector3,System.Int64 time,IInvokeOption invokeOption = default); +/// +///更新位置 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task UpdatePositionAsync(System.Int32 id,System.Numerics.Vector3 vector3,System.Int64 time,IInvokeOption invokeOption = default); + +/// +///创建新的NPC +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +void NewNPC(System.Int32 id,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default); +/// +///创建新的NPC +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task NewNPCAsync(System.Int32 id,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default); + +/// +///玩家离线 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +void Offline(System.Int32 id,IInvokeOption invokeOption = default); +/// +///玩家离线 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task OfflineAsync(System.Int32 id,IInvokeOption invokeOption = default); + +/// +///玩家登陆 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +void PlayerLogin(System.Int32 id,IInvokeOption invokeOption = default); +/// +///玩家登陆 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task PlayerLoginAsync(System.Int32 id,IInvokeOption invokeOption = default); + +} +public class Reverse2DSquareRpcServer :IReverse2DSquareRpcServer +{ +public Reverse2DSquareRpcServer(IRpcClient client) +{ +this.Client=client; +} +public IRpcClient Client{get;private set; } +/// +///更新位置 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public void UpdatePosition(System.Int32 id,System.Numerics.Vector3 vector3,System.Int64 time,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{id,vector3,time}; +this.Client.Invoke("UpdatePosition",null,invokeOption, @_parameters); + +} +/// +///更新位置 +/// +public Task UpdatePositionAsync(System.Int32 id,System.Numerics.Vector3 vector3,System.Int64 time,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{id,vector3,time}; +return this.Client.InvokeAsync("UpdatePosition",null,invokeOption, parameters); + +} + +/// +///创建新的NPC +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public void NewNPC(System.Int32 id,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{id,vector3}; +this.Client.Invoke("NewNPC",null,invokeOption, @_parameters); + +} +/// +///创建新的NPC +/// +public Task NewNPCAsync(System.Int32 id,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{id,vector3}; +return this.Client.InvokeAsync("NewNPC",null,invokeOption, parameters); + +} + +/// +///玩家离线 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public void Offline(System.Int32 id,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{id}; +this.Client.Invoke("Offline",null,invokeOption, @_parameters); + +} +/// +///玩家离线 +/// +public Task OfflineAsync(System.Int32 id,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{id}; +return this.Client.InvokeAsync("Offline",null,invokeOption, parameters); + +} + +/// +///玩家登陆 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public void PlayerLogin(System.Int32 id,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{id}; +this.Client.Invoke("PlayerLogin",null,invokeOption, @_parameters); + +} +/// +///玩家登陆 +/// +public Task PlayerLoginAsync(System.Int32 id,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{id}; +return this.Client.InvokeAsync("PlayerLogin",null,invokeOption, parameters); + +} + +} +public static class Reverse2DSquareRpcServerExtensions +{ +/// +///更新位置 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static void UpdatePosition(this TClient client,System.Int32 id,System.Numerics.Vector3 vector3,System.Int64 time,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{id,vector3,time}; +client.Invoke("UpdatePosition",null,invokeOption, @_parameters); + +} +/// +///更新位置 +/// +public static Task UpdatePositionAsync(this TClient client,System.Int32 id,System.Numerics.Vector3 vector3,System.Int64 time,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{id,vector3,time}; +return client.InvokeAsync("UpdatePosition",null,invokeOption, parameters); + +} + +/// +///创建新的NPC +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static void NewNPC(this TClient client,System.Int32 id,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{id,vector3}; +client.Invoke("NewNPC",null,invokeOption, @_parameters); + +} +/// +///创建新的NPC +/// +public static Task NewNPCAsync(this TClient client,System.Int32 id,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{id,vector3}; +return client.InvokeAsync("NewNPC",null,invokeOption, parameters); + +} + +/// +///玩家离线 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static void Offline(this TClient client,System.Int32 id,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{id}; +client.Invoke("Offline",null,invokeOption, @_parameters); + +} +/// +///玩家离线 +/// +public static Task OfflineAsync(this TClient client,System.Int32 id,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{id}; +return client.InvokeAsync("Offline",null,invokeOption, parameters); + +} + +/// +///玩家登陆 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static void PlayerLogin(this TClient client,System.Int32 id,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{id}; +client.Invoke("PlayerLogin",null,invokeOption, @_parameters); + +} +/// +///玩家登陆 +/// +public static Task PlayerLoginAsync(this TClient client,System.Int32 id,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{id}; +return client.InvokeAsync("PlayerLogin",null,invokeOption, parameters); + +} + +} +} diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/RPCStore/UnityRpcProxy_Json_HttpDmtp_2D.cs b/examples/Unity3d/UnityServerConsoleApp_2D/RPCStore/UnityRpcProxy_Json_HttpDmtp_2D.cs new file mode 100644 index 000000000..cbc263d15 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/RPCStore/UnityRpcProxy_Json_HttpDmtp_2D.cs @@ -0,0 +1,96 @@ +/* +此代码由Rpc工具直接生成,非必要请不要修改此处代码 +*/ +#pragma warning disable +using System; +using TouchSocket.Core; +using TouchSocket.Sockets; +using TouchSocket.Rpc; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Threading.Tasks; +namespace UnityRpcProxy_Json_HttpDmtp_2D +{ +public interface IUnityRpcStore:TouchSocket.Rpc.IRemoteServer +{ +/// +///单位移动 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +void JsonRpc_UnitMovement(System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default); +/// +///单位移动 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task JsonRpc_UnitMovementAsync(System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default); + +} +public class UnityRpcStore :IUnityRpcStore +{ +public UnityRpcStore(IRpcClient client) +{ +this.Client=client; +} +public IRpcClient Client{get;private set; } +/// +///单位移动 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public void JsonRpc_UnitMovement(System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{vector3}; +this.Client.Invoke("JsonRpc_UnitMovement",null,invokeOption, @_parameters); + +} +/// +///单位移动 +/// +public Task JsonRpc_UnitMovementAsync(System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{vector3}; +return this.Client.InvokeAsync("JsonRpc_UnitMovement",null,invokeOption, parameters); + +} + +} +public static class UnityRpcStoreExtensions +{ +/// +///单位移动 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static void JsonRpc_UnitMovement(this TClient client,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{vector3}; +client.Invoke("JsonRpc_UnitMovement",null,invokeOption, @_parameters); + +} +/// +///单位移动 +/// +public static Task JsonRpc_UnitMovementAsync(this TClient client,System.Numerics.Vector3 vector3,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{vector3}; +return client.InvokeAsync("JsonRpc_UnitMovement",null,invokeOption, parameters); + +} + +} +} diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/BaseTouchServer.cs b/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/BaseTouchServer.cs new file mode 100644 index 000000000..8071edd3b --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/BaseTouchServer.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UnityServerConsoleApp_2D.TouchServer +{ + /// + /// 基础网络服务接口 + /// + public interface BaseTouchServer + { + /// + /// 启动服务 + /// + /// + Task StartService(int port); + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/Touch_JsonWebSocket_2D.cs b/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/Touch_JsonWebSocket_2D.cs new file mode 100644 index 000000000..630cde54e --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/Touch_JsonWebSocket_2D.cs @@ -0,0 +1,147 @@ +using System.Numerics; +using TouchSocket.Core; +using TouchSocket.Dmtp; +using TouchSocket.Dmtp.Rpc; +using TouchSocket.Http; +using TouchSocket.Http.WebSockets; +using TouchSocket.JsonRpc; +using TouchSocket.Rpc; +using TouchSocket.Sockets; +using UnityRpcProxy; +namespace UnityServerConsoleApp_2D.TouchServer +{ + /// + /// Web Socket + /// + public class Touch_JsonWebSocket_2D : BaseTouchServer + { + JsonHttpService dmtpService = new JsonHttpService(); + public async Task StartService(int port) + { + var config = new TouchSocketConfig()//配置 + .SetListenIPHosts(port) + + .ConfigureContainer(a => + { + a.AddConsoleLogger();//注册一个日志组 + + //注册rpc服务 + a.AddRpcStore(store => + { + store.RegisterServer(); +#if DEBUG + var code = store.GetProxyCodes("UnityRpcProxy_Json_HttpDmtp_2D", typeof(JsonRpcAttribute)); + File.WriteAllText("../../../RPCStore/UnityRpcProxy_Json_HttpDmtp_2D.cs", code); +#endif + }); + }) + .ConfigurePlugins(a => + { + a.UseWebSocket() + .SetWSUrl("/ws"); + + //启用json rpc插件 + a.UseWebSocketJsonRpc() + .SetAllowJsonRpc((websocket, context) => true);//让所有请求WebSocket都加载JsonRpc插件 + + + a.Add(); + + }); + + await dmtpService.SetupAsync(config); + await dmtpService.StartAsync(); + + + dmtpService.Logger.Info($"TCP_JsonWebSocket已启动,监听端口:{port}"); + } + } + /// + /// 状态日志打印插件 + /// + internal class Touch_JsonWebSocket_Log_Plguin : PluginBase, IWebSocketHandshakedPlugin, IWebSocketClosedPlugin + { + ILog Log; + public Touch_JsonWebSocket_Log_Plguin(ILog Log) + { + this.Log = Log; + + } + static int ID; + public async Task OnWebSocketClosed(IWebSocket webSocket, ClosedEventArgs e) + { + webSocket.Client.Logger.Info($"TCP_WebSocket:客户端{webSocket.Client.IP}已断开"); + if (webSocket.Client is JsonHttpSessionClient client) { + Log.Info("在线用户" + client.Service.Count); + + foreach (JsonHttpSessionClient clientItem in client.Service.GetClients()) + { + //对已经在线的客户端通知他们有玩家退出 + if (clientItem != client) + { + _ = clientItem.GetJsonRpcActionClient().OfflineAsync(client.ID); + } + + } + } + await e.InvokeNext(); + } + + public async Task OnWebSocketHandshaked(IWebSocket webSocket, HttpContextEventArgs e) + { + + if (webSocket.Client is JsonHttpSessionClient client) + { + Log.Info($"TCP_WebSocket:客户端{webSocket.Client.IP}已连接"); + client.ID = ++ID; + _ = Task.Run(async () => + { + foreach (JsonHttpSessionClient clientItem in client.Service.GetClients()) + { + //对当前玩家返回已登陆玩家的数据 + await client.GetJsonRpcActionClient().NewNPCAsync(clientItem.ID, clientItem.Postion); + } + foreach (JsonHttpSessionClient clientItem in client.Service.GetClients()) + { + //对已在线的玩家添加在线用户 + await clientItem.GetJsonRpcActionClient().NewNPCAsync(client.ID, client.Postion); + } + await client.GetJsonRpcActionClient().PlayerLoginAsync(client.ID); + }); + Log.Info("在线用户"+ client.Service.Count); + } + await e.InvokeNext(); + } + } + + /// + /// 自定义HttpDmtpService + /// + internal class JsonHttpService : HttpDmtpService + { + protected override JsonHttpSessionClient NewClient() + { + return new JsonHttpSessionClient(); + + } + } + + /// + /// 自定义HttpDmtpSessionClient + /// + internal class JsonHttpSessionClient : HttpDmtpSessionClient + { + public int ID { get; set; } + /// + /// 位置 + /// + public Vector3 Postion { get; set; } + + public JsonHttpSessionClient() { + + + } + + + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/UnityRpcStore.cs b/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/UnityRpcStore.cs new file mode 100644 index 000000000..43867a6fd --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/TouchServer/UnityRpcStore.cs @@ -0,0 +1,55 @@ +using System.ComponentModel; +using TouchSocket.Core; +using TouchSocket.JsonRpc; +using TouchSocket.Rpc; +using System.Numerics; +using UnityRpcProxy; + +namespace UnityServerConsoleApp_2D.TouchServer +{ + internal class UnityRpcStore: RpcServer + { + private readonly ILog m_logger; + public UnityRpcStore(ILog logger) + { + this.m_logger = logger; + } + + /// + /// 将 DateTime 转换为时间戳(毫秒) + /// + /// 要转换的 DateTime + /// 时间戳(毫秒) + public static long ToTimestamp(DateTime dateTime) + { + // Unix 纪元时间 + DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + // 计算时间差并转换为毫秒 + TimeSpan timeSpan = dateTime.ToUniversalTime() - unixEpoch; + return (long)timeSpan.TotalMilliseconds; + } + + [Description("单位移动")] + [JsonRpc(MethodInvoke = true, MethodName = "JsonRpc_{0}")] + public void UnitMovement(ICallContext callContext,Vector3 vector3) + { + if (callContext.Caller is JsonHttpSessionClient jsonsession) + { + jsonsession.Postion = vector3; + foreach (JsonHttpSessionClient clientItem in jsonsession.Service.GetClients()) + { + + //通知除开玩家的其他所有客户端 + if (jsonsession!=clientItem) + { + clientItem.GetJsonRpcActionClient().UpdatePositionAsync(jsonsession.ID, jsonsession.Postion, ToTimestamp(DateTime.Now)); + } + + } + + } + } + + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_2D/UnityServerConsoleApp_2D.csproj b/examples/Unity3d/UnityServerConsoleApp_2D/UnityServerConsoleApp_2D.csproj new file mode 100644 index 000000000..139bc84ae --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_2D/UnityServerConsoleApp_2D.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/examples/Unity3d/UnityServerConsoleApp_All/Program.cs b/examples/Unity3d/UnityServerConsoleApp_All/Program.cs new file mode 100644 index 000000000..ad1da86f1 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/Program.cs @@ -0,0 +1,26 @@ +using UnityServerConsoleApp_All.TouchServer; + +namespace UnityServerConsoleApp_All +{ + internal class Program + { + //适用于unity的package包在同级目录中 + static async Task Main(string[] args) + { + Touch_UDP touch_UDP = new Touch_UDP(); + Touch_TCP touch_TCP = new Touch_TCP(); + Touch_HttpDmtp touch_Dmtp = new Touch_HttpDmtp(); + Touch_WebSocket touch_WebSocket = new Touch_WebSocket(); + Touch_JsonWebSocket touch_JsonWeb = new Touch_JsonWebSocket(); + + await touch_TCP.StartService(7789); + await touch_Dmtp.StartService(7790); + await touch_UDP.StartService(7791); + await touch_WebSocket.StartService(7792); + await touch_JsonWeb.StartService(7793); + + Console.ReadKey(); + + } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Client_HttpDmtp.cs b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Client_HttpDmtp.cs new file mode 100644 index 000000000..6629e2a76 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Client_HttpDmtp.cs @@ -0,0 +1,98 @@ +/* +此代码由Rpc工具直接生成,非必要请不要修改此处代码 +*/ +#pragma warning disable +using System; +using TouchSocket.Core; +using TouchSocket.Sockets; +using TouchSocket.Rpc; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Threading.Tasks; +namespace UnityRpcProxy +{ +public interface ITouch_HttpDmtp_Client_UnityRpcStore:TouchSocket.Rpc.IRemoteServer +{ +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +System.Int32 RandomNumber(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default); +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task RandomNumberAsync(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default); + +} +public class Touch_HttpDmtp_Client_UnityRpcStore :ITouch_HttpDmtp_Client_UnityRpcStore +{ +public Touch_HttpDmtp_Client_UnityRpcStore(IRpcClient client) +{ +this.Client=client; +} +public IRpcClient Client{get;private set; } +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public System.Int32 RandomNumber(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{a,b}; +System.Int32 returnData=(System.Int32)this.Client.Invoke("RandomNumber",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///无注释信息 +/// +public async Task RandomNumberAsync(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{a,b}; +return (System.Int32) await this.Client.InvokeAsync("RandomNumber",typeof(System.Int32),invokeOption, parameters); + +} + +} +public static class Touch_HttpDmtp_Client_UnityRpcStoreExtensions +{ +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static System.Int32 RandomNumber(this TClient client,System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) where TClient: +TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ +object[] @_parameters = new object[]{a,b}; +System.Int32 returnData=(System.Int32)client.Invoke("RandomNumber",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///无注释信息 +/// +public static async Task RandomNumberAsync(this TClient client,System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) where TClient: +TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ +object[] parameters = new object[]{a,b}; +return (System.Int32) await client.InvokeAsync("RandomNumber",typeof(System.Int32),invokeOption, parameters); + +} + +} +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Client_JsonRPCDmtp.cs b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Client_JsonRPCDmtp.cs new file mode 100644 index 000000000..4c18a61dd --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Client_JsonRPCDmtp.cs @@ -0,0 +1,98 @@ +/* +此代码由Rpc工具直接生成,非必要请不要修改此处代码 +*/ +#pragma warning disable +using System; +using TouchSocket.Core; +using TouchSocket.Sockets; +using TouchSocket.Rpc; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Threading.Tasks; +namespace UnityRpcProxy +{ +public interface IReverseJsonRpcServer:TouchSocket.Rpc.IRemoteServer +{ +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +System.Int32 Add(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default); +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task AddAsync(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default); + +} +public class ReverseJsonRpcServer :IReverseJsonRpcServer +{ +public ReverseJsonRpcServer(IRpcClient client) +{ +this.Client=client; +} +public IRpcClient Client{get;private set; } +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public System.Int32 Add(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{a,b}; +System.Int32 returnData=(System.Int32)this.Client.Invoke("Add",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///无注释信息 +/// +public async Task AddAsync(System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{a,b}; +return (System.Int32) await this.Client.InvokeAsync("Add",typeof(System.Int32),invokeOption, parameters); + +} + +} +public static class ReverseJsonRpcServerExtensions +{ +/// +///无注释信息 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static System.Int32 Add(this TClient client,System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{a,b}; +System.Int32 returnData=(System.Int32)client.Invoke("Add",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///无注释信息 +/// +public static async Task AddAsync(this TClient client,System.Int32 a,System.Int32 b,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{a,b}; +return (System.Int32) await client.InvokeAsync("Add",typeof(System.Int32),invokeOption, parameters); + +} + +} +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_HttpDmtp.cs b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_HttpDmtp.cs new file mode 100644 index 000000000..42e1f44ac --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_HttpDmtp.cs @@ -0,0 +1,180 @@ +/* +此代码由Rpc工具直接生成,非必要请不要修改此处代码 +*/ +#pragma warning disable +using System; +using TouchSocket.Core; +using TouchSocket.Sockets; +using TouchSocket.Rpc; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Threading.Tasks; +namespace UnityRpcProxy_HttpDmtp +{ +public interface IUnityRpcStore:TouchSocket.Rpc.IRemoteServer +{ +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +LoginModelResult DmtpRpc_Login(LoginModel model,IInvokeOption invokeOption = default); +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task DmtpRpc_LoginAsync(LoginModel model,IInvokeOption invokeOption = default); + +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +System.Int32 DmtpRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default); +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task DmtpRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default); + +} +public class UnityRpcStore :IUnityRpcStore +{ +public UnityRpcStore(IRpcClient client) +{ +this.Client=client; +} +public IRpcClient Client{get;private set; } +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public LoginModelResult DmtpRpc_Login(LoginModel model,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{model}; +LoginModelResult returnData=(LoginModelResult)this.Client.Invoke("DmtpRpc_Login",typeof(LoginModelResult),invokeOption, @_parameters); +return returnData; + +} +/// +///登录 +/// +public async Task DmtpRpc_LoginAsync(LoginModel model,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{model}; +return (LoginModelResult) await this.Client.InvokeAsync("DmtpRpc_Login",typeof(LoginModelResult),invokeOption, parameters); + +} + +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public System.Int32 DmtpRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{i}; +System.Int32 returnData=(System.Int32)this.Client.Invoke("DmtpRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///性能测试 +/// +public async Task DmtpRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{i}; +return (System.Int32) await this.Client.InvokeAsync("DmtpRpc_Performance",typeof(System.Int32),invokeOption, parameters); + +} + +} +public static class UnityRpcStoreExtensions +{ +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static LoginModelResult DmtpRpc_Login(this TClient client,LoginModel model,IInvokeOption invokeOption = default) where TClient: +TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ +object[] @_parameters = new object[]{model}; +LoginModelResult returnData=(LoginModelResult)client.Invoke("DmtpRpc_Login",typeof(LoginModelResult),invokeOption, @_parameters); +return returnData; + +} +/// +///登录 +/// +public static async Task DmtpRpc_LoginAsync(this TClient client,LoginModel model,IInvokeOption invokeOption = default) where TClient: +TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ +object[] parameters = new object[]{model}; +return (LoginModelResult) await client.InvokeAsync("DmtpRpc_Login",typeof(LoginModelResult),invokeOption, parameters); + +} + +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static System.Int32 DmtpRpc_Performance(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: +TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ +object[] @_parameters = new object[]{i}; +System.Int32 returnData=(System.Int32)client.Invoke("DmtpRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///性能测试 +/// +public static async Task DmtpRpc_PerformanceAsync(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: +TouchSocket.Dmtp.Rpc.IDmtpRpcActor{ +object[] parameters = new object[]{i}; +return (System.Int32) await client.InvokeAsync("DmtpRpc_Performance",typeof(System.Int32),invokeOption, parameters); + +} + +} +public class LoginModelResult +{ +public TouchSocket.Core.ResultCode ResultCode { get; set; } +public System.String Message { get; set; } +} + +public class LoginModel +{ +public System.String Token { get; set; } +public System.String Account { get; set; } +public System.String Password { get; set; } +} + +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Json_HttpDmtp.cs b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Json_HttpDmtp.cs new file mode 100644 index 000000000..63349c337 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/RPCStore/UnityRpcProxy_Json_HttpDmtp.cs @@ -0,0 +1,180 @@ +/* +此代码由Rpc工具直接生成,非必要请不要修改此处代码 +*/ +#pragma warning disable +using System; +using TouchSocket.Core; +using TouchSocket.Sockets; +using TouchSocket.Rpc; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using System.Threading.Tasks; +namespace UnityRpcProxy_Json_HttpDmtp +{ +public interface IUnityRpcStore:TouchSocket.Rpc.IRemoteServer +{ +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +LoginModelResult JsonRpc_Login(LoginModel model,IInvokeOption invokeOption = default); +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task JsonRpc_LoginAsync(LoginModel model,IInvokeOption invokeOption = default); + +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +System.Int32 JsonRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default); +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +Task JsonRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default); + +} +public class UnityRpcStore :IUnityRpcStore +{ +public UnityRpcStore(IRpcClient client) +{ +this.Client=client; +} +public IRpcClient Client{get;private set; } +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public LoginModelResult JsonRpc_Login(LoginModel model,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{model}; +LoginModelResult returnData=(LoginModelResult)this.Client.Invoke("JsonRpc_Login",typeof(LoginModelResult),invokeOption, @_parameters); +return returnData; + +} +/// +///登录 +/// +public async Task JsonRpc_LoginAsync(LoginModel model,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{model}; +return (LoginModelResult) await this.Client.InvokeAsync("JsonRpc_Login",typeof(LoginModelResult),invokeOption, parameters); + +} + +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public System.Int32 JsonRpc_Performance(System.Int32 i,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] @_parameters = new object[]{i}; +System.Int32 returnData=(System.Int32)this.Client.Invoke("JsonRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///性能测试 +/// +public async Task JsonRpc_PerformanceAsync(System.Int32 i,IInvokeOption invokeOption = default) +{ +if(this.Client==null) +{ +throw new RpcException("IRpcClient为空,请先初始化或者进行赋值"); +} +object[] parameters = new object[]{i}; +return (System.Int32) await this.Client.InvokeAsync("JsonRpc_Performance",typeof(System.Int32),invokeOption, parameters); + +} + +} +public static class UnityRpcStoreExtensions +{ +/// +///登录 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static LoginModelResult JsonRpc_Login(this TClient client,LoginModel model,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{model}; +LoginModelResult returnData=(LoginModelResult)client.Invoke("JsonRpc_Login",typeof(LoginModelResult),invokeOption, @_parameters); +return returnData; + +} +/// +///登录 +/// +public static async Task JsonRpc_LoginAsync(this TClient client,LoginModel model,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{model}; +return (LoginModelResult) await client.InvokeAsync("JsonRpc_Login",typeof(LoginModelResult),invokeOption, parameters); + +} + +/// +///性能测试 +/// +/// 调用超时 +/// Rpc调用异常 +/// 其他异常 +public static System.Int32 JsonRpc_Performance(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] @_parameters = new object[]{i}; +System.Int32 returnData=(System.Int32)client.Invoke("JsonRpc_Performance",typeof(System.Int32),invokeOption, @_parameters); +return returnData; + +} +/// +///性能测试 +/// +public static async Task JsonRpc_PerformanceAsync(this TClient client,System.Int32 i,IInvokeOption invokeOption = default) where TClient: +TouchSocket.JsonRpc.IJsonRpcClient{ +object[] parameters = new object[]{i}; +return (System.Int32) await client.InvokeAsync("JsonRpc_Performance",typeof(System.Int32),invokeOption, parameters); + +} + +} +public class LoginModelResult +{ +public TouchSocket.Core.ResultCode ResultCode { get; set; } +public System.String Message { get; set; } +} + +public class LoginModel +{ +public System.String Token { get; set; } +public System.String Account { get; set; } +public System.String Password { get; set; } +} + +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/BaseTouchServer.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/BaseTouchServer.cs new file mode 100644 index 000000000..837fa40f9 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/BaseTouchServer.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UnityServerConsoleApp_All.TouchServer +{ + /// + /// 基础网络服务接口 + /// + public interface BaseTouchServer + { + /// + /// 启动服务 + /// + /// + Task StartService(int port); + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_HttpDmtp.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_HttpDmtp.cs new file mode 100644 index 000000000..998a00be6 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_HttpDmtp.cs @@ -0,0 +1,170 @@ +using TouchSocket.Core; +using TouchSocket.Dmtp; +using TouchSocket.Dmtp.Rpc; +using TouchSocket.Rpc; +using TouchSocket.Sockets; +using UnityRpcProxy; + +namespace UnityServerConsoleApp_All.TouchServer +{ + /// + /// HTTP_Dmtp 网络服务 + /// + public class Touch_HttpDmtp : BaseTouchServer + { + HttpDmtpService dmtpService = new HttpDmtpService(); + public async Task StartService(int port) + { + var config = new TouchSocketConfig()//配置 + .SetListenIPHosts(port) + + .ConfigureContainer(a => + { + a.AddConsoleLogger();//注册一个日志组 + + //注册rpc服务 + a.AddRpcStore(store => + { + store.RegisterServer(); +#if DEBUG + var code = store.GetProxyCodes("UnityRpcProxy_HttpDmtp", typeof(DmtpRpcAttribute)); + File.WriteAllText("../../../RPCStore/UnityRpcProxy_HttpDmtp.cs", code); +#endif + }); + }) + .ConfigurePlugins(a => + { + //启用dmtp rpc插件 + a.UseDmtpRpc(); + + a.Add(); + + }) + .SetDmtpOption(new DmtpOption() + { + VerifyToken = "Dmtp"//设置验证token + }); + + await dmtpService.SetupAsync(config); + await dmtpService.StartAsync(); + + + dmtpService.Logger.Info($"Dmtp已启动,监听端口:{port}"); + } + + /// + /// 状态日志打印插件 + /// + internal class Touch_Dmtp_Log_Plguin : PluginBase, IDmtpHandshakedPlugin, IDmtpClosedPlugin, IDmtpCreatedChannelPlugin + { + public async Task OnDmtpClosed(IDmtpActorObject client, ClosedEventArgs e) + { + if (client is HttpDmtpSessionClient clientSession) + { + clientSession.Logger.Info($"HTTP_DMTP:客户端{clientSession.IP}已断开"); + clientSession.StopReverseRPC(); + } + await e.InvokeNext(); + } + + public async Task OnDmtpCreatedChannel(IDmtpActorObject client, CreateChannelEventArgs e) + { + if (client.TrySubscribeChannel(e.ChannelId, out var channel)) + { + //设定读取超时时间 + //channel.Timeout = TimeSpan.FromSeconds(30); + using (channel) + { + client.DmtpActor.Logger.Info("通道开始接收"); + //此判断主要是探测是否有Hold操作 + while (channel.CanMoveNext) + { + long count = 0; + foreach (var byteBlock in channel) + { + //这里处理数据 + count += byteBlock.Length; + client.DmtpActor.Logger.Info($"通道已接收:{count}字节"); + } + + client.DmtpActor.Logger.Info($"通道接收结束,状态={channel.Status},短语={channel.LastOperationMes},共接收{count / (1048576.0):0.00}Mb字节"); + } + } + } + + await e.InvokeNext(); + } + + public async Task OnDmtpHandshaked(IDmtpActorObject client, DmtpVerifyEventArgs e) + { + if (client is HttpDmtpSessionClient clientSession) + { + clientSession.Logger.Info($"HTTP_DMTP:客户端{clientSession.IP}已连接"); + //有新的客户端连接后,调用执行RandomNumber函数 + clientSession.StartReverseRPC(); + + + } + await e.InvokeNext(); + } + + + } + + /// + /// 自定义HttpDmtpService + /// + internal class HttpDmtpService : TouchSocket.Dmtp.HttpDmtpService + { + protected override HttpDmtpSessionClient NewClient() + { + return new HttpDmtpSessionClient(); + } + } + + /// + /// 自定义HttpDmtpSessionClient + /// + internal class HttpDmtpSessionClient : TouchSocket.Dmtp.HttpDmtpSessionClient { + + Timer timer; + internal void StartReverseRPC() { + timer = new Timer(ClientReverseRPC, null, 1 * 1000, 10 * 1000); + } + + Random Random = new Random(); + async void ClientReverseRPC(object? client) + { + if (Online) + { + var a = Random.Next(100000000); + var b = Random.Next(100000000); + var c = a + b; + try + { + var d = await this.GetDmtpRpcActor().RandomNumberAsync(a, b); + if (c != d) + { + Logger.Info("客户端计算数据不对"); + } + } + catch (Exception e) + { + StopReverseRPC(); + } + + } + else + { + StopReverseRPC(); + } + } + + internal void StopReverseRPC() { + timer.Dispose(); + timer = null; + } + } + } + +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_JsonWebSocket.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_JsonWebSocket.cs new file mode 100644 index 000000000..cffc37079 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_JsonWebSocket.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TouchSocket.Core; +using TouchSocket.Dmtp; +using TouchSocket.Dmtp.Rpc; +using TouchSocket.Http; +using TouchSocket.Http.WebSockets; +using TouchSocket.JsonRpc; +using TouchSocket.Rpc; +using TouchSocket.Sockets; +using UnityRpcProxy; + +namespace UnityServerConsoleApp_All.TouchServer +{ + /// + /// Web Socket + /// + public class Touch_JsonWebSocket : BaseTouchServer + { + JsonHttpDmtpService dmtpService = new JsonHttpDmtpService(); + public async Task StartService(int port) + { + var config = new TouchSocketConfig()//配置 + .SetListenIPHosts(port) + + .ConfigureContainer(a => + { + a.AddConsoleLogger();//注册一个日志组 + + //注册rpc服务 + a.AddRpcStore(store => + { + store.RegisterServer(); +#if DEBUG + var code = store.GetProxyCodes("UnityRpcProxy_Json_HttpDmtp", typeof(JsonRpcAttribute)); + File.WriteAllText("../../../RPCStore/UnityRpcProxy_Json_HttpDmtp.cs", code); +#endif + }); + }) + .ConfigurePlugins(a => + { + a.UseWebSocket() + .SetWSUrl("/ws"); + + //启用json rpc插件 + a.UseWebSocketJsonRpc() + .SetAllowJsonRpc((websocket, context) => true);//让所有请求WebSocket都加载JsonRpc插件 + + + a.Add(); + + }); + + await dmtpService.SetupAsync(config); + await dmtpService.StartAsync(); + + + dmtpService.Logger.Info($"TCP_JsonWebSocket已启动,监听端口:{port}"); + } + } + /// + /// 状态日志打印插件 + /// + internal class Touch_JsonWebSocket_Log_Plguin : PluginBase, IWebSocketHandshakedPlugin, IWebSocketClosedPlugin + //,IWebSocketReceivedPlugin + { + + public async Task OnWebSocketClosed(IWebSocket webSocket, ClosedEventArgs e) + { + webSocket.Client.Logger.Info($"TCP_WebSocket:客户端{webSocket.Client.IP}已断开"); + await e.InvokeNext(); + } + + public async Task OnWebSocketHandshaked(IWebSocket webSocket, HttpContextEventArgs e) + { + webSocket.Client.Logger.Info($"TCP_WebSocket:客户端{webSocket.Client.IP}已连接"); + await e.InvokeNext(); + } + } + + /// + /// 自定义HttpDmtpService + /// + internal class JsonHttpDmtpService : TouchSocket.Dmtp.HttpDmtpService + { + protected override JsonHttpDmtpSessionClient NewClient() + { + return new JsonHttpDmtpSessionClient(); + } + } + + /// + /// 自定义HttpDmtpSessionClient + /// + internal class JsonHttpDmtpSessionClient : TouchSocket.Dmtp.HttpDmtpSessionClient + { + + Timer timer; + public JsonHttpDmtpSessionClient() + { + timer = new Timer(ClientReverseRPC, null, 1 * 1000, 10 * 1000); + } + + Random Random = new Random(); + async void ClientReverseRPC(object? client) + { + if (Online) + { + try + { + await this.GetJsonRpcActionClient().AddAsync(1, 2); + } + catch (Exception e) + { + Console.WriteLine(e); + StopReverseRPC(); + } + + } + else + { + StopReverseRPC(); + } + } + + internal void StopReverseRPC() + { + timer?.Dispose(); + } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_TCP.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_TCP.cs new file mode 100644 index 000000000..d2ba66c73 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_TCP.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TouchSocket.Core; +using TouchSocket.Sockets; + +namespace UnityServerConsoleApp_All.TouchServer +{ + /// + /// TCP 网络服务 + /// + public class Touch_TCP : BaseTouchServer + { + TcpService tcpService = new TcpService(); + public async Task StartService(int port) + { + await tcpService.SetupAsync(new TouchSocketConfig()//载入配置 + .SetListenIPHosts(new IPHost(port)) + .SetTcpDataHandlingAdapter(() => new FixedHeaderPackageAdapter()) + .ConfigurePlugins(a => + { + a.Add();//此处可以添加插件 + }) + .ConfigureContainer(a => + { + a.AddConsoleLogger();//添加一个日志注入 + })); + await tcpService.StartAsync();//启动 + tcpService.Logger.Info($"Tcp服务器已启动,端口{port}"); + } + } + + /// + /// 状态日志打印插件 + /// + class Touch_TCP_Log_Plguin : PluginBase, ITcpConnectedPlugin, ITcpClosedPlugin, ITcpReceivedPlugin + { + public async Task OnTcpClosed(ITcpSession client, ClosedEventArgs e) + { + client.Logger.Info($"TCP:客户端{client.GetIPPort()}已断开"); + await e.InvokeNext(); + } + + public async Task OnTcpConnected(ITcpSession client, ConnectedEventArgs e) + { + client.Logger.Info($"TCP:客户端{client.GetIPPort()}已连接"); + await e.InvokeNext(); + } + + + public async Task OnTcpReceived(ITcpSession client, ReceivedDataEventArgs e) + { + client.Logger.Info($"TCP:接收到信息:{e.ByteBlock.Span.ToString(Encoding.UTF8)}"); + + if (client is ITcpSessionClient sessionClient) + { + await sessionClient.SendAsync($"TCP:服务器已收到你发送的消息:{e.ByteBlock.ToString()}"); + } + await e.InvokeNext(); + } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_UDP.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_UDP.cs new file mode 100644 index 000000000..077bd9bfe --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_UDP.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using TouchSocket.Core; +using TouchSocket.Sockets; + +namespace UnityServerConsoleApp_All.TouchServer +{ + + /// + /// UDP 网络服务 + /// + public class Touch_UDP : BaseTouchServer + { + UdpSession udpService = new UdpSession(); + public async Task StartService(int port) + { + await udpService.SetupAsync(new TouchSocketConfig() + .SetBindIPHost(new IPHost(port)) + .SetUdpDataHandlingAdapter(() => new NormalUdpDataHandlingAdapter())//常规udp + //.SetUdpDataHandlingAdapter(() => new UdpPackageAdapter())//Udp包模式,支持超过64k数据。 + .ConfigurePlugins(a => + { + a.Add();//此处可以添加插件 + }) + .ConfigureContainer(a => + { + a.AddConsoleLogger();//添加一个日志注入 + })); + await udpService.StartAsync(); + + udpService.Logger.Info($"UdpService已启动,端口:{port}"); + } + /// + /// 状态日志打印插件 + /// + class Touch_UDP_Log_Plguin : PluginBase, IUdpReceivedPlugin + { + public async Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e) + { + client.Logger.Info($"UDP:收到:{e.ByteBlock.Span.ToString(Encoding.UTF8)}"); + if (client is UdpSession session) + { + await session.SendAsync(e.EndPoint, "UDP:" + e.EndPoint.ToString()+ "收到了你的消息:" + e.ByteBlock.Span.ToString(Encoding.UTF8)); + } + await e.InvokeNext(); + } + } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_WebSocket.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_WebSocket.cs new file mode 100644 index 000000000..30b2e4fc5 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/Touch_WebSocket.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TouchSocket.Core; +using TouchSocket.Dmtp; +using TouchSocket.Dmtp.Rpc; +using TouchSocket.Http; +using TouchSocket.Http.WebSockets; +using TouchSocket.Rpc; +using TouchSocket.Sockets; + +namespace UnityServerConsoleApp_All.TouchServer +{ + /// + /// Web Socket + /// + public class Touch_WebSocket : BaseTouchServer + { + HttpDmtpService dmtpService = new HttpDmtpService(); + public async Task StartService(int port) + { + var config = new TouchSocketConfig()//配置 + .SetListenIPHosts(port) + + .ConfigureContainer(a => + { + a.AddConsoleLogger();//注册一个日志组 + }) + .ConfigurePlugins(a => + { + a.UseWebSocket() + .SetWSUrl("/ws"); + + a.Add(); + + }); + + await dmtpService.SetupAsync(config); + await dmtpService.StartAsync(); + + + dmtpService.Logger.Info($"TCP_WebSocket已启动,监听端口:{port}"); + } + } + /// + /// 状态日志打印插件 + /// + internal class Touch_WebSocket_Log_Plguin : PluginBase, IWebSocketHandshakedPlugin, IWebSocketReceivedPlugin, IWebSocketClosedPlugin + { + + public async Task OnWebSocketClosed(IWebSocket webSocket, ClosedEventArgs e) + { + webSocket.Client.Logger.Info($"TCP_WebSocket:客户端{webSocket.Client.IP}已断开"); + await e.InvokeNext(); + } + + public async Task OnWebSocketHandshaked(IWebSocket webSocket, HttpContextEventArgs e) + { + webSocket.Client.Logger.Info($"TCP_WebSocket:客户端{webSocket.Client.IP}已连接"); + await e.InvokeNext(); + } + + public async Task OnWebSocketReceived(IWebSocket webSocket, WSDataFrameEventArgs e) + { + var m_logger=webSocket.Client.Logger; + var client =webSocket; + switch (e.DataFrame.Opcode) + { + case WSDataType.Cont: + m_logger.Info($"TCP_WebSocket:收到中间数据,长度为:{e.DataFrame.PayloadLength}"); + + return; + + case WSDataType.Text: + m_logger.Info("TCP_WebSocket:"+e.DataFrame.ToText()); + + if (!client.Client.IsClient) + { + await client.SendAsync("TCP_WebSocket:我已收到"); + } + return; + + case WSDataType.Binary: + if (e.DataFrame.FIN) + { + m_logger.Info($"TCP_WebSocket:收到二进制数据,长度为:{e.DataFrame.PayloadLength}"); + } + else + { + m_logger.Info($"TCP_WebSocket:收到未结束的二进制数据,长度为:{e.DataFrame.PayloadLength}"); + } + return; + + case WSDataType.Close: + { + m_logger.Info("TCP_WebSocket:远程请求断开"); + client.Close("TCP_WebSocket:断开"); + } + return; + + case WSDataType.Ping: + break; + + case WSDataType.Pong: + break; + + default: + break; + } + + await e.InvokeNext(); + + } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/UnityRpcStore.cs b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/UnityRpcStore.cs new file mode 100644 index 000000000..6c8c597a1 --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/TouchServer/UnityRpcStore.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TouchSocket.Core; +using TouchSocket.Dmtp.Rpc; +using TouchSocket.JsonRpc; +using TouchSocket.Rpc; +using static UnityServerConsoleApp_All.TouchServer.Touch_HttpDmtp; + +namespace UnityServerConsoleApp_All.TouchServer +{ + public partial class UnityRpcStore : RpcServer + { + public UnityRpcStore(ILog logger) + { + + this.m_logger = logger; + } + + private readonly ILog m_logger; + + [Description("登录")] + [DmtpRpc(MethodInvoke = true, MethodName = "DmtpRpc_{0}")] + [JsonRpc(MethodInvoke = true, MethodName = "JsonRpc_{0}")] + public LoginModelResult Login(ICallContext callContext, LoginModel model) + { + if (callContext.Caller is HttpDmtpSessionClient session) { + Console.WriteLine("HttpDmtp:请求登陆:" + model.Account + ",Pwd:" + model.Password); + } + if (callContext.Caller is JsonHttpDmtpSessionClient jsonsession) + { + Console.WriteLine("Json_webSocket:请求登陆:" + model.Account + ",Pwd:" + model.Password); + } + + if (model.Account == "123" && model.Password == "abc") + { + return new LoginModelResult() { ResultCode = ResultCode.Success, Message = "Success" }; + } + + return new LoginModelResult() { ResultCode = ResultCode.Fail, Message = "账号或密码错误" }; + } + + [Description("性能测试")] + [DmtpRpc(MethodInvoke = true, MethodName = "DmtpRpc_{0}")] + [JsonRpc(MethodInvoke = true, MethodName = "JsonRpc_{0}")] + public int Performance(int i) + { + return ++i; + } + } + public class LoginModel + { + public string Token { get; set; } + public string Account { get; set; } + public string Password { get; set; } + } + + public class LoginModelResult + { + public ResultCode ResultCode { get; set; } + public string Message { get; set; } + } +} diff --git a/examples/Unity3d/UnityServerConsoleApp_All/UnityServerConsoleApp_All.csproj b/examples/Unity3d/UnityServerConsoleApp_All/UnityServerConsoleApp_All.csproj new file mode 100644 index 000000000..139bc84ae --- /dev/null +++ b/examples/Unity3d/UnityServerConsoleApp_All/UnityServerConsoleApp_All.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/examples/WebApi/DispatchProxyWebApiConsoleApp/DispatchProxyWebApiConsoleApp.csproj b/examples/WebApi/DispatchProxyWebApiConsoleApp/DispatchProxyWebApiConsoleApp.csproj index a2d3ad661..60bc06669 100644 --- a/examples/WebApi/DispatchProxyWebApiConsoleApp/DispatchProxyWebApiConsoleApp.csproj +++ b/examples/WebApi/DispatchProxyWebApiConsoleApp/DispatchProxyWebApiConsoleApp.csproj @@ -8,6 +8,6 @@ - + diff --git a/examples/WebApi/WebApiClientApp/WebApiClientApp.csproj b/examples/WebApi/WebApiClientApp/WebApiClientApp.csproj index 3c2ac4e1c..169edc573 100644 --- a/examples/WebApi/WebApiClientApp/WebApiClientApp.csproj +++ b/examples/WebApi/WebApiClientApp/WebApiClientApp.csproj @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git a/examples/WebApi/WebApiServer/WebApiServerApp.csproj b/examples/WebApi/WebApiServer/WebApiServerApp.csproj index 7221209b8..cebf2423b 100644 --- a/examples/WebApi/WebApiServer/WebApiServerApp.csproj +++ b/examples/WebApi/WebApiServer/WebApiServerApp.csproj @@ -6,8 +6,8 @@ - - + +