本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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));
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
}