internal void SocketAcceptCallback(IAsyncResult ar) { if (!this.Disposed) { Socket pAcceptedSocket = null; SocketListener pListener = null; ConnectionManage pConnection = null; try { pListener = (SocketListener)ar.AsyncState; pAcceptedSocket = pListener.CurrentSocket.EndAccept(ar); pAcceptedSocket.ReceiveBufferSize = this.Service.SocketBufferSize; pAcceptedSocket.SendBufferSize = this.Service.SocketBufferSize; pConnection = new ServerConnect(pAcceptedSocket, pListener, this.Service); pConnection.Active = true; this.Service.AddConnection(pConnection); ThreadPool.QueueUserWorkItem(new WaitCallback(this.Initialize), pConnection); } catch (Exception ex) { this.Service.SocketExceptionEvent(pConnection, ex); } finally { pListener.CurrentSocket.BeginAccept(new AsyncCallback(SocketAcceptCallback), pListener); } } }
internal override void SendTo(ServerConnect pServerConnect, byte[] pBuffer, bool bAllConnection) { if (!this.Disposed) { ConnectionManage[] pConnectionItmes = this.GetConnections(); if (pConnectionItmes != null) { int iLoopSleep = 0; foreach (ConnectionManage pConnection in pConnectionItmes) { if (this.Disposed) { break; } try { if (bAllConnection || pServerConnect != pConnection) { byte[] pSendBuffer = new byte[pBuffer.Length]; Buffer.BlockCopy(pBuffer, 0, pSendBuffer, 0, pBuffer.Length); this.SendTo(pConnection, pSendBuffer); } } finally { ThreadLoop.LoopSleep(ref iLoopSleep); } //end try...finally... } //end foreach(...) } //end if(...) } //end if(...) }
internal abstract void SendTo(ServerConnect pServerConnect, byte[] pBuffer, bool bAllConnection);
internal override void SendTo(ServerConnect pServerConnect, byte[] pBuffer, bool bAllConnection) { }