public virtual void StopNetwork() { Acceptor.Close(); if (_threadCount != 0) { for (int i = 0; i < _threadCount; ++i) { _threads[i].Stop(); } } Wait(); Acceptor = null; _threads = null; _threadCount = 0; }
public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1) { Contract.Assert(threadCount > 0); Acceptor = new AsyncAcceptor(bindIp, port); _threadCount = threadCount; _threads = new NetworkThread <SocketType> [GetNetworkThreadCount()]; for (int i = 0; i < _threadCount; ++i) { _threads[i] = new NetworkThread <SocketType>(); _threads[i].Start(); } Acceptor.AsyncAcceptSocket(OnSocketOpen); return(true); }
public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1) { Cypher.Assert(threadCount > 0); Acceptor = new AsyncAcceptor(); if (!Acceptor.Start(bindIp, port)) { Log.outError(LogFilter.Network, "StartNetwork failed to Start AsyncAcceptor"); return(false); } _threadCount = threadCount; _threads = new NetworkThread <TSocketType> [GetNetworkThreadCount()]; for (int i = 0; i < _threadCount; ++i) { _threads[i] = new NetworkThread <TSocketType>(); _threads[i].Start(); } Acceptor.AsyncAcceptSocket(OnSocketOpen); return(true); }