public void Test() { byte[] encryptionKey = new byte[16]; Random.NextBytes(encryptionKey); Console.WriteLine("Starting server"); DoubleServerHandler serverHandler = new DoubleServerHandler(); DoubleServer server = new DoubleServer(serverHandler, 1, 1, Port); serverHandler.Server = server; Console.WriteLine("Starting client"); DoubleClientHandler clientHandler = new DoubleClientHandler(); DoubleClient client = new DoubleClient(clientHandler, encryptionKey, encryptionKey, Ip, Port); clientHandler.Client = client; client.Start(); lock (client) { clientHandler.MaySend = true; Monitor.Pulse(client); Console.WriteLine("Main thread waiting"); Monitor.Wait(client); } Console.WriteLine("Closing client"); client.Close(); Console.WriteLine("Closing server"); server.Close(); }
private void OnDisconnectButtonClick(object sender, RoutedEventArgs e) { lock (_client) { if (_client.CurrentState == DoubleClient.State.Disconnected) { return; } _client.Close(); OnDisconnected("Disconnected"); } }