/// <summary> /// Cstr for OutboundBaseStreamWireMessage given /// Message Header Info: Protocol Kind, pertinent stream id and message sequence # /// </summary> /// <param name="kind">StreamWireProtocolMessageKind</param> /// <param name="streamId">Stream Id</param> /// <param name="sequenceNumber">Message Sequence number</param> protected OutboundBaseStreamWireMessage(StreamWireProtocolMessageKind kind, Guid streamId, long sequenceNumber) { // Stream Version this.protocolVersion.MajorVersion = StreamConstants.CurrentStreamMajorProtocolVersion; this.protocolVersion.MinorVersion = StreamConstants.CurrentStreamMinorProtocolVersion; // Message Info. this.Kind = kind; this.StreamIdentity = streamId; this.MessageSequenceNumber = sequenceNumber; this.Payload = null; // Encode this.EncodeHeaderBuffer(); }
/// <summary> /// Cstor for InboundProtocolResponseValue /// Validate the payload for valid protocol response and store. /// </summary> /// <param name="inboundStreamMessage"></param> /// <param name="expectedType"></param> internal InboundProtocolResponseValue(InboundBaseStreamWireMessage inboundStreamMessage, StreamWireProtocolMessageKind expectedType) { Diagnostics.Assert( inboundStreamMessage.Kind == expectedType, "Unexpected StreamWireProtocolMessageKind in InboundBaseStreamWireMessage used to construct InboundProtocolResponseValue"); Diagnostics.Assert( inboundStreamMessage.Payload != null, "null ProtocolResponseValue payload in InboundBaseStreamWireMessage used to construct InboundProtocolResponseValue"); Diagnostics.Assert( inboundStreamMessage.Payload.Length == sizeof(int), "payload in InboundBaseStreamWireMessage used to construct InboundProtocolResponseValue contains more than ProtocolResponseValue"); // Store appropriate decoded Protocol Response this.Response = (StreamWireProtocolResponse)BitConverter.ToInt32(inboundStreamMessage.Payload, 0); }
internal OutboundProtocolResponseWireMessage(Guid streamId, StreamWireProtocolMessageKind messageKind, StreamWireProtocolResponse response) : base(messageKind, streamId, StreamConstants.StreamProtocolResponseMessageSequenceNumber) { this.Payload = BitConverter.GetBytes((int)response); }