本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
}
示例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));
}
示例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));
}
示例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);
}
//.........这里部分代码省略.........
示例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>");
}
}
示例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);
}
示例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;
}
示例12: CheckResourceUri
private static void CheckResourceUri(IncomingMessage requestMessage, string expectedResourceUri)
{
var resourceUri = requestMessage.GetHeader<ResourceUriHeader>();
if (resourceUri == null || resourceUri.ResourceUri != expectedResourceUri)
{
throw new DestinationUnreachableFaultException();
}
}
示例13: IsCountRequest
private static bool IsCountRequest(IncomingMessage incomingMessage)
{
return incomingMessage.GetHeader<RequestTotalItemsCountEstimateHeader>() != null;
}