public virtual void Start(INodeEndpointServerCallback <T> callback) { if (this.serverState != NodeEndpointServerState.Ready) { throw new InvalidOperationException("The server cannot be started."); } this.callback = callback; this.ProtocolFactory = this.callback.ProtocolFactory; this.ServerListener = this.ProtocolFactory.CreateServerListener(); this.serverListenerThread = new Thread(ServerListenerThreadProc); this.serverListenerThread.Start(); this.serverState = NodeEndpointServerState.Running; }
public virtual void Stop() { if (this.serverState != NodeEndpointServerState.Running) { throw new InvalidOperationException("The server cannot be stopped."); } this.needToStop = true; if (!this.serverListenerThread.Join(NodeEndpointProtocolFactoryExtension.DefaultTimeout)) { this.serverListenerThread.Abort(); } ClearServices(false); this.ServerListener.Disconnect(); this.ServerListener = null; this.serverState = NodeEndpointServerState.Stopped; }