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


C# ISocket.SendMessage方法代码示例

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


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

示例1: ForwardMessageAway

        private bool ForwardMessageAway(MessageIdentifier messageIdentifier, Message message, ISocket scaleOutBackend)
        {
            var handlers = ((message.Distribution == DistributionPattern.Unicast)
                                ? new[] {externalRoutingTable.FindRoute(messageIdentifier)}
                                : (MessageCameFromLocalActor(message)
                                       ? externalRoutingTable.FindAllRoutes(messageIdentifier)
                                       : Enumerable.Empty<Node>()))
                .Where(h => h != null)
                .ToList();

            foreach (var handler in handlers)
            {
                try
                {
                    message.SetSocketIdentity(handler.SocketIdentity);
                    message.PushRouterAddress(routerConfiguration.ScaleOutAddress);
                    scaleOutBackend.SendMessage(message);

                    messageTracer.ForwardedToOtherNode(message);
                }
                catch (HostUnreachableException err)
                {
                    externalRoutingTable.RemoveNodeRoute(new SocketIdentifier(handler.SocketIdentity));
                    scaleOutBackend.Disconnect(handler.Uri);
                    logger.Error(err);
                }
            }

            return handlers.Any();
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:30,代码来源:MessageRouter.cs

示例2: CallbackException

        private static void CallbackException(ISocket localSocket, Exception err, Message messageIn)
        {
            var messageOut = (Message) Message.Create(new ExceptionMessage {Exception = err}, ExceptionMessage.MessageIdentity);
            messageOut.RegisterCallbackPoint(ExceptionMessage.MessageIdentity, messageIn.CallbackReceiverIdentity);
            messageOut.SetCorrelationId(messageIn.CorrelationId);
            messageOut.CopyMessageHops(messageIn.GetMessageHops());

            localSocket.SendMessage(messageOut);
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:9,代码来源:ActorHost.cs

示例3: HandleMessageLocally

        private bool HandleMessageLocally(MessageIdentifier messageIdentifier, Message message, ISocket localSocket)
        {
            var handlers = ((message.Distribution == DistributionPattern.Unicast)
                                ? new[] {internalRoutingTable.FindRoute(messageIdentifier)}
                                : internalRoutingTable.FindAllRoutes(messageIdentifier))
                .Where(h => h != null)
                .ToList();

            foreach (var handler in handlers)
            {
                message.SetSocketIdentity(handler.Identity);
                try
                {
                    localSocket.SendMessage(message);
                    messageTracer.RoutedToLocalActor(message);
                }
                catch (HostUnreachableException err)
                {
                    var removedHandlerIdentifiers = internalRoutingTable.RemoveActorHostRoute(handler);
                    if (removedHandlerIdentifiers.Any())
                    {
                        clusterMonitor.UnregisterSelf(removedHandlerIdentifiers);
                    }
                    logger.Error(err);
                }
            }

            return handlers.Any();
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:29,代码来源:MessageRouter.cs

示例4: SendActorRegistrationMessage

        private static void SendActorRegistrationMessage(ISocket socket, byte[] identity, IEnumerable<MessageIdentifier> registrations)
        {
            var payload = new RegisterInternalMessageRouteMessage
                          {
                              SocketIdentity = identity,
                              MessageContracts = registrations
                                  .Select(mh => new MessageContract
                                                {
                                                    Identity = mh.Identity,
                                                    Version = mh.Version
                                                })
                                  .ToArray()
                          };

            socket.SendMessage(Message.Create(payload, RegisterInternalMessageRouteMessage.MessageIdentity));
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:16,代码来源:ActorHost.cs

示例5: HandleTaskResult

        private void HandleTaskResult(CancellationToken token, Task<IActorResult> task, Message messageIn, ISocket localSocket)
        {
            if (task.IsCompleted)
            {
                var response = CreateTaskResultMessage(task).Messages;

                messageTracer.MessageProcessed(messageIn, response.Count());

                foreach (var messageOut in response.Cast<Message>())
                {
                    messageOut.RegisterCallbackPoint(GetTaskCallbackIdentity(task, messageIn), messageIn.CallbackReceiverIdentity);
                    messageOut.SetCorrelationId(messageIn.CorrelationId);
                    messageOut.CopyMessageHops(messageIn.GetMessageHops());

                    localSocket.SendMessage(messageOut);

                    messageTracer.ResponseSent(messageOut, true);
                }
            }
            else
            {
                task.ContinueWith(completed => SafeExecute(() => EnqueueTaskForCompletion(token, completed, messageIn)), token)
                    .ConfigureAwait(false);
            }
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:25,代码来源:ActorHost.cs

示例6: SendMessage

 public static int SendMessage(ISocket socket, string ip, int port, Buffer buffer)
 {
     if (socket.GetSocket().ProtocolType == ProtocolType.Tcp) throw new ConstraintException("Cannot call this method with a TCP socket. Call SendMessage(Socket, Buffer) instead.");
     return socket.SendMessage(ip, port, buffer);
 }
开发者ID:jccprj,项目名称:AwesomeSockets,代码行数:5,代码来源:AweSock.cs

示例7: RegisterMessageHub

        private void RegisterMessageHub(ISocket socket, byte[] receivingSocketIdentity)
        {
            var rdyMessage = Message.Create(new RegisterInternalMessageRouteMessage
                                            {
                                                SocketIdentity = receivingSocketIdentity,
                                                MessageContracts = new[]
                                                                  {
                                                                      new MessageContract
                                                                      {
                                                                          Version = Message.CurrentVersion,
                                                                          Identity = receivingSocketIdentity
                                                                      }
                                                                  }
                                            },
                                            RegisterInternalMessageRouteMessage.MessageIdentity);
            socket.SendMessage(rdyMessage);

            hubRegistered.Set();
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:19,代码来源:MessageHub.cs

示例8: UnregisterDeadNodes

 private void UnregisterDeadNodes(ISocket routerNotificationSocket, DateTime pingTime, TimeSpan pingInterval)
 {
     foreach (var deadNode in clusterMembership.GetDeadMembers(pingTime, pingInterval))
     {
         var message = Message.Create(new UnregisterNodeMessageRouteMessage
                                      {
                                          Uri = deadNode.Uri.ToSocketAddress(),
                                          SocketIdentity = deadNode.Identity
                                      },
                                      UnregisterNodeMessageRouteMessage.MessageIdentity);
         clusterMembership.DeleteClusterMember(deadNode);
         routerNotificationSocket.SendMessage(message);
     }
 }
开发者ID:gitter-badger,项目名称:kino,代码行数:14,代码来源:ClusterMonitor.cs

示例9: MessageRoutingControlMessage

        private bool MessageRoutingControlMessage(IMessage message, ISocket routerNotificationSocket)
        {
            var shouldHandle = IsRequestAllMessageRoutingMessage(message)
                               || IsRequestNodeMessageRoutingMessage(message)
                               || IsUnregisterMessageRoutingMessage(message)
                               || IsRegisterExternalRoute(message)
                               || IsUnregisterRoutingMessage(message)
                               || IsDiscoverMessageRouteMessage(message);

            if (shouldHandle)
            {
                if (IsRegisterExternalRoute(message))
                {
                    AddClusterMember(message);
                }
                if (IsUnregisterRoutingMessage(message))
                {
                    var payload = message.GetPayload<UnregisterNodeMessageRouteMessage>();
                    clusterMembership.DeleteClusterMember(new SocketEndpoint(new Uri(payload.Uri), payload.SocketIdentity));
                }

                routerNotificationSocket.SendMessage(message);
            }

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

示例10: SendMessages

        private void SendMessages(CancellationToken token, Barrier gateway)
        {
            try
            {
                using (clusterMonitorSendingSocket = CreateClusterMonitorSendingSocket())
                {
                    gateway.SignalAndWait(token);
                    try
                    {
                        foreach (var messageOut in outgoingMessages.GetConsumingEnumerable(token))
                        {
                            clusterMonitorSendingSocket.SendMessage(messageOut);
                            // TODO: Block immediatelly for the response
                            // Otherwise, consider the RS dead and switch to failover partner
                            //sendingSocket.ReceiveMessage(token);
                        }
                    }
                    catch (OperationCanceledException)
                    {
                    }

                    clusterMonitorSendingSocket.SendMessage(CreateUnregisterRoutingMessage());
                }
            }
            catch (Exception err)
            {
                logger.Error(err);
            }
        }
开发者ID:gitter-badger,项目名称:kino,代码行数:29,代码来源:ClusterMonitor.cs


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