public BinaryDeserializer() { _buffer = new MemoryStream(); _message = null; _length = -1; _partLength = 0; OnDeserializedValue += (value) => { if (_length == -1) { _length = (int)value; } else { if (_message == null) { _message = new Message((string)value); } else { _message.Add(value); } if (_length == _message.Count) { OnDeserializedMessage?.Invoke(_message); _message = null; _length = -1; } } State = EnumState.INIT; }; }