Пример #1
0
 public TransportMessage(MessageTypeId messageTypeId, Stream content, OriginatorInfo originator)
 {
     Id            = MessageId.NextId();
     MessageTypeId = messageTypeId;
     Content       = content;
     Originator    = originator;
 }
Пример #2
0
 public TransportMessage(MessageTypeId messageTypeId, byte[] messageBytes, OriginatorInfo originator, MessageId messageId)
 {
     Id            = messageId;
     MessageTypeId = messageTypeId;
     MessageBytes  = messageBytes;
     Originator    = originator;
 }
Пример #3
0
 public TransportMessage(MessageTypeId messageTypeId, byte[] messageBytes, OriginatorInfo originator, MessageId messageId)
 {
     Id = messageId;
     MessageTypeId = messageTypeId;
     MessageBytes = messageBytes;
     Originator = originator;
 }
Пример #4
0
        public static MessageContext CreateOverride(PeerId peerId, string peerEndPoint)
        {
            var currentContext = Current;
            var initiatorUserName = GetInitiatorUserName();

            var originator = new OriginatorInfo(peerId, peerEndPoint, CurrentMachineName, initiatorUserName);

            return new MessageContext
            {
                MessageId = MessageId.NextId(),
                Originator = originator,
                DispatchQueueName = currentContext?.DispatchQueueName,
            };
        }
Пример #5
0
        private static void Write(CodedOutputStream output, OriginatorInfo originatorInfo)
        {
            var size = 0;

            // SenderId
            var senderIdString = originatorInfo.SenderId.ToString();
            int senderIdLength;
            int senderIdStringLength;

            if (string.IsNullOrEmpty(senderIdString))
            {
                senderIdStringLength = 0;
                senderIdLength       = 0;
                size += 1 + GetMessageSizeWithLength(senderIdLength);
            }
            else
            {
                senderIdStringLength = GetUtf8ByteCount(senderIdString);
                senderIdLength       = 1 + CodedOutputStream.ComputeStringSize(senderIdStringLength);
                size += 1 + GetMessageSizeWithLength(senderIdLength);
            }

            // SenderEndPoint
            int senderEndPointLength;

            if (originatorInfo.SenderEndPoint == null)
            {
                senderEndPointLength = 0;
            }
            else
            {
                senderEndPointLength = GetUtf8ByteCount(originatorInfo.SenderEndPoint);
                size += 1 + CodedOutputStream.ComputeStringSize(senderEndPointLength);
            }

            // SenderMachineName
            int senderMachineNameLength;

            if (originatorInfo.SenderMachineName == null)
            {
                senderMachineNameLength = 0;
            }
            else
            {
                senderMachineNameLength = GetUtf8ByteCount(originatorInfo.SenderMachineName);
                size += 1 + CodedOutputStream.ComputeStringSize(senderMachineNameLength);
            }

            // InitiatorUserName
            int initiatorUserNameLength;

            if (originatorInfo.InitiatorUserName == null)
            {
                initiatorUserNameLength = 0;
            }
            else
            {
                initiatorUserNameLength = GetUtf8ByteCount(originatorInfo.InitiatorUserName);
                size += 1 + CodedOutputStream.ComputeStringSize(initiatorUserNameLength);
            }

            output.WriteLength(size);

            output.WriteRawTag(1 << 3 | 2);
            output.WriteLength(senderIdLength);

            if (!string.IsNullOrEmpty(senderIdString))
            {
                output.WriteRawTag(1 << 3 | 2);
                output.WriteString(senderIdString, senderIdStringLength);
            }

            if (originatorInfo.SenderEndPoint != null)
            {
                output.WriteRawTag(2 << 3 | 2);
                output.WriteString(originatorInfo.SenderEndPoint, senderEndPointLength);
            }
            if (originatorInfo.SenderMachineName != null)
            {
                output.WriteRawTag(3 << 3 | 2);
                output.WriteString(originatorInfo.SenderMachineName, senderMachineNameLength);
            }
            if (originatorInfo.InitiatorUserName != null)
            {
                output.WriteRawTag(5 << 3 | 2);
                output.WriteString(originatorInfo.InitiatorUserName, initiatorUserNameLength);
            }
        }
Пример #6
0
 public static MessageContext CreateTest(OriginatorInfo originator)
 {
     return new MessageContext
     {
         MessageId = MessageId.NextId(),
         Originator = originator,
     };
 }