当前位置: 首页>>代码示例>>C#>>正文


C# IncomingMessage.GetHeader方法代码示例

本文整理汇总了C#中IncomingMessage.GetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IncomingMessage.GetHeader方法的具体用法?C# IncomingMessage.GetHeader怎么用?C# IncomingMessage.GetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IncomingMessage的用法示例。


在下文中一共展示了IncomingMessage.GetHeader方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Subscribe

        private OutgoingMessage Subscribe(IncomingMessage requestMessage)
        {
            var toHeader = requestMessage.GetHeader<ToHeader>();
            var subscriptionManagerReference = new EndpointReference(toHeader.Uri);
            var request = requestMessage.GetPayload<SubscribeRequest>();            
            var responseMessage = new OutgoingMessage()
                .AddHeader(new ActionHeader(Constants.SubscribeResponseAction), false);

            var expiration = CalculateExpiration(request.Expires);
            var filterInstance = GetFilterInstance(request);
            var identifier = GenerateUniqueSubscriptionIdentifier();
            var subscription = new Subscription(expiration, _requestHandler, filterInstance, subscriptionManagerReference, requestMessage);
            _activeSubscriptions.Add(identifier, subscription);
            OnSubscribed(identifier, subscription);

            //R7.2.4-1
            var body = new SubscribeResponse
                           {
                               SubscriptionManager = subscriptionManagerReference,
                               EnumerationContext = request.Delivery.Mode == Delivery.DeliveryModePull
                                                        ? new EnumerationContextKey(
                                                              identifier)
                                                        : null,
                               Expires = expiration
                           };
            responseMessage.SetBody(new SerializerBodyWriter(body));
            return responseMessage;
        }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:28,代码来源:EventingServer.cs

示例2: Handle

        public OutgoingMessage Handle(IncomingMessage request)
        {
            var actionHeader = request.GetHeader<ActionHeader>();
            var messageIdHeader = request.GetHeader<MessageIdHeader>();

            var outgoingMessage = ProcessMessage(request, actionHeader);
            if (outgoingMessage == null)
            {
                return null;
            }
            outgoingMessage.AddHeader(MessageIdHeader.CreateRandom(), false);
            if (messageIdHeader != null)
            {
                outgoingMessage.AddHeader(new RelatesToHeader(messageIdHeader.MessageId), false);
            }
            outgoingMessage.AddHeader(ToHeader.Anonymous, false);
            return outgoingMessage;
        }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:18,代码来源:AddressingBasedRequestHandler.cs

示例3: It_reads_header_information

        public void It_reads_header_information()
        {
            var messageElement = new XElement(Constants.Envelope,
                                              new XElement(Constants.Header,
                                                           new XElement("SomeHeader",
                                                                        new XText("SomeValue"))),
                                              new XElement(Constants.Body));

            var messageReader = messageElement.ToReader();
            var message = new IncomingMessage(messageReader);

            var header = message.GetHeader(XName.Get("SomeHeader", ""));
            Assert.IsNotNull(header);
        }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:14,代码来源:IncomingMessageTests.cs

示例4: GetMBeanInfo

        public OutgoingMessage GetMBeanInfo(IncomingMessage requestMessage)
        {
            CheckResourceUri(requestMessage, Schema.DynamicMBeanResourceUri);

            var selectorSet = requestMessage.GetHeader<SelectorSetHeader>();
            var objectName = selectorSet.ExtractObjectName();

            var info = _server.GetMBeanInfo(objectName);

            var response = new ResourceMetaDataTypeMessage(new ResourceMetaDataType(info));
            return new OutgoingMessage()
                .AddHeader(new ActionHeader(Schema.GetMBeanInfoResponseAction), true)
                .SetBody(new SerializerBodyWriter(response));
        }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:14,代码来源:Jsr262ExtensionMethodHandler.cs

