/// <summary> /// Called when an incoming connection has been accepted. /// </summary> /// <param name="ar"></param> protected virtual void EndAcceptCallback(IAsyncResult ar) { ProxySocket listenSocket = (ProxySocket)ar.AsyncState; try { dcSocket = listenSocket.EndAccept(ar); DCState = DirectConnectionState.Foo; Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "I have listened on " + dcSocket.LocalEndPoint + " and setup a DC with " + dcSocket.RemoteEndPoint, GetType().Name); // Stop listening StopListening(); // Begin accepting messages Processor.BeginDataReceive(dcSocket); OnConnected(); } catch (Exception ex) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, GetType().ToString() + " Error: " + ex.Message); } }