Example #1
0
 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;
     };
 }
Example #2
0
 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));
 }
Example #3
0
        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);
        }
Example #4
0
 /// <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)
 {
 }
Example #5
0
 public InboundUnassociated(IAssociationEventListener associationEventListener, AssociationHandle wrappedHandle)
 {
     WrappedHandle            = wrappedHandle;
     AssociationEventListener = associationEventListener;
 }
Example #6
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="listener">TBD</param>
 public ListenerRegistered(IAssociationEventListener listener)
 {
     Listener = listener;
 }
Example #7
0
 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);
 }
Example #8
0
 protected abstract void StartAcceptingConnections(IAssociationEventListener listener);
Example #9
0
 protected override void StartAcceptingConnections(IAssociationEventListener listener)
 {
     Task.Run(() => ListenLoop(listener));
 }