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


C# IncomingMessage类代码示例

本文整理汇总了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);
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:10,代码来源:ConnectorContextExtensions.cs

示例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);
                }
            }
        }
开发者ID:krich38,项目名称:Watson-CSharp,代码行数:28,代码来源:Help.cs

示例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;
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:27,代码来源:MessageFromClientHandler.cs

示例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;
        }
开发者ID:Particular,项目名称:NServiceBus.Callbacks,代码行数:33,代码来源:IncomingContextExtensions.cs

示例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);
                    }
                }
            }
        }
开发者ID:krich38,项目名称:Watson-CSharp,代码行数:32,代码来源:Markov.cs

示例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);
        }
开发者ID:habb0,项目名称:-IHI-NavigatorManager,代码行数:35,代码来源:PacketHandlers.cs

示例7: ProcessBalanceRequest

 internal static void ProcessBalanceRequest(Habbo sender, IncomingMessage message)
 {
     new MCreditBalance
         {
             Balance = sender.Credits
         }.Send(sender);
 }
开发者ID:habb0,项目名称:Bluedot,代码行数:7,代码来源:ProcessBalanceRequest.cs

示例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);
            }
        }
开发者ID:habb0,项目名称:Bluedot,代码行数:31,代码来源:ProcessSSOTicket.cs

示例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;
        }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:28,代码来源:EventingServer.cs

示例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;
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:34,代码来源:DefaultRecoverabilityPolicy.cs

示例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);
 }
开发者ID:habb0,项目名称:Bluedot,代码行数:27,代码来源:ProcessSessionRequest.cs

示例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;
        }
开发者ID:Particular,项目名称:NServiceBus,代码行数:34,代码来源:DelayedRetryExecutor.cs

示例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));
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:7,代码来源:ErrorsNotifications.cs

示例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);
     }
 }
开发者ID:CodeByBerglund,项目名称:nai-framework,代码行数:28,代码来源:AuthenticationState.cs

示例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));
        }
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:28,代码来源:TestEnvelope.cs


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