/// <summary> /// Handler method to create a network channel /// </summary> /// <returns>The network channel.</returns> /// <param name="scope">The scope calling the method.</param> /// <param name="attr">The channel attribute.</param> /// <param name="type">The type to create the channel for</param> private static IUntypedChannel Creator(ChannelScope scope, ChannelNameAttribute attr, Type type) { return ((IUntypedChannel)typeof(NetworkChannelScope) .GetMethod(nameof(CreateNetworkChannel), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.NonPublic) .MakeGenericMethod(type) .Invoke(scope, new object[] { attr })); }
/// <summary> /// Creates a channel that is wrapped in a profiling channel instance /// </summary> /// <returns>The profiling-wrapped channel.</returns> /// <param name="attribute">The channel attribute.</param> /// <typeparam name="T">The channel type parameter.</typeparam> private static IChannel <T> CreateNetworkChannel <T>(ChannelNameAttribute attribute) { // We do not support annoymous channels, so we assign a random ID if (string.IsNullOrWhiteSpace(attribute.Name)) { attribute.Name = Guid.NewGuid().ToString("N"); } // Transmit the desired channel properties to the channel server NetworkConfig.TransmitRequestAsync(new PendingNetworkRequest(attribute.Name, typeof(T), NetworkMessageType.CreateChannelRequest, attribute)); return(new NetworkChannel <T>(attribute)); }
/// <summary> /// Initializes a new instance of the <see cref="CoCoL.Network.NetworkChannel<T>"/> class. /// </summary> /// <param name="attr">The channel this instance represents.</param> public NetworkChannel(ChannelNameAttribute attr) { m_attribute = attr; }
/// <summary> /// Initializes a new instance of the <see cref="CoCoL.Network.NetworkChannel<T>"/> class. /// </summary> /// <param name="channelid">The channel this instance represents.</param> public NetworkChannel(string channelid) { m_attribute = new ChannelNameAttribute(channelid); }