TransportListener(BaseUriWithWildcard pipeUri) { if (TD.PipeTransportListenerListeningStartIsEnabled()) { TD.PipeTransportListenerListeningStart(this.EventTraceActivity, (pipeUri.BaseAddress != null) ? pipeUri.BaseAddress.ToString() : string.Empty); } transportType = TransportType.NamedPipe; IConnectionListener connectionListener = new PipeConnectionListener(pipeUri.BaseAddress, pipeUri.HostNameComparisonMode, ListenerConstants.SharedConnectionBufferSize, null, false, int.MaxValue); demuxer = Go(connectionListener); if (TD.PipeTransportListenerListeningStopIsEnabled()) { TD.PipeTransportListenerListeningStop(this.EventTraceActivity); } }
public void Run(EventWaitHandle serverStartWaitHandle) { this.World.TickStarted += OnTickStarted; this.World.TickEnded += OnTickEnded; this.World.TurnStarting += OnTurnStarting; this.World.TurnEnded += OnTurnEnded; PipeConnectionListener.StartListening(_OnNewConnection); TcpConnectionListener.StartListening(_OnNewConnection, "SNet"); DirectConnectionListener.StartListening(_OnNewConnection); trace.TraceInformation("The server is ready."); if (serverStartWaitHandle != null) { serverStartWaitHandle.Set(); } CheckForStartTick(); // Enter the main loop m_dispatcher.Run(MainWork); trace.TraceInformation("Server exiting"); DirectConnectionListener.StopListening(); TcpConnectionListener.StopListening(); PipeConnectionListener.StopListening(); this.World.TurnEnded -= OnTurnEnded; this.World.TurnStarting -= OnTurnStarting; this.World.TickEnded -= OnTickEnded; this.World.TickStarted -= OnTickStarted; // Need to disconnect the sockets foreach (var user in m_users) { if (user.IsConnected) { user.Disconnect(); } } trace.TraceInformation("Server exit"); }