listener.Start();
connection.Connect();
+ Thread.Sleep(100); // Gotta wait for the server to set up the events.
listener.Dispose();
- Thread.Sleep(10);
+ Thread.Sleep(100);
Assert.IsTrue(serverConnected);
Assert.IsTrue(clientDisconnected);
listener.Start();
connection.Connect();
+
+ Thread.Sleep(100); // Gotta wait for the server to set up the events.
connection.Dispose();
Thread.Sleep(100);
connection.Connect();
connection.KeepAliveInterval = 100;
- System.Threading.Thread.Sleep(1050); //Enough time for ~10 keep alive packets
+ Thread.Sleep(1050); //Enough time for ~10 keep alive packets
Assert.AreEqual(ConnectionState.Connected, connection.State);
Assert.IsTrue(
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Text;
-
namespace Hazel
{
/// </remarks>
protected void InvokeNewConnection(MessageReader msg, Connection connection)
{
- //Make a copy to avoid race condition between null check and invocation
+ // Make a copy to avoid race condition between null check and invocation
Action<NewConnectionEventArgs> handler = NewConnection;
if (handler != null)
{
{
this.State = ConnectionState.Connecting;
- //Begin listening
try
{
if (IPMode == IPMode.IPv4)
}
catch (SocketException e)
{
- State = ConnectionState.NotConnected;
+ this.State = ConnectionState.NotConnected;
throw new HazelException("A socket exception occured while binding to the port.", e);
}
}
catch (ObjectDisposedException)
{
- //If the socket's been disposed then we can just end there but make sure we're in NotConnected state.
- //If we end up here I'm really lost...
- State = ConnectionState.NotConnected;
+ // If the socket's been disposed then we can just end there but make sure we're in NotConnected state.
+ // If we end up here I'm really lost...
+ this.State = ConnectionState.NotConnected;
return;
}
catch (SocketException e)
throw new HazelException("A Socket exception occured while initiating a receive operation.", e);
}
- //Write bytes to the server to tell it hi (and to punch a hole in our NAT, if present)
- //When acknowledged set the state to connected
- SendHello(bytes, () => { State = ConnectionState.Connected; });
+ // Write bytes to the server to tell it hi (and to punch a hole in our NAT, if present)
+ // When acknowledged set the state to connected
+ SendHello(bytes, () => { this.State = ConnectionState.Connected; });
}
/// <summary>