• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IncomingMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



IncomingMessage类属于命名空间,在下文中一共展示了IncomingMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Handle

        public void Handle(IncomingMessage msg)
        {
            string lastSeenEvent = null;

            if (msg.Command.Equals("PRIVMSG"))
            {
                lastSeenEvent = "saying: " + msg.Message;
            }
            else if (msg.Command.Equals("JOIN"))
            {
                lastSeenEvent = "joining " + msg.Message;
            }
            else if (msg.Command.Equals("PART"))
            {
                lastSeenEvent = "leaving " + msg.TargetParams + ": " + msg.Message;
            }
            else if (msg.Command.Equals("QUIT"))
            {
                lastSeenEvent = "quitting: " + msg.Message;
            }
            else if (msg.Command.Equals("NICK"))
            {
                lastSeenEvent = "changing nick to: " + msg.TargetParams;
            }
            if (lastSeenEvent != null)
            {
                string nick = msg.Sender.ToLower();
                Database.SetKeyValue(msg.Server, "lastseen.time." + nick, Environment.TickCount);
                Database.SetKeyValue(msg.Server, "lastseen.event." + nick, lastSeenEvent);
            }
        }
开发者ID:krich38,项目名称:Watson-CSharp,代码行数:31,代码来源:UserSeenListener.cs


示例17: Pull

 private OutgoingMessage Pull(IncomingMessage requestMessage)
 {
     var response = CreatePullResponse();
     var request = requestMessage.GetPayload<PullRequest>();
     IPullHandler handler;
     var context = request.EnumerationContext.Text;
     lock (_handlers)
     {
         if (!_handlers.TryGetValue(context, out handler))
         {
             throw new InvalidEnumerationContextFaultException();
         }
     }
     var maxElements = GetMaxElements(request);
     var maxTime = GetMaxTime(request);
     var pullResult = handler.Pull(maxElements, maxTime, context);
     var items = new EnumerationItemList(pullResult.Items, pullResult.EnumerationMode);
     if (pullResult.EndOfSequence)
     {
         handler.Dispose();
         lock (_handlers)
         {
             _handlers.Remove(context);
         }
     }
     response.SetBody(
         new SerializerBodyWriter(new PullResponse
                                      {
                                          Items = items,
                                          EndOfSequence = pullResult.EndOfSequence ? new EndOfSequence() : null,
                                          EnumerationContext = pullResult.EndOfSequence ? null : request.EnumerationContext
                                      }));
     return response;
 }
开发者ID:SzymonPobiega,项目名称:WS-Man.Net,代码行数:34,代码来源:PullServer.cs


示例18: ProcessEncryptionRequest

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


示例19: OnRun

        protected override void OnRun(IncomingMessage message)
        {
            JoinTableRequest request = Manager.Serializer.GetObject<JoinTableRequest>(message.Data);

            RouteInfo routeInfo = Manager.GetRouteInfo(request.PlayerName);

            string gameServerId = Manager.GetServerWithTable(request.TableToJoin);

            //-- Stop people trying to bring down the server by sending join requests to tables that do not exist.
            if (string.IsNullOrEmpty(gameServerId) == false)
            {
                IPEndPoint serverEndpoint = Manager.ResolveServer(gameServerId);

                //-- Has the destination server been found?
                if (serverEndpoint != null)
                {
                    Manager.SendEnvelopeObjectToServer(GameMessageType.Server_ReceiveJoinTableRequest,
                        Manager.Serializer.GetBytes(request),
                        serverEndpoint.ToList(),
                        routeInfo);
                }
                else
                {
                    ServerUIShell.WriteLine("-IPEndPoint for server could not be resolved (" + gameServerId + ")");
                }
            }

            message.WasMessageHandled = true;
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:29,代码来源:JoinTableRequestHandler.cs


示例20: Handle

        public void Handle(IncomingMessage msg)
        {
            IRCServer server = msg.Server;
            string ourNick = server.Nick;

            if (msg.Command.Equals("NICK"))
            {
                string whoChanging = msg.Sender;
                string changingTo = msg.Target;
                if (whoChanging.Equals(ourNick))
                {
                    server.Nick = changingTo;
                    server.SetAttemptNickChange(false);
                }
                else
                {
                    // update user nick list
                }
            }
            else if (msg.Command.Equals("ERROR"))
            {
                server.Dispose();
            }
            else
            {
                string raw = msg.Raw;
                switch (msg.Command)
                {
                    // nick change
                    case "433":
                        if (server.Connected)
                        {
                            // are we attempting a nick name change?
                            if (server.IsAttemptNickChange())
                            {

                                server.Nick = server.LastNick;
                                server.SetAttemptNickChange(false);
                            }

                        }
                        else
                        {
                            string nick;
                            if (server.Nick.Equals(server.AltNick))
                            {
                                nick = server.AltNick + 1;
                            }
                            else
                            {
                                nick = server.AltNick;
                            }
                            server.Nick = nick;

                        }
                        break;
                }
            }
        }
开发者ID:krich38,项目名称:Watson-CSharp,代码行数:59,代码来源:ProtocolHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IndentedTextWriter类代码示例发布时间:2022-05-24
下一篇:
C# Include类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap