本文整理汇总了C#中IncomingMessage类的典型用法代码示例。如果您正苦于以下问题:C# IncomingMessage类的具体用法?C# IncomingMessage怎么用?C# IncomingMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IncomingMessage类属于命名空间,在下文中一共展示了IncomingMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateIncomingPhysicalMessageContext
/// <summary>
/// Creates a <see cref="IIncomingPhysicalMessageContext" /> based on the current context.
/// </summary>
public static IIncomingPhysicalMessageContext CreateIncomingPhysicalMessageContext(this StageConnector<ITransportReceiveContext, IIncomingPhysicalMessageContext> stageConnector, IncomingMessage incomingMessage, ITransportReceiveContext sourceContext)
{
Guard.AgainstNull(nameof(incomingMessage), incomingMessage);
Guard.AgainstNull(nameof(sourceContext), sourceContext);
return new IncomingPhysicalMessageContext(incomingMessage, sourceContext);
}
示例2: HandleCommand
public void HandleCommand(IRCServer server, string command, IncomingMessage msg)
{
CommandManager commands = CommandManager.GetInstance();
if (!msg.HasMessage())
{
msg.SendChat("Available commands: " + commands.AvailableCommands());
return;
}
string cmd = msg.Message.ToLower();
if (!commands.HasCommand(cmd))
{
msg.SendChat("No help for command: " + cmd);
}
else
{
string help = commands.GetCommand(cmd).Help();
if (help == null || help.Equals(""))
{
msg.SendChat("No help available for: " + cmd);
}
else
{
msg.SendChat("Help for " + cmd + ": " + help);
}
}
}
示例3: OnRun
protected override void OnRun(IncomingMessage message)
{
ServerEnvelopeObject envelope = Manager.Serializer.GetObject<ServerEnvelopeObject>(message.Data);
GameMessageType gmt = (GameMessageType)Enum.ToObject(typeof(GameMessageType), envelope.InnerOperationCode);
switch (gmt)
{
case GameMessageType.Server_ReceiveTableListingRequest:
OnTableListingRequest(Manager.Serializer.GetObject<TableListingRequest>(envelope.InnerData), envelope.RouteInfo);
break;
case GameMessageType.Server_ReceiveJoinTableRequest:
OnJoinTableRequest(envelope);
break;
default:
IncomingGameMessageQueueItem defaultItem = new IncomingGameMessageQueueItem();
defaultItem.OperationCode = (GameMessageType)envelope.InnerOperationCode;
defaultItem.Data = envelope.InnerData;
defaultItem.RouteInfo = envelope.RouteInfo;
Manager.Tables[defaultItem.RouteInfo.TableId].PlayerPortal.IncomingQueue.Add(defaultItem);
break;
}
message.WasMessageHandled = true;
}
示例4: TryRemoveResponseStateBasedOnCorrelationId
public static RequestResponseStateLookup.State? TryRemoveResponseStateBasedOnCorrelationId(this IIncomingContext context, IncomingMessage message, RequestResponseStateLookup lookup)
{
var correlationId = context.GetCorrelationId();
if (correlationId == null)
{
return null;
}
string version;
var checkMessageIntent = true;
if (message.Headers.TryGetValue(Headers.NServiceBusVersion, out version))
{
Version parsedVersion;
if (Version.TryParse(version, out parsedVersion))
{
if (parsedVersion < minimumVersionThatSupportMessageIntent_Reply)
{
checkMessageIntent = false;
}
}
}
var messageIntentEnum = message.GetMesssageIntent();
if (checkMessageIntent && messageIntentEnum != MessageIntentEnum.Reply)
{
return null;
}
RequestResponseStateLookup.State state;
return lookup.TryRemove(correlationId, out state) ? (RequestResponseStateLookup.State?) state : null;
}
示例5: HandleCommand
public void HandleCommand(IRCServer server, string command, IncomingMessage message)
{
if (!message.HasMessage())
{
// bad syntax
return;
}
if (COMMAND_REGEX.IsMatch(message.Message))
{
Match m = COMMAND_REGEX.Match(message.Message);
string cmd = m.Groups[1].Value;
if (cmd.Equals("about"))
{
if (m.Groups[2].Value == null || m.Groups[2].Value.Equals(""))
{
message.SendChat("Need context");
}
string markov = MarkovDatabaseAdapter.MarkovFind(m.Groups[2].Value, m.Groups[3].Value);
if (markov == null || markov.Equals(""))
{
message.SendChat("I can't :(");
}
else
{
message.SendChat(markov);
}
}
}
}
示例6: ProcessRequestCategoryListings
private static void ProcessRequestCategoryListings(Habbo sender, IncomingMessage message)
{
bool excludeFullRooms = message.PopWiredBoolean();
int categoryID = message.PopWiredInt32();
Category category = CoreManager.ServerCore.GetNavigator().GetCategory(categoryID);
if (category == null)
new MNavigatorCategoryListing // TODO: Remove this. Maybe even throw an exception?
{
ID = categoryID,
ExcludeFullRooms = excludeFullRooms,
Name = "Non-Existant Category",
ParentID = categoryID,
IsPublicCategory = true,
Listings = new Listing[0],
UnknownA = 0,
UnknownB = 10000,
UnknownC = 0
}.Send(sender);
else
new MNavigatorCategoryListing
{
ID = categoryID,
ExcludeFullRooms = excludeFullRooms,
Name = category.Name,
ParentID = (category.PrimaryCategory != null ? category.PrimaryCategory.ID : category.ID),
IsPublicCategory = category.IsPublicCategory,
Listings = category.GetListings(),
UnknownA = 0,
UnknownB = 10000,
UnknownC = 0
}.Send(sender);
}
示例7: ProcessBalanceRequest
internal static void ProcessBalanceRequest(Habbo sender, IncomingMessage message)
{
new MCreditBalance
{
Balance = sender.Credits
}.Send(sender);
}
示例8: ProcessSSOTicket
internal static void ProcessSSOTicket(Habbo sender, IncomingMessage message)
{
ClassicIncomingMessage classicMessage = (ClassicIncomingMessage)message;
Habbo fullHabbo = CoreManager.ServerCore.HabboDistributor.GetHabboFromSSOTicket(classicMessage.PopPrefixedString());
if (fullHabbo == null)
{
new MConnectionClosed
{
Reason = ConnectionClosedReason.InvalidSSOTicket
}.Send(sender);
sender.Socket.Disconnect("Invalid SSO Ticket");
}
else
{
// If this Habbo is already logged in...
if (fullHabbo.LoggedIn)
{
// Disconnect them.
new MConnectionClosed
{
Reason = ConnectionClosedReason.ConcurrentLogin
}.Send(fullHabbo);
fullHabbo.Socket.Disconnect("Concurrent Login");
}
LoginMerge(fullHabbo, sender);
}
}
示例9: 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;
}
示例10: HasReachedMaxTime
static bool HasReachedMaxTime(IncomingMessage message)
{
string timestampHeader;
if (!message.Headers.TryGetValue(Headers.DelayedRetriesTimestamp, out timestampHeader))
{
return false;
}
if (string.IsNullOrEmpty(timestampHeader))
{
return false;
}
try
{
var handledAt = DateTimeExtensions.ToUtcDateTime(timestampHeader);
var now = DateTime.UtcNow;
if (now > handledAt.AddDays(1))
{
return true;
}
}
// ReSharper disable once EmptyGeneralCatchClause
// this code won't usually throw but in case a user has decided to hack a message/headers and for some bizarre reason
// they changed the date and that parse fails, we want to make sure that doesn't prevent the message from being
// forwarded to the error queue.
catch (Exception)
{
}
return false;
}
示例11: ProcessSessionRequest
internal static void ProcessSessionRequest(Habbo sender, IncomingMessage message)
{
new MSessionParams
{
A = 9,
B = 0,
C = 0,
D = 1,
E = 1,
F = 3,
G = 0,
H = 2,
I = 1,
J = 4,
K = 0,
L = 5,
DateFormat = "dd-MM-yyyy",
M = "",
N = 7,
O = false,
P = 8,
URL = "http://null",
Q = "",
R = 9,
S = false
}.Send(sender);
}
示例12: Retry
public async Task<int> Retry(IncomingMessage message, TimeSpan delay, TransportTransaction transportTransaction)
{
var outgoingMessage = new OutgoingMessage(message.MessageId, new Dictionary<string, string>(message.Headers), message.Body);
var currentDelayedRetriesAttempt = message.GetDelayedDeliveriesPerformed() + 1;
outgoingMessage.SetCurrentDelayedDeliveries(currentDelayedRetriesAttempt);
outgoingMessage.SetDelayedDeliveryTimestamp(DateTime.UtcNow);
UnicastAddressTag messageDestination;
List<DeliveryConstraint> deliveryConstraints = null;
if (timeoutManagerAddress == null)
{
// transport supports native deferred messages, directly send to input queue with delay constraint:
deliveryConstraints = new List<DeliveryConstraint>(1)
{
new DelayDeliveryWith(delay)
};
messageDestination = new UnicastAddressTag(endpointInputQueue);
}
else
{
// transport doesn't support native deferred messages, reroute to timeout manager:
outgoingMessage.Headers[TimeoutManagerHeaders.RouteExpiredTimeoutTo] = endpointInputQueue;
outgoingMessage.Headers[TimeoutManagerHeaders.Expire] = DateTimeExtensions.ToWireFormattedString(DateTime.UtcNow + delay);
messageDestination = new UnicastAddressTag(timeoutManagerAddress);
}
var transportOperations = new TransportOperations(new TransportOperation(outgoingMessage, messageDestination, deliveryConstraints: deliveryConstraints));
await dispatcher.Dispatch(transportOperations, transportTransaction, new ContextBag()).ConfigureAwait(false);
return currentDelayedRetriesAttempt;
}
示例13: InvokeMessageHasBeenSentToErrorQueue
internal void InvokeMessageHasBeenSentToErrorQueue(IncomingMessage message, Exception exception, string errorQueue)
{
MessageSentToErrorQueue?.Invoke(this, new FailedMessage(
message.MessageId,
new Dictionary<string, string>(message.Headers),
CopyOfBody(message.Body), exception, errorQueue));
}
示例14: HandleIncomingMessage
public override void HandleIncomingMessage(IncomingMessage message)
{
if (message is CredentialsMessage)
{
CredentialsMessage cm = message as CredentialsMessage;
if (AuthenticationHandler.Authenticate(cm.Credentials))
{
_session.ClientId.Credentials = cm.Credentials;
_session.Communication.SendAuthenticationAccepted();
_session.State = new PairingState(_session);
}
else
{
_session.Communication.SendAuthenticationRejected();
}
}
else if (message is ClientPausedMessage ||
message is ClientResumedMessage)
{
// Ignore, but not reject!
}
else
{
string errorMsg = string.Format("Message type '{0}' is not supported at this point", message.GetType().Name);
Debug.WriteLine(errorMsg);
throw new NotSupportedException(errorMsg);
}
}
示例15: TestIncomingBasic
public void TestIncomingBasic()
{
Message message = LoadMessage("simple.eml");
DirectAddressCollection rcpto = new DirectAddressCollection(
new DirectAddress[] {
new DirectAddress("[email protected]"),
new DirectAddress("[email protected]")
}
);
IncomingMessage incoming = new IncomingMessage(message, rcpto, new DirectAddress("[email protected]"));
Assert.True(incoming.Recipients.Count == 2);
DirectAddressCollection routingRecipients = incoming.GetRecipientsInRoutingHeaders();
Assert.True(routingRecipients.Count == 1);
Assert.False(incoming.AreAddressesInRoutingHeaders(rcpto));
incoming.Recipients.Remove(x => MimeStandard.Equals(x.Address, "[email protected]"));
Assert.True(incoming.AreAddressesInRoutingHeaders(rcpto));
message.ToValue = "[email protected]";
incoming = new IncomingMessage(message, rcpto, new DirectAddress("[email protected]"));
Assert.False(incoming.AreAddressesInRoutingHeaders(rcpto));
message.ToValue = "[email protected]";
incoming = new IncomingMessage(message, rcpto, new DirectAddress("[email protected]"));
Assert.False(incoming.AreAddressesInRoutingHeaders(rcpto));
}