public void AddMessageRoute(InternalRouteRegistration routeRegistration) { if (routeRegistration.ReceiverIdentifier.IsMessageHub()) { var registration = new ReceiverIdentifierRegistration(routeRegistration.ReceiverIdentifier, routeRegistration.KeepRegistrationLocal); messageHubs[registration] = routeRegistration.DestinationSocket; } else { if (routeRegistration.ReceiverIdentifier.IsActor()) { var actorMessages = MapSocketToActor(routeRegistration); foreach (var messageContract in routeRegistration.MessageContracts) { MapMessageToActor(routeRegistration, messageContract); MapActorToMessage(routeRegistration, actorMessages, messageContract); } actorToSocketMap[routeRegistration.ReceiverIdentifier] = routeRegistration.DestinationSocket; } else { throw new ArgumentException($"Requested registration is for unknown Receiver type: [{routeRegistration.ReceiverIdentifier}]!"); } } }
private void MapMessageToActor(InternalRouteRegistration routeRegistration, MessageContract messageContract) { if (!messageToActorMap.TryGetValue(messageContract.Message, out var actors)) { actors = new HashedLinkedList <ReceiverIdentifier>(); messageToActorMap[messageContract.Message] = actors; } if (!actors.Contains(routeRegistration.ReceiverIdentifier)) { var registration = new ReceiverIdentifierRegistration(routeRegistration.ReceiverIdentifier, messageContract.KeepRegistrationLocal); actors.InsertLast(registration); } }
public void AddMessageRoute(InternalRouteRegistration routeRegistration) { var shouldAddSocket = false; if (routeRegistration.ReceiverIdentifier.IsMessageHub()) { var registration = new ReceiverIdentifierRegistration(routeRegistration.ReceiverIdentifier, routeRegistration.KeepRegistrationLocal); shouldAddSocket = !messageHubs.ContainsKey(registration); if (shouldAddSocket) { messageHubs.Add(registration, routeRegistration.DestinationSocket); } } else { if (routeRegistration.ReceiverIdentifier.IsActor()) { var actorMessages = MapSocketToActor(routeRegistration); foreach (var messageContract in routeRegistration.MessageContracts) { MapMessageToActor(routeRegistration, messageContract); MapActorToMessage(routeRegistration, actorMessages, messageContract); } shouldAddSocket = !actorToSocketMap.ContainsKey(routeRegistration.ReceiverIdentifier); if (shouldAddSocket) { actorToSocketMap[routeRegistration.ReceiverIdentifier] = routeRegistration.DestinationSocket; } } else { throw new ArgumentException($"Requested registration is for unknown Receiver type: [{routeRegistration.ReceiverIdentifier}]!"); } } if (shouldAddSocket) { roundRobinList.Add(routeRegistration.DestinationSocket); } }