private HubMessage CreateHubCancelInvocationMessage(ReadOnlySpan <byte> protobufMessage)
        {
            var protobufCancelInvocationMessage = new CancelInvocationMessageProtobuf();

            protobufCancelInvocationMessage.MergeFrom(protobufMessage.ToArray());

            return(new CancelInvocationMessage(protobufCancelInvocationMessage.InvocationId)
            {
                Headers = protobufCancelInvocationMessage.Headers
            });
        }
        private void WriteCancelInvocationMessage(CancelInvocationMessage cancelInvocationMessage, IBufferWriter <byte> output)
        {
            var protobufCancelInvocationMessage = new CancelInvocationMessageProtobuf
            {
                InvocationId = cancelInvocationMessage.InvocationId
            };

            if (cancelInvocationMessage.Headers != null)
            {
                protobufCancelInvocationMessage.Headers.Add(cancelInvocationMessage.Headers);
            }

            var packedMessage = MessageDescriptor.PackMessage(HubProtocolConstants.CancelInvocationMessageType, protobufCancelInvocationMessage.ToByteArray());

            output.Write(packedMessage);
        }