示例#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)));
 }
示例#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));
        }
示例#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)
 {
 }
示例#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));
        }
示例#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;
 }
示例#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);
     }
 }
示例#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);
        }
示例#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();
 }
示例#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);
        }
示例#10
0
 public Associate(HandshakeInfo info)
 {
     Info = info;
 }
示例#11
0
 public abstract ByteString ConstructAssociate(HandshakeInfo info);
示例#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)));
 }
示例#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)
 {
 }
示例#14
0
 private bool Equals(HandshakeInfo other)
 {
     return(Equals(Origin, other.Origin) && Uid == other.Uid);
 }