From 00199ec762586b9ba319cefd25866f6f99e7e774 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Sat, 25 May 2013 13:44:36 +0200 Subject: [PATCH] some client server changes --- .../AndroidRemote/AndroidRemote.csproj | 14 ++++--- ClientServerLib/ClientServerLib/CClient.cs | 35 ++++++++++-------- .../ClientServerLib/ClientServerLib.csproj | 6 --- ClientServerLib/ClientTest/ClientTest.csproj | 10 +++++ Output/ClientServerLib.dll | Bin 43520 -> 40448 bytes .../Base/Server}/CCommands.cs | 0 .../Base/Server}/VocaluxeStructs.cs | 0 Vocaluxe/Vocaluxe.csproj | 6 +++ 8 files changed, 44 insertions(+), 27 deletions(-) rename {ClientServerLib/ClientServerLib/Vocaluxe => Vocaluxe/Base/Server}/CCommands.cs (100%) rename {ClientServerLib/ClientServerLib/Vocaluxe => Vocaluxe/Base/Server}/VocaluxeStructs.cs (100%) diff --git a/ClientServerLib/AndroidRemote/AndroidRemote.csproj b/ClientServerLib/AndroidRemote/AndroidRemote.csproj index 91c8cc78..be3a86b4 100644 --- a/ClientServerLib/AndroidRemote/AndroidRemote.csproj +++ b/ClientServerLib/AndroidRemote/AndroidRemote.csproj @@ -70,15 +70,15 @@ ClientServerLib\DeffieHellman\StrongNumberProvider.cs - - ClientServerLib\Vocaluxe\CCommands.cs - - - ClientServerLib\Vocaluxe\VocaluxeStructs.cs - ClientServerLib\CDiscover.cs + + ClientServerLib\Server\CCommands.cs + + + ClientServerLib\Server\VocaluxeStructs.cs + @@ -93,5 +93,7 @@ + + \ No newline at end of file diff --git a/ClientServerLib/ClientServerLib/CClient.cs b/ClientServerLib/ClientServerLib/CClient.cs index 2face503..a642f55d 100644 --- a/ClientServerLib/ClientServerLib/CClient.cs +++ b/ClientServerLib/ClientServerLib/CClient.cs @@ -118,8 +118,8 @@ namespace ClientServerLib } catch { - connected = false; - RaiseOnConnectionChanged(); + DoDisconnect(); + for (int i = 0; i < 500; i++) { if (doConnect) @@ -133,17 +133,7 @@ namespace ClientServerLib if (connected && !doConnect) { - try - { - connection.TcpClient.Close(); - connection = new CConnection(new TcpClient(), -1); - } - catch - { - } - - connected = false; - RaiseOnConnectionChanged(); + DoDisconnect(); } if (doConnect && connected) @@ -154,16 +144,31 @@ namespace ClientServerLib } catch { - connected = false; - RaiseOnConnectionChanged(); + DoDisconnect(); } } } } + private void DoDisconnect() + { + try + { + connection.TcpClient.Close(); + } + catch { } + + connection = new CConnection(new TcpClient(), -1); + connected = false; + RaiseOnConnectionChanged(); + } + private void Communicate() { + if (connection.TcpClient == null || !connection.TcpClient.Connected) + DoDisconnect(); + NetworkStream clientStream = connection.TcpClient.GetStream(); byte[] data = new byte[bufferLength]; diff --git a/ClientServerLib/ClientServerLib/ClientServerLib.csproj b/ClientServerLib/ClientServerLib/ClientServerLib.csproj index fbda0800..8b4826b3 100644 --- a/ClientServerLib/ClientServerLib/ClientServerLib.csproj +++ b/ClientServerLib/ClientServerLib/ClientServerLib.csproj @@ -31,10 +31,6 @@ 4 - - False - bin\Newtonsoft.Json.dll - @@ -53,8 +49,6 @@ - -