Abstract base class for HeliosTransport - has separate child implementations for TCP / UDP respectively
상속: Transport
예제 #1
0
        /// <summary>
        /// Converts a <see cref="ByteString"/> structure into a Helios <see cref="NetworkData"/> structure
        /// </summary>
        /// <param name="byteString">The data to send over the network</param>
        /// <param name="address">The address that we received data from / are sending data to</param>
        /// <returns>a new <see cref="NetworkData"/> struct</returns>
        public static NetworkData ToData(ByteString byteString, Address address)
        {
            var data = new NetworkData()
            {
                Buffer     = byteString.ToByteArray(),
                RemoteHost = HeliosTransport.AddressToNode(address)
            };

            data.Length = data.Buffer.Length;
            return(data);
        }
예제 #2
0
        void InitInbound(IChannel channel, IPEndPoint socketAddress, object msg)
        {
            // disable automatic reads
            channel.Configuration.AutoRead = false;

            _associationEventListener.ContinueWith(r =>
            {
                var listener      = r.Result;
                var remoteAddress = HeliosTransport.MapSocketToAddress(socketAddress, WrappedTransport.SchemeIdentifier,
                                                                       WrappedTransport.System.Name);
                AssociationHandle handle;
                Init(channel, socketAddress, remoteAddress, msg, out handle);
                listener.Notify(new InboundAssociation(handle));
            }, TaskContinuationOptions.OnlyOnRanToCompletion);
        }
예제 #3
0
        protected void InitInbound(IConnection connection, INode remoteSocketAddress, NetworkData msg)
        {
            _associationListenerTask.ContinueWith(r =>
            {
                var listener      = r.Result;
                var remoteAddress = HeliosTransport.NodeToAddress(remoteSocketAddress, WrappedTransport.SchemeIdentifier,
                                                                  WrappedTransport.System.Name);

                if (remoteAddress == null)
                {
                    throw new HeliosNodeException("Unknown inbound remote address type {0}", remoteSocketAddress);
                }
                AssociationHandle handle;
                Init(connection, remoteSocketAddress, remoteAddress, msg, out handle);
                listener.Notify(new InboundAssociation(handle));
            }, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.NotOnCanceled | TaskContinuationOptions.NotOnFaulted);
        }
예제 #4
0
        protected void Init(IConnection channel, INode remoteSocketAddress, Address remoteAddress, NetworkData msg,
                            out AssociationHandle op)
        {
            var localAddress = HeliosTransport.NodeToAddress(channel.Local, WrappedTransport.SchemeIdentifier,
                                                             WrappedTransport.System.Name, WrappedTransport.Settings.Hostname);

            if (localAddress != null)
            {
                var handle = CreateHandle(channel, localAddress, remoteAddress);
                handle.ReadHandlerSource.Task.ContinueWith(s =>
                {
                    var listener = s.Result;
                    RegisterListener(channel, listener, msg, remoteSocketAddress);
                }, TaskContinuationOptions.AttachedToParent & TaskContinuationOptions.ExecuteSynchronously & TaskContinuationOptions.NotOnCanceled & TaskContinuationOptions.NotOnFaulted);
                op = handle;
            }
            else
            {
                op = null;
                channel.Close();
            }
        }
예제 #5
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="channel">TBD</param>
        /// <param name="remoteSocketAddress">TBD</param>
        /// <param name="remoteAddress">TBD</param>
        /// <param name="msg">TBD</param>
        /// <param name="op">TBD</param>
        protected void Init(IChannel channel, IPEndPoint remoteSocketAddress, Address remoteAddress, object msg,
                            out AssociationHandle op)
        {
            var localAddress = HeliosTransport.MapSocketToAddress((IPEndPoint)channel.LocalAddress, WrappedTransport.SchemeIdentifier,
                                                                  WrappedTransport.System.Name, WrappedTransport.Settings.Hostname);

            if (localAddress != null)
            {
                var handle = CreateHandle(channel, localAddress, remoteAddress);
                handle.ReadHandlerSource.Task.ContinueWith(s =>
                {
                    var listener = s.Result;
                    RegisterListener(channel, listener, msg, remoteSocketAddress);
                    channel.Configuration.AutoRead = true; // turn reads back on
                }, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.NotOnCanceled | TaskContinuationOptions.NotOnFaulted);
                op = handle;
            }
            else
            {
                op = null;
                channel.CloseAsync();
            }
        }
예제 #6
0
 protected ClientHandler(HeliosTransport heliosWrappedTransport, Address remoteAddress, IConnection underlyingConnection) : base(underlyingConnection)
 {
     WrappedTransport = heliosWrappedTransport;
     RemoteAddress    = remoteAddress;
 }
예제 #7
0
 protected ServerHandler(HeliosTransport wrappedTransport, Task <IAssociationEventListener> associationListenerTask, IConnection underlyingConnection) : base(underlyingConnection)
 {
     WrappedTransport         = wrappedTransport;
     _associationListenerTask = associationListenerTask;
 }
예제 #8
0
 public TcpAssociationHandle(Address localAddress, Address remoteAddress, HeliosTransport transport, IConnection connection)
     : base(localAddress, remoteAddress)
 {
     _channel = connection;
     _transport = transport;
 }
예제 #9
0
 public TcpClientHandler(HeliosTransport heliosWrappedTransport, Address remoteAddress, IConnection underlyingConnection)
     : base(underlyingConnection)
 {
     WrappedTransport = heliosWrappedTransport;
     RemoteAddress = remoteAddress;
 }
예제 #10
0
 public TcpServerHandler(HeliosTransport wrappedTransport, Task<IAssociationEventListener> associationListenerTask, IConnection underlyingConnection)
     : base(underlyingConnection)
 {
     WrappedTransport = wrappedTransport;
     _associationListenerTask = associationListenerTask;
 }
예제 #11
0
 public TcpAssociationHandle(Address localAddress, Address remoteAddress, HeliosTransport transport, IConnection connection)
     : base(localAddress, remoteAddress)
 {
     _channel   = connection;
     _transport = transport;
 }
예제 #12
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="wrappedTransport">TBD</param>
 /// <param name="log">TBD</param>
 /// <param name="remoteAddress">TBD</param>
 public TcpClientHandler(HeliosTransport wrappedTransport, ILoggingAdapter log, Address remoteAddress) : base(wrappedTransport, log)
 {
     _remoteAddress = remoteAddress;
 }
예제 #13
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="wrappedTransport">TBD</param>
 /// <param name="log">TBD</param>
 /// <param name="associationEventListener">TBD</param>
 public TcpServerHandler(HeliosTransport wrappedTransport, ILoggingAdapter log, Task <IAssociationEventListener> associationEventListener) : base(wrappedTransport, log)
 {
     _associationEventListener = associationEventListener;
 }
예제 #14
0
 public TcpServerHandler(HeliosTransport wrappedTransport, ILoggingAdapter log, Task<IAssociationEventListener> associationEventListener) : base(wrappedTransport, log)
 {
     _associationEventListener = associationEventListener;
 }
예제 #15
0
 protected TcpHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) : base(wrappedTransport, log)
 {
 }
예제 #16
0
 public TcpClientHandler(HeliosTransport wrappedTransport, ILoggingAdapter log, Address remoteAddress) : base(wrappedTransport, log)
 {
     _remoteAddress = remoteAddress;
 }
예제 #17
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="wrappedTransport">TBD</param>
 /// <param name="log">TBD</param>
 protected TcpHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) : base(wrappedTransport, log)
 {
 }
예제 #18
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="wrappedTransport">TBD</param>
 /// <param name="log">TBD</param>
 protected CommonHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log)
 {
     WrappedTransport = wrappedTransport;
     Log = log;
 }
예제 #19
0
 protected CommonHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log)
 {
     WrappedTransport = wrappedTransport;
     Log = log;
 }