diff --git "a/examples/Adapter\347\256\200\345\215\225\347\244\272\344\276\213/AdapterConsoleApp/Program.cs" "b/examples/Adapter\347\256\200\345\215\225\347\244\272\344\276\213/AdapterConsoleApp/Program.cs" index 612b10fcc34e551b7c85b2a17ba90ed2410d7822..b8b84f6ee8142f93ae90291a6721c18590ce9a31 100644 --- "a/examples/Adapter\347\256\200\345\215\225\347\244\272\344\276\213/AdapterConsoleApp/Program.cs" +++ "b/examples/Adapter\347\256\200\345\215\225\347\244\272\344\276\213/AdapterConsoleApp/Program.cs" @@ -42,11 +42,6 @@ namespace AdapterConsoleApp private static void StartTcpService() { TcpService service = new TcpService(); - service.Connecting += (client, e) => - { - //有客户端正在连接 - client.SetDataHandlingAdapter(new MyCustomBetweenAndDataHandlingAdapter()); - }; service.Connected += (client, e) => { };//有客户端连接 service.Disconnected += (client, e) => { };//有客户端断开连接 service.Received += (client, byteBlock, requestInfo) => diff --git "a/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusClient/EventBusClient.csproj" "b/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusClient/EventBusClient.csproj" index 2107185ec68573e62aae4cbd0f7ce8d6e047e440..9ffd4ffb9b028e688a8f91d7fcca14079cf2164e 100644 --- "a/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusClient/EventBusClient.csproj" +++ "b/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusClient/EventBusClient.csproj" @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git "a/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusServer/EventBusServer.csproj" "b/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusServer/EventBusServer.csproj" index b16ac804de9bc50cffdae9d94a2770d1af43ed9f..fe68c433e482bc56d5e4c64c3d074bead74611a1 100644 --- "a/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusServer/EventBusServer.csproj" +++ "b/examples/EventBus\347\256\200\345\215\225\347\244\272\344\276\213/EventBusServer/EventBusServer.csproj" @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git "a/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/NATServiceConsoleApp.csproj" "b/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/NATServiceConsoleApp.csproj" index a04c784407b86e1877709612a3ac40fbed9565e0..ea7f53613e8911298068443f27236d28652b985c 100644 --- "a/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/NATServiceConsoleApp.csproj" +++ "b/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/NATServiceConsoleApp.csproj" @@ -6,7 +6,7 @@ - + diff --git "a/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/Program.cs" "b/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/Program.cs" index bc4fb04a5f436ce8616161ba7e3ca01cfbc39417..34fe327e129bb5d5ec01b4aa1c7b1851628ef64a 100644 --- "a/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/Program.cs" +++ "b/examples/NAT\347\256\200\345\215\225\347\244\272\344\276\213/NATServiceConsoleApp/Program.cs" @@ -3,7 +3,9 @@ using TouchSocket.Core; using TouchSocket.Core.ByteManager; using TouchSocket.Core.Config; using TouchSocket.Core.Log; +using TouchSocket.Core.Plugins; using TouchSocket.Sockets; +using TouchSocket.Sockets.Plugins; namespace NATServiceConsoleApp { @@ -18,7 +20,7 @@ namespace NATServiceConsoleApp service.Setup(config); service.Start(); - Console.WriteLine("转发服务器已启动。已将7788端口转发到127.0.0.1:7789与127.0.0.1:7790地址"); + Console.WriteLine("转发服务器已启动。已将7788端口转发到127.0.0.1:7789地址"); } } @@ -32,8 +34,15 @@ namespace NATServiceConsoleApp { //此处模拟的是只要连接到NAT服务器,就转发。 //实际上,这个方法可以随时调用。 - socketClient.AddTargetClient(new TouchSocketConfig().SetRemoteIPHost("127.0.0.1:7789")); - socketClient.AddTargetClient(new TouchSocketConfig().SetRemoteIPHost("127.0.0.1:7790")); + socketClient.AddTargetClient(new TouchSocketConfig() + .SetRemoteIPHost("127.0.0.1:7789") + .ConfigurePlugins(a=> + { + //在企业版中,使用以下任意方式,可实现转发客户端的断线重连。 + a.Add>() + .SetTick(1000);//每秒检查 + //a.UseReconnection(); + })); } catch (Exception ex) { diff --git "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UdpDemoApp/Form1.cs" "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UdpDemoApp/Form1.cs" index 415b33d116e55f3c9b4c17065fc62342c524b9b0..3c9915c0fbdddf22577c4903efbb54ab05df7ddb 100644 --- "a/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UdpDemoApp/Form1.cs" +++ "b/examples/Udp\347\256\200\345\215\225\347\244\272\344\276\213/UdpDemoApp/Form1.cs" @@ -32,16 +32,20 @@ namespace UdpDemoApp } }; - if (checkBox1.Checked) - { - m_udpSession.SetDataHandlingAdapter(new UdpPackageAdapter()); - } - else - { - m_udpSession.SetDataHandlingAdapter(new NormalUdpDataHandlingAdapter()); - } + m_udpSession.Setup(new TouchSocketConfig() .SetBindIPHost(new IPHost(this.textBox2.Text)) + .SetUdpDataHandlingAdapter(()=> + { + if (checkBox1.Checked) + { + return new UdpPackageAdapter(); + } + else + { + return new NormalUdpDataHandlingAdapter(); + } + }) .ConfigureContainer(a => { a.SetSingletonLogger(new LoggerGroup(new EasyLogger(this.ShowMsg), new FileLogger()));