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


C# IMessage.GetPayload方法代码示例

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


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

示例1: Handler

        private async Task<IActorResult> Handler(IMessage message)
        {
            var cityWeather = message.GetPayload<CityWeatherMessage>();
            var correlationId = new Guid(message.CorrelationId.GetString());
            var cityName = cityWeather.Weather.CityName;
            var temperature = cityWeather.Weather.Temperature;

            if (temperature != null)
            {
                await GetReduceDocument(correlationId);
                await UpdateHighestTemperature(correlationId, temperature, cityName);
                await UpdateLowestTemperature(correlationId, temperature, cityName);
            }
            var result = await IncrementMessageCount(correlationId);

            if (result.MessagesProcessed % 100 == 0)
            {
                WriteLine($"Done {result.MessagesProcessed} out of {cityWeather.TotalCityCount}");
            }

            if (result.MessagesProcessed == cityWeather.TotalCityCount)
            {
                return CreateAggregatedWeatherMessage(result);
            }

            return null;
        }
开发者ID:iiwaasnet,项目名称:weather,代码行数:27,代码来源:WeatherAggregator.cs

示例2: StartProcess

        private async Task<IActorResult> StartProcess(IMessage message)
        {
            var hello = message.GetPayload<HelloMessage>();
            //System.Console.WriteLine(hello.Greeting);

            //return await Task.Delay(0)
            //                 .ContinueWith(_ => Message.Create(new EhlloMessage
            //                                                   {
            //                                                       Ehllo = new string(hello.Greeting.Reverse().ToArray())
            //                                                   },
            //                                                   EhlloMessage.MessageIdentity))
            //                                                   .ConfigureAwait(false);

            //throw new Exception("Bla!");

            //Thread.Sleep(50000);

            var reversedString = new string(hello.Greeting.Reverse().ToArray());

            //WriteLine(reversedString);

            return new ActorResult(Message.Create(new EhlloMessage
                                  {
                                      Ehllo = reversedString
                                  },
                                  EhlloMessage.MessageIdentity));
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:27,代码来源:RevertStringActor.cs

示例3: AsyncProcess

        private async Task<IActorResult> AsyncProcess(IMessage messageIn)
        {
            var error = messageIn.GetPayload<AsyncExceptionMessage>();

            await Task.Delay(error.Delay).ContinueWith(_ => { throw new Exception(error.ErrorMessage); }).ConfigureAwait(false);

            return null;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:8,代码来源:ExceptionActor.cs

示例4: HandleException

        private Task<IActorResult> HandleException(IMessage message)
        {
            var payload = message.GetPayload<ExceptionMessage>();

            Console.WriteLine(payload.Exception.ToString());

            return null;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:8,代码来源:ExceptionHandlerActor.cs

示例5: StartProcess

        private async Task<IActorResult> StartProcess(IMessage message)
        {
            var ehllo = message.GetPayload<EhlloMessage>();

            var messageOut = Message.Create(new GroupCharsResponseMessage
                                            {
                                                Groups = ehllo.Ehllo.GroupBy(c => c).Select(g => new GroupInfo {Char = g.Key, Count = g.Count()}),
                                                Text = ehllo.Ehllo
                                            },
                                            GroupCharsResponseMessage.MessageIdentity);

            return new ActorResult(messageOut);
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:13,代码来源:GroupCharsActor.cs

示例6: Handler

        private async Task<IActorResult> Handler(IMessage message)
        {
            var request = message.GetPayload<RequestWeatherHighlightsMessage>();
            var totalCount = request.Cities.Count();
            var response = new ActorResult(request
                                               .Cities
                                               .Select(city => Message.Create(new RequestCityWeatherMessage
                                                                              {
                                                                                  CityName = city,
                                                                                  TotalCityCount = totalCount
                                                                              })).ToArray());

            return response;
        }
开发者ID:iiwaasnet,项目名称:weather,代码行数:14,代码来源:WeatherRequestsCreator.cs

示例7: SetResult

        internal void SetResult(IMessage message)
        {
            expirableItem?.ExpireNow();

            if (Unsafe.Equals(message.Identity, ExceptionMessage.MessageIdentity))
            {
                var error = message.GetPayload<ExceptionMessage>().Exception;
                result.SetException(error);
            }
            else
            {
                result.SetResult(message);
            }
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:14,代码来源:Promise.cs

示例8: Handler

        private async Task<IActorResult> Handler(IMessage message)
        {
            var request = message.GetPayload<LogCityWeatherMessage>();

            var cityWeather = new CityWeatherHistory
                              {
                                  CorrelationId = new Guid(message.CorrelationId.GetString()),
                                  Weather = new Weather
                                            {
                                                CityName = request.Weather.CityName,
                                                Temperature = request.Weather.Temperature
                                            }
                              };
            db.GetCollection<CityWeatherHistory>(CityWeatherHistory.Collection)
              .InsertOneAsync(cityWeather);

            return null;
        }
开发者ID:iiwaasnet,项目名称:weather,代码行数:18,代码来源:WeatherLogger.cs

示例9: Handler

        private async Task<IActorResult> Handler(IMessage message)
        {
            var request = message.GetPayload<RequestCityWeatherMessage>();
            var weather = await GetCityWeather(request.CityName);
            var cityWeather = new CityWeather
                              {
                                  CityName = request.CityName,
                                  Temperature = weather?.Main?.Temp
                              };
            var response = Message.Create(new CityWeatherMessage
                                          {
                                              Weather = cityWeather,
                                              TotalCityCount = request.TotalCityCount
                                          });
            var log = Message.Create(new LogCityWeatherMessage
                                     {
                                         Weather = cityWeather
                                     });

            return new ActorResult(response, log);
        }
开发者ID:iiwaasnet,项目名称:weather,代码行数:21,代码来源:WeatherCollector.cs

示例10: OnWriteReceived

        private void OnWriteReceived(IMessage message)
        {
            var payload = message.GetPayload<LeaseWriteMessage>();

            var ballot = new Ballot(new DateTime(payload.Ballot.Timestamp, DateTimeKind.Utc),
                                    payload.Ballot.MessageNumber,
                                    payload.Ballot.Identity);
            IMessage response;
            if (writeBallot > ballot || readBallot > ballot)
            {
                LogNackWrite(ballot);

                response = Message.Create(new LeaseNackWriteMessage
                                          {
                                              Ballot = payload.Ballot,
                                              SenderUri = synodConfig.LocalNode.Uri.ToSocketAddress()
                                          },
                                          LeaseNackWriteMessage.MessageIdentity);
            }
            else
            {
                LogAckWrite(ballot);

                writeBallot = ballot;
                var ownerEndpoint = new OwnerEndpoint
                                    {
                                        UnicastUri = new Uri(payload.Lease.OwnerEndpoint.UnicastUri),
                                        MulticastUri = new Uri(payload.Lease.OwnerEndpoint.MulticastUri)
                                    };
                lease = new Lease(payload.Lease.Identity, ownerEndpoint, new DateTime(payload.Lease.ExpiresAt, DateTimeKind.Utc));

                response = Message.Create(new LeaseAckWriteMessage
                                          {
                                              Ballot = payload.Ballot,
                                              SenderUri = synodConfig.LocalNode.Uri.ToSocketAddress()
                                          },
                                          LeaseAckWriteMessage.MessageIdentity);
            }
            intercomMessageHub.Send(response, payload.SenderIdentity);
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:40,代码来源:RoundBasedRegister.cs

示例11: IsPong

        private bool IsPong(IMessage message)
        {
            if (Unsafe.Equals(PongMessage.MessageIdentity, message.Identity))
            {
                var payload = message.GetPayload<PongMessage>();

                return !ThisNodeSocket(payload.SocketIdentity);
            }

            return false;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:11,代码来源:ClusterMonitor.cs

示例12: RegisterExternalRoutes

        private bool RegisterExternalRoutes(IMessage message, ISocket scaleOutBackend)
        {
            var shouldHandle = IsExternalRouteRegistration(message);
            if (shouldHandle)
            {
                var payload = message.GetPayload<RegisterExternalMessageRouteMessage>();

                var handlerSocketIdentifier = new SocketIdentifier(payload.SocketIdentity);
                var uri = new Uri(payload.Uri);

                foreach (var registration in payload.MessageContracts)
                {
                    try
                    {
                        var messageHandlerIdentifier = new MessageIdentifier(registration.Version, registration.Identity);
                        externalRoutingTable.AddMessageRoute(messageHandlerIdentifier, handlerSocketIdentifier, uri);
                        scaleOutBackend.Connect(uri);
                    }
                    catch (Exception err)
                    {
                        logger.Error(err);
                    }
                }
            }

            return shouldHandle;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:27,代码来源:MessageRouter.cs

示例13: RegisterInternalMessageRoutes

        private bool RegisterInternalMessageRoutes(IMessage message)
        {
            var shouldHandle = IsInternalMessageRoutingRegistration(message);
            if (shouldHandle)
            {
                var payload = message.GetPayload<RegisterInternalMessageRouteMessage>();
                var handlerSocketIdentifier = new SocketIdentifier(payload.SocketIdentity);

                var handlers = UpdateLocalRoutingTable(payload, handlerSocketIdentifier);

                clusterMonitor.RegisterSelf(handlers);
            }

            return shouldHandle;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:15,代码来源:MessageRouter.cs

示例14: UnregisterRoute

        private bool UnregisterRoute(IMessage message, ISocket scaleOutBackend)
        {
            var shouldHandle = IsUnregisterRouting(message);
            if (shouldHandle)
            {
                var payload = message.GetPayload<UnregisterNodeMessageRouteMessage>();
                externalRoutingTable.RemoveNodeRoute(new SocketIdentifier(payload.SocketIdentity));
                try
                {
                    scaleOutBackend.Disconnect(new Uri(payload.Uri));
                }
                catch (EndpointNotFoundException)
                {
                }
            }

            return shouldHandle;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:18,代码来源:MessageRouter.cs

示例15: DiscoverMessageRoute

        private bool DiscoverMessageRoute(IMessage message)
        {
            var shouldHandle = IsDiscoverMessageRouteRequest(message);
            if (shouldHandle)
            {
                var messageContract = message.GetPayload<DiscoverMessageRouteMessage>().MessageContract;
                var messageIdentifier = new MessageIdentifier(messageContract.Version, messageContract.Identity);
                if (internalRoutingTable.CanRouteMessage(messageIdentifier))
                {
                    clusterMonitor.RegisterSelf(new [] { messageIdentifier});
                }
            }

            return shouldHandle;
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:15,代码来源:MessageRouter.cs


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