/// <summary> /// Event triggered on data read /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDataRead(object sender, IgbClientDataReadEventArgs e) { IgbTcpClient IgbSender = (IgbTcpClient)sender; byte[] newBuf; lock (m_clients) { byte[] existingBuf = m_clients[IgbSender]; newBuf = new byte[existingBuf.Length + e.Count]; Array.Copy(existingBuf, newBuf, existingBuf.Length); Array.Copy(e.Buffer, 0, newBuf, existingBuf.Length, e.Count); m_clients[IgbSender] = newBuf; } TryProcessBuffer(IgbSender, newBuf, Math.Min(e.Count + 1, newBuf.Length)); }
/// <summary> /// Event triggered on data read. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDataRead(object sender, IgbClientDataReadEventArgs e) { IgbTcpClient igbSender = (IgbTcpClient)sender; byte[] newBuf; lock (m_clients) { byte[] existingBuf = m_clients[igbSender]; newBuf = new byte[existingBuf.Length + e.Count]; Array.Copy(existingBuf, newBuf, existingBuf.Length); Array.Copy(e.Buffer.ToArray(), 0, newBuf, existingBuf.Length, e.Count); m_clients[igbSender] = newBuf; } TryProcessBuffer(igbSender, newBuf, Math.Min(e.Count + 1, newBuf.Length)); }