Beispiel #1
0
 public static Props InboundProps(HandshakeInfo handshakeInfo, AssociationHandle wrappedHandle,
                                  IAssociationEventListener associationEventListener, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector)
 {
     return
         (Props.Create(
              () =>
              new ProtocolStateActor(handshakeInfo, wrappedHandle, associationEventListener, settings, codec, failureDetector)));
 }
Beispiel #2
0
        public override ByteString ConstructAssociate(HandshakeInfo info)
        {
            var handshakeInfo = AkkaHandshakeInfo.CreateBuilder()
                                .SetOrigin(SerializeAddress(info.Origin))
                                .SetUid((ulong)info.Uid);

            return(ConstructControlMessagePdu(CommandType.ASSOCIATE, handshakeInfo));
        }
Beispiel #3
0
 /// <summary>
 /// Constructor for outbound ProtocolStateActors
 /// </summary>
 public ProtocolStateActor(HandshakeInfo handshakeInfo, Address remoteAddress,
                           TaskCompletionSource <AssociationHandle> statusCompletionSource, Transport transport,
                           AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector, int?refuseUid = null)
     : this(
         new OutboundUnassociated(remoteAddress, statusCompletionSource, transport), handshakeInfo, settings, codec, failureDetector,
         refuseUid)
 {
 }
Beispiel #4
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="info">TBD</param>
        /// <exception cref="ArgumentException">
        /// This exception is thrown when the specified <paramref name="info"/> contains an invalid address.
        /// </exception>
        /// <returns>TBD</returns>
        public override ByteString ConstructAssociate(HandshakeInfo info)
        {
            var handshakeInfo = new AkkaHandshakeInfo()
            {
                Origin = SerializeAddress(info.Origin),
                Uid    = (ulong)info.Uid
            };

            return(ConstructControlMessagePdu(CommandType.Associate, handshakeInfo));
        }
Beispiel #5
0
 public AkkaProtocolHandle(Address originalLocalAddress, Address originalRemoteAddress,
                           TaskCompletionSource <IHandleEventListener> readHandlerCompletionSource, AssociationHandle wrappedHandle,
                           HandshakeInfo handshakeInfo, ActorRef stateActor, AkkaPduCodec codec)
     : base(originalLocalAddress, originalRemoteAddress, wrappedHandle, RemoteSettings.AkkaScheme)
 {
     HandshakeInfo     = handshakeInfo;
     StateActor        = stateActor;
     ReadHandlerSource = readHandlerCompletionSource;
     Codec             = codec;
 }
Beispiel #6
0
 private bool SendAssociate(AssociationHandle wrappedHandle, HandshakeInfo info)
 {
     try
     {
         return(wrappedHandle.Write(_codec.ConstructAssociate(info)));
     }
     catch (Exception ex)
     {
         throw new AkkaProtocolException("Error writing ASSOCIATE to transport", ex);
     }
 }
Beispiel #7
0
        private Task <IHandleEventListener> NotifyOutboundHandler(AssociationHandle wrappedHandle,
                                                                  HandshakeInfo handshakeInfo, TaskCompletionSource <AssociationHandle> statusPromise)
        {
            var readHandlerPromise = new TaskCompletionSource <IHandleEventListener>();

            ListenForListenerRegistration(readHandlerPromise);

            statusPromise.SetResult(new AkkaProtocolHandle(_localAddress, wrappedHandle.RemoteAddress, readHandlerPromise, wrappedHandle, handshakeInfo, Self, _codec));

            return(readHandlerPromise.Task);
        }
Beispiel #8
0
 /// <summary>
 /// Common constructor used by both the outbound and the inboud cases
 /// </summary>
 protected ProtocolStateActor(InitialProtocolStateData initialData, HandshakeInfo localHandshakeInfo, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector, int?refuseUid)
 {
     _initialData        = initialData;
     _localHandshakeInfo = localHandshakeInfo;
     _settings           = settings;
     _refuseUid          = refuseUid;
     _localAddress       = _localHandshakeInfo.Origin;
     _codec           = codec;
     _failureDetector = failureDetector;
     InitializeFSM();
 }
Beispiel #9
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);
        }
Beispiel #10
0
 public Associate(HandshakeInfo info)
 {
     Info = info;
 }
Beispiel #11
0
 public abstract ByteString ConstructAssociate(HandshakeInfo info);
Beispiel #12
0
 public static Props OutboundProps(HandshakeInfo handshakeInfo, Address remoteAddress,
                                   TaskCompletionSource <AssociationHandle> statusCompletionSource,
                                   Transport transport, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector, int?refuseUid = null)
 {
     return(Props.Create(() => new ProtocolStateActor(handshakeInfo, remoteAddress, statusCompletionSource, transport, settings, codec, failureDetector, refuseUid)));
 }
Beispiel #13
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)
 {
 }
Beispiel #14
0
 private bool Equals(HandshakeInfo other)
 {
     return(Equals(Origin, other.Origin) && Uid == other.Uid);
 }