private Receive Accepting(IAssociationEventListener listener) { return message => { var connected = message as Tcp.Connected; if (connected != null) { var actor = Context.ActorOf(Props.Create(() => new ConnectionAssociationActor(Sender))); var association = new ConnectionAssociationHandle(actor, connected.LocalAddress.ToAddress(Context.System), connected.RemoteAddress.ToAddress(Context.System)); listener.Notify(new InboundAssociation(association)); } return false; }; }
protected override void OnReceive(object message) { PatternMatch.Match(message) .With <ListenUnderlying>(listen => { LocalAddress = listen.ListenAddress; var capturedSelf = Self; listen.UpstreamListener.ContinueWith( listenerRegistered => capturedSelf.Tell(new ListenerRegistered(listenerRegistered.Result)), TaskContinuationOptions.ExecuteSynchronously); }) .With <ListenerRegistered>(listener => { AssociationListener = listener.Listener; foreach (var dEvent in DelayedEvents) { Self.Tell(dEvent, ActorRefs.NoSender); } DelayedEvents = new Queue <object>(); Context.Become(Ready); }) .Default(m => DelayedEvents.Enqueue(m)); }
private Task <IHandleEventListener> NotifyInboundHandler(AssociationHandle wrappedHandle, HandshakeInfo handshakeInfo, IAssociationEventListener associationEventListener) { var readHandlerPromise = new TaskCompletionSource <IHandleEventListener>(); ListenForListenerRegistration(readHandlerPromise); associationEventListener.Notify( new InboundAssociation( new AkkaProtocolHandle(_localAddress, handshakeInfo.Origin, readHandlerPromise, wrappedHandle, handshakeInfo, Self, _codec))); return(readHandlerPromise.Task); }
/// <summary> /// Constructor for inbound ProtocolStateActors /// </summary> public ProtocolStateActor(HandshakeInfo handshakeInfo, AssociationHandle wrappedHandle, IAssociationEventListener associationEventListener, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector) : this(new InboundUnassociated(associationEventListener, wrappedHandle), handshakeInfo, settings, codec, failureDetector, refuseUid : null) { }
public InboundUnassociated(IAssociationEventListener associationEventListener, AssociationHandle wrappedHandle) { WrappedHandle = wrappedHandle; AssociationEventListener = associationEventListener; }
/// <summary> /// TBD /// </summary> /// <param name="listener">TBD</param> public ListenerRegistered(IAssociationEventListener listener) { Listener = listener; }
protected override Task<IAssociationEventListener> InterceptListen(Address listenAddress, Task<IAssociationEventListener> listenerTask) { _log.Warning("FailureInjectorTransport is active on this system. Gremlins might munch your packets."); listenerTask.ContinueWith(tr => { // Side effecting: As this class is not an actor, the only way to safely modify state is through volatile vars. // Listen is called only during the initialization of the stack, and upstreamListener is not read before this // finishes. _upstreamListener = tr.Result; }, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion); return Task.FromResult((IAssociationEventListener)this); }
protected abstract void StartAcceptingConnections(IAssociationEventListener listener);
protected override void StartAcceptingConnections(IAssociationEventListener listener) { Task.Run(() => ListenLoop(listener)); }