/// <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); }
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); }
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); }
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(); } }
/// <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(); } }
protected ClientHandler(HeliosTransport heliosWrappedTransport, Address remoteAddress, IConnection underlyingConnection) : base(underlyingConnection) { WrappedTransport = heliosWrappedTransport; RemoteAddress = remoteAddress; }
protected ServerHandler(HeliosTransport wrappedTransport, Task <IAssociationEventListener> associationListenerTask, IConnection underlyingConnection) : base(underlyingConnection) { WrappedTransport = wrappedTransport; _associationListenerTask = associationListenerTask; }
public TcpAssociationHandle(Address localAddress, Address remoteAddress, HeliosTransport transport, IConnection connection) : base(localAddress, remoteAddress) { _channel = connection; _transport = transport; }
public TcpClientHandler(HeliosTransport heliosWrappedTransport, Address remoteAddress, IConnection underlyingConnection) : base(underlyingConnection) { WrappedTransport = heliosWrappedTransport; RemoteAddress = remoteAddress; }
public TcpServerHandler(HeliosTransport wrappedTransport, Task<IAssociationEventListener> associationListenerTask, IConnection underlyingConnection) : base(underlyingConnection) { WrappedTransport = wrappedTransport; _associationListenerTask = associationListenerTask; }
/// <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; }
/// <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; }
public TcpServerHandler(HeliosTransport wrappedTransport, ILoggingAdapter log, Task<IAssociationEventListener> associationEventListener) : base(wrappedTransport, log) { _associationEventListener = associationEventListener; }
protected TcpHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) : base(wrappedTransport, log) { }
public TcpClientHandler(HeliosTransport wrappedTransport, ILoggingAdapter log, Address remoteAddress) : base(wrappedTransport, log) { _remoteAddress = remoteAddress; }
/// <summary> /// TBD /// </summary> /// <param name="wrappedTransport">TBD</param> /// <param name="log">TBD</param> protected TcpHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) : base(wrappedTransport, log) { }
/// <summary> /// TBD /// </summary> /// <param name="wrappedTransport">TBD</param> /// <param name="log">TBD</param> protected CommonHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) { WrappedTransport = wrappedTransport; Log = log; }
protected CommonHandlers(HeliosTransport wrappedTransport, ILoggingAdapter log) { WrappedTransport = wrappedTransport; Log = log; }