/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (Interlocked.CompareExchange(ref isDisposed, 1, 0) == 0) { (checkSocketVersion as IDisposable).Dispose(); if (Processor != null) { Processor.Free(); } } }
/// <summary> /// TCP 客户端套接字初始化处理 /// </summary> /// <param name="parameter"></param> private void onClientSocket(AutoCSer.Net.TcpServer.ClientSocketEventParameter parameter) { Abstract.DistributionConsumerStreamProcessor oldProcesser = Processor; switch (parameter.Type) { case AutoCSer.Net.TcpServer.ClientSocketEventParameter.EventType.SetSocket: createProcessor(); break; default: Processor = null; break; } if (oldProcesser != null) { oldProcesser.Free(); } }
/// <summary> /// TCP 客户端套接字初始化处理 /// </summary> /// <param name="socket"></param> private void onClientSocket(AutoCSer.Net.TcpServer.ClientSocketBase socket) { Abstract.DistributionConsumerStreamProcessor oldProcesser = Processor; if (socket != null) { createProcessor(); } else { Processor = null; } if (oldProcesser != null) { oldProcesser.Free(); } }
/// <summary> /// 重启处理器 /// </summary> /// <param name="processor"></param> internal void ReStartProcessor(DistributionConsumerStreamProcessor processor) { if (IsProcessor(processor)) { object setSocketLock = client._TcpClient_.OnSocketLock; Monitor.Enter(setSocketLock); try { if (IsProcessor(processor)) { Processor = null; reStartProcessor(); } } finally { Monitor.Exit(setSocketLock); } } processor.Free(); }