private void OnClientReadingEvent(TcpSocketAsync client, int position, int length) { if (this.ClientReadingEvent != null) { this.ClientReadingEvent(client, position, length); } }
private void OnClientErrorEvent(TcpSocketAsync client, Exception ex) { if (this.ClientErrorEvent != null) { this.ClientErrorEvent(client, ex); } }
private void OnAcceptEvent(TcpSocketAsync client) { if (this.AcceptEvent != null) { this.AcceptEvent(client); } }
private void OnClientReceiveEvent(TcpSocketAsync client, byte[] data, int length) { if (this.ClientReceiveEvent != null) { this.ClientReceiveEvent(client, data, length); } }
private void BeginAccept(object obj) { try { while (this.isAccept) { Socket s = this.socket.Accept(); var client = new TcpSocketAsync(s, this.SendBufferSize, this.ReceiveBufferSize); client.ErrorEvent += this.OnClientErrorEvent; client.ReceiveEvent += this.OnClientReceiveEvent; client.ReadingEvent += this.OnClientReadingEvent; this.OnAcceptEvent(client); client.BeginReceive(); } } catch (Exception ex) { this.OnServerErrorEvent(ex); } }