/// <summary> /// Raises the Received event. /// </summary> /// <param name="e">A <see cref="ReceivedEventArgs"/> that contains the event data.</param> protected void OnReceived(ReceivedEventArgs e) { if (this.Received != null) { this.Received(this, e); } }
private void Socket_Received(object sender, ReceivedEventArgs e) { if (e.BytesRead <= 0) { if (this.Handler != null) { this.CloseSocket(); } return; } var readBytes = e.Buffer.Take(e.BytesRead); if (this.Handler != null) { this.Handler.ProcessData(readBytes); } else { this.data.AddRange(readBytes); this.CreateHandler(this.data); } this.Read(e.Buffer); }