示例5: HandleRequest

 private OutgoingMessage HandleRequest(HttpContext ctx)
 {
     ctx.Response.ContentType = @"application/soap+xml; charset=utf-8";
     var reader = XmlReader.Create(ctx.Request.InputStream);
     using (var incomingMessage = new IncomingMessage(reader))
     {
         var messageIdHeader = incomingMessage.GetHeader<MessageIdHeader>();
         if (messageIdHeader != null)
         {
             ThreadContext.Properties[MessageIdProperty] = messageIdHeader.MessageId;
         }
         Log.Debug("Invoking request handlers.");
         return InvokeHandlers(incomingMessage);
     }
 }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:15,代码来源:SOAPHttpHandler.cs

示例6: IsInstanceOf

        public OutgoingMessage IsInstanceOf(IncomingMessage requestMessage)
        {
            CheckResourceUri(requestMessage, Schema.DynamicMBeanResourceUri);

            var request = requestMessage.GetPayload<IsInstanceOfMessage>();
            var selectorSet = requestMessage.GetHeader<SelectorSetHeader>();
            var objectName = selectorSet.ExtractObjectName();

            //TODO: Java-to-Net class mapping (i.e. javax.management.NotificationBroadcaster)

            var result = _server.IsInstanceOf(objectName, request.Value);
            var response = new IsInstanceOfResponseMessage(result);
            return new OutgoingMessage()
                .AddHeader(new ActionHeader(Schema.InstanceOfResponseAction), true)
                .SetBody(new SerializerBodyWriter(response));
        }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:16,代码来源:Jsr262ExtensionMethodHandler.cs

示例7: Invoke

        public OutgoingMessage Invoke(IncomingMessage requestMessage)
        {
            CheckResourceUri(requestMessage, Schema.DynamicMBeanResourceUri);

            var request = requestMessage.GetPayload<InvokeMessage>();
            var selectorSet = requestMessage.GetHeader<SelectorSetHeader>();
            var objectName = selectorSet.ExtractObjectName();
            var arguments = request.ManagedResourceOperation.Input.Select(x => x.Deserialize()).ToArray();

            var result = _server.Invoke(objectName, request.ManagedResourceOperation.name, arguments);

            var response = new InvokeResponseMessage(new GenericValueType(result));
            return new OutgoingMessage()
                .AddHeader(new ActionHeader(Schema.InvokeResponseAction), true)
                .SetBody(new SerializerBodyWriter(response));
        }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:16,代码来源:Jsr262ExtensionMethodHandler.cs

示例8: HandleConnectionData

        private void HandleConnectionData(ref byte[] data)
        {
            int pos = 0;
            while (pos < data.Length)
            {
                try
                {
                    if (data[0] == 60)
                    {
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> Policy Request");
                        SendData(PolicyReplyData);
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] <-- Policy Sent");
                        Close();
                        return;
                    }

                    // Total length of message (without this): 3 Base64 bytes
                    int messageLength = Base64Encoding.DecodeInt32(new[] {data[pos++], data[pos++], data[pos++]});

                    // ID of message: 2 Base64 bytes
                    uint messageID = Base64Encoding.DecodeUInt32(new[] {data[pos++], data[pos++]});

                    // Data of message: (messageLength - 2) bytes
                    byte[] content = new byte[messageLength - 2];
                    for (int i = 0; i < content.Length; i++)
                    {
                        content[i] = data[pos++];
                    }

                    // Create message object
                    IncomingMessage message = new IncomingMessage(messageID, content);

                    if (Habbo.IsLoggedIn())
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + Habbo.GetUsername() + "] --> " +
                                                                           message.GetHeader() +
                                                                           message.GetContentString());
                    else
                        CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> " +
                                                                           message.GetHeader() +
                                                                           message.GetContentString());

                    // Handle message object
                    bool unknown = true;

                    if (_packetHandlers.GetLength(0) > messageID)
                    {
                        if (_packetHandlers[messageID, 3] != null)
                        {
                            lock (_packetHandlers[messageID, 3])
                            {
                                _packetHandlers[messageID, 3].Invoke(Habbo, message); // Execute High Priority
                                unknown = false;
                            }
                        }

                        if (message.IsCancelled())
                            return;

                        if (_packetHandlers[messageID, 2] != null)
                        {
                            lock (_packetHandlers[messageID, 2])
                            {
                                _packetHandlers[messageID, 2].Invoke(Habbo, message); // Execute Low Priority
                                unknown = false;
                            }
                        }

                        if (message.IsCancelled())
                            return;

                        if (_packetHandlers[messageID, 1] != null)
                        {
                            lock (_packetHandlers[messageID, 1])
                            {
                                _packetHandlers[messageID, 1].Invoke(Habbo, message); // Execute Default Action
                                unknown = false;
                            }
                        }

                        if (_packetHandlers[messageID, 0] != null)
                        {
                            lock (_packetHandlers[messageID, 0])
                            {
                                _packetHandlers[messageID, 0].Invoke(Habbo, message); // Execute Watchers
                                unknown = false;
                            }
                        }
                    }

                    if (unknown)
                    {
                        CoreManager.ServerCore.GetStandardOut().PrintWarning("Packet " + messageID + " ('" +
                                                                             message.GetHeader() + "') unhandled!");
                    }
                }
                catch (IndexOutOfRangeException) // Bad formatting!
                {
                    // TODO: Move this to IHI
                    //IonEnvironment.GetHabboHotel().GetClients().StopClient(_id, 0);
                }
//.........这里部分代码省略.........
开发者ID:habb0,项目名称:IHI,代码行数:101,代码来源:IonTcpConnection.cs

示例9: Process_DYNAMIC

 private void Process_DYNAMIC(Habbo Sender, IncomingMessage Message)
 {
     lock (this.fPacketLogs)
     {
         this.fPacketLogs.
             Append("<div class='packet'>").
             Append('[').
             Append(Message.GetID()).
             Append("] <u>").
             Append(Message.GetHeader()).
             Append("</u>").
             Append(Message.GetContentString()).
             Append("</div>");
     }
 }
开发者ID:Cecer1,项目名称:-IHI-PacketDebugger,代码行数:15,代码来源:Handlers.cs

示例10: Unsubscribe

        public OutgoingMessage Unsubscribe(IncomingMessage requestMessage)
        {            
            var identifierHeader = requestMessage.GetHeader<IdentifierHeader>();
            var identifier = identifierHeader.Identifier;

            var toRemove = _activeSubscriptions.Remove(identifier);
            OnUnsubscribed(identifier, toRemove);
            toRemove.Dispose();

            return new OutgoingMessage()
                .AddHeader(new ActionHeader(Constants.UnsubscribeResponseAction), false);
        }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:12,代码来源:EventingServer.cs

示例11: Renew

        public OutgoingMessage Renew(IncomingMessage requestMessage)
        {            
            var request = requestMessage.GetPayload<RenewRequest>();
            var identifierHeader = requestMessage.GetHeader<IdentifierHeader>();
            

            var existing = _activeSubscriptions.Get(identifierHeader.Identifier);
            existing.Renew(CalculateExpiration(request.Expires));

            var responseMessage = new OutgoingMessage()
                .AddHeader(new ActionHeader(Constants.RenewResponseAction), false);
            responseMessage.SetBody(new SerializerBodyWriter(
                                        new RenewResponse
                                            {
                                                Expires = request.Expires
                                            }));
            return responseMessage;
        }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:18,代码来源:EventingServer.cs

示例12: CheckResourceUri

 private static void CheckResourceUri(IncomingMessage requestMessage, string expectedResourceUri)
 {
     var resourceUri = requestMessage.GetHeader<ResourceUriHeader>();
     if (resourceUri == null || resourceUri.ResourceUri != expectedResourceUri)
     {
         throw new DestinationUnreachableFaultException();
     }
 }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:8,代码来源:Jsr262ExtensionMethodHandler.cs

示例13: IsCountRequest

 private static bool IsCountRequest(IncomingMessage incomingMessage)
 {
     return incomingMessage.GetHeader<RequestTotalItemsCountEstimateHeader>() != null;
 }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:4,代码来源:EnumerationServer.cs


注:本文中的IncomingMessage.GetHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。