protected override void OnExit() { CloseSocket(mSocket); mState = NetState.Close; Disposed = true; mBuffSize = 0; mPosition = 0; mBuffer = null; if (mReader != null) { mReader.Dispose(); mReader = null; } mWriterBuffer = null; if (mWriter != null) { mWriter.Dispose(); mWriter = null; } mNeedSize = HEAD_SIZE; mIsHead = true; mMsgPool = null; mHandler = null; SendBeforCallback = null; }
public NetworkThread(int bufferSize, IMsgPool msgPool, ILogger logger = null) : base(100, logger, "NetworkThread") { mBuffSize = bufferSize; mMsgPool = msgPool; mHandler = new Func <ActorCmd, ThreadResult> [NetworkInCmd.Count]; mHandler[NetworkInCmd.Close] = CloseHandler; mHandler[NetworkInCmd.Connect] = ConnectHandler; }
public NetworkCore(int bufferSize, IMsgPool msgPool = null, ILogger logger = null) { if (logger == null) { logger = new DefaultLogger("Netwrok"); } mState = NetworkState.Closed; mLogger = logger; mBufferSize = bufferSize; mMsgPool = msgPool; mHandler = new Action <ActorCmd> [NetworkOutCmd.Count]; mHandler[NetworkOutCmd.Connected] = ConnectedHandler; mHandler[NetworkOutCmd.ConnectError] = ConnErrHandler; mHandler[NetworkOutCmd.Close] = CloseHandler; mHandler[NetworkOutCmd.Message] = MessageHandler; mHandler[NetworkOutCmd.Dump] = DumpHandler; }