private void FormatBinaryData(byte[] data) { var lastIndex = BinaryMessages.Count; var current = new BinaryLine(); if (lastIndex > 0 && BinaryMessages[lastIndex - 1].Data.Count < 16) { current = BinaryMessages.Last(); BinaryMessages.RemoveAt(lastIndex - 1); } foreach (var b in data) { current.Data.Add(b); if (current.Data.Count == 16) { BinaryMessages.Add(current); current = new BinaryLine(); } } if (current.Data.Count > 0) { BinaryMessages.Add(current); } }
protected override Task OnBinaryMessage(ArraySegment <byte> buffer) { BinaryMessages.Add(buffer); return(Task.CompletedTask); }