Ejemplo n.º 1
0
        private Tuple <TestAssociationHandle, TestAssociationHandle> CreateHandlePair(TestTransport remoteTransport,
                                                                                      Address remoteAddress)
        {
            var localHandle  = new TestAssociationHandle(LocalAddress, remoteAddress, this, false);
            var remoteHandle = new TestAssociationHandle(remoteAddress, LocalAddress, remoteTransport, true);

            return(new Tuple <TestAssociationHandle, TestAssociationHandle>(localHandle, remoteHandle));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns the remote endpoint for a pair of endpoints relative to the owner of the supplied <see cref="TestAssociationHandle"/>.
 /// </summary>
 /// <param name="handle">The reference handle to determine the remote endpoint relative to</param>
 /// <param name="listenerPair">pair of listeners in initiator, receiver order</param>
 /// <returns></returns>
 public IHandleEventListener RemoteListenerRelativeTo(TestAssociationHandle handle,
                                                      Tuple <IHandleEventListener, IHandleEventListener> listenerPair)
 {
     if (handle.Inbound)
     {
         return(listenerPair.Item1); //initiator
     }
     return(listenerPair.Item2);     //receiver
 }
Ejemplo n.º 3
0
        public Task DefaultDisassociate(TestAssociationHandle handle)
        {
            var handlers = _registry.DeregisterAssociation(handle.Key);

            handlers.Item1.Notify(new Disassociated(DisassociateInfo.Unknown));
            handlers.Item2.Notify(new Disassociated(DisassociateInfo.Unknown));

            return(Task.Run(() => { }));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Returns the event handler corresponding to the remote endpoint of the given local handle. In other words
        ///     it returns the listener that will receive <see cref="InboundPayload" /> events when
        ///     <seealso cref="AssociationHandle.Write" /> is called.
        /// </summary>
        /// <param name="localHandle">The handle</param>
        /// <returns>The option that contains the listener if it exists.</returns>
        public IHandleEventListener GetRemoteReadHandlerFor(TestAssociationHandle localHandle)
        {
            if (_listenersTable.TryGetValue(localHandle.Key, out var listeners))
            {
                return(RemoteListenerRelativeTo(localHandle, listeners));
            }

            return(null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="handle">TBD</param>
        /// <returns>TBD</returns>
        public Task <bool> DefaultDisassociate(TestAssociationHandle handle)
        {
            var handlers = _registry.DeregisterAssociation(handle.Key);

            if (handlers != null)
            {
                handlers.Item1.Notify(new Disassociated(DisassociateInfo.Unknown));
                handlers.Item2.Notify(new Disassociated(DisassociateInfo.Unknown));
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 6
0
        private Task <bool> DefaultWriteBehavior(TestAssociationHandle handle, ByteString payload)
        {
            var remoteReadHandler = _registry.GetRemoteReadHandlerFor(handle);

            if (remoteReadHandler != null)
            {
                remoteReadHandler.Notify(new InboundPayload(payload));
                return(Task.Run(() => true));
            }

            return(Task.Run(() =>
            {
                throw new ArgumentException("No association present");
#pragma warning disable 162
                return true;

#pragma warning restore 162
            }));
        }
Ejemplo n.º 7
0
 public Task <bool> Write(TestAssociationHandle handle, ByteString payload)
 {
     return(WriteBehavior.Apply(new Tuple <TestAssociationHandle, ByteString>(handle, payload)));
 }
Ejemplo n.º 8
0
 public Task Disassociate(TestAssociationHandle handle)
 {
     return(DisassociateBehavior.Apply(handle));
 }