public EmbeddedChannel(IChannelId id, bool hasDisconnect, bool start, params IChannelHandler[] handlers) : base(null, id) { this.Metadata = hasDisconnect ? METADATA_DISCONNECT : METADATA_NO_DISCONNECT; this.Configuration = new DefaultChannelConfiguration(this); if (handlers == null) { throw new ArgumentNullException(nameof(handlers)); } IChannelPipeline p = this.Pipeline; p.AddLast(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; foreach (IChannelHandler h in handlers) { if (h == null) { break; } pipeline.AddLast(h); } })); if (start) { this.Start(); } }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="parent">The parent of this channel. Pass <c>null</c> if there's no parent.</param> /// <param name="id">An <see cref="IChannelId"/> for the new channel.</param> protected AbstractChannel(IChannel parent, IChannelId id) { this.Parent = parent; this.Id = id; this.channelUnsafe = this.NewUnsafe(); this.pipeline = this.NewChannelPipeline(); }
public void EnsureDefaultChannelId() { TestChannel channel = new TestChannel(); IChannelId channelId = channel.Id; Assert.True(channelId is DefaultChannelId); }
/// <summary> /// Create a new instance with the pipeline initialized with the specified handlers. /// </summary> /// <param name="id">The <see cref="IChannelId" /> of this channel.</param> /// <param name="handlers"> /// The <see cref="IChannelHandler" />s that will be added to the <see cref="IChannelPipeline" /> /// </param> public EmbeddedChannel(IChannelId id, params IChannelHandler[] handlers) : base(null, id) { this.Configuration = new DefaultChannelConfiguration(this); if (handlers == null) { throw new NullReferenceException("handlers cannot be null"); } IChannelPipeline p = this.Pipeline; p.AddLast(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; foreach (IChannelHandler h in handlers) { if (h == null) { break; } pipeline.AddLast(h); } })); Task future = this.loop.RegisterAsync(this); Debug.Assert(future.IsCompleted); p.AddLast(new LastInboundHandler(this.InboundMessages, this.RecordException)); }
public EmbeddedChannel(IChannel parent, IChannelId id, bool hasDisconnect, bool register, params IChannelHandler[] handlers) : base(parent, id) { Metadata = GetMetadata(hasDisconnect); Configuration = new DefaultChannelConfiguration(this); Setup(register, handlers); }
public IChannel Find(IChannelId id) { IChannel channel; this.nonServerChannels.TryGetValue(id, out channel); return(channel); }
/// <summary>Create a new instance with the pipeline initialized with the specified handlers.</summary> /// <param name="id">The <see cref="IChannelId" /> of this channel.</param> /// <param name="hasDisconnect"> /// <c>false</c> if this <see cref="IChannel" /> will delegate <see cref="DisconnectAsync" /> /// to <see cref="CloseAsync" />, <c>true</c> otherwise. /// </param> /// <param name="handlers"> /// The <see cref="IChannelHandler" />s that will be added to the <see cref="IChannelPipeline" /> /// </param> public EmbeddedChannel(IChannelId id, bool hasDisconnect, params IChannelHandler[] handlers) : base(null, id) { this.Metadata = hasDisconnect ? METADATA_DISCONNECT : METADATA_NO_DISCONNECT; this.Configuration = new DefaultChannelConfiguration(this); if (handlers == null) { throw new ArgumentNullException(nameof(handlers)); } IChannelPipeline p = this.Pipeline; p.AddLast(new ActionChannelInitializer <IChannel>(channel => { IChannelPipeline pipeline = channel.Pipeline; foreach (IChannelHandler h in handlers) { if (h == null) { break; } pipeline.AddLast(h); } })); Task future = this.loop.RegisterAsync(this); Debug.Assert(future.IsCompleted); p.AddLast(new LastInboundHandler(this.InboundMessages, this.RecordException)); }
/// <summary> /// Creates a new instance. /// //* @param parent //* the parent of this channel. {@code null} if there's no parent. /// </summary> protected AbstractChannel(IChannel parent , IChannelId id) { this.Parent = parent; this.Id = id; this.channelUnsafe = this.NewUnsafe(); this.pipeline = new DefaultChannelPipeline(this); }
public int CompareTo(IChannelId other) { if (other is EmbeddedChannelId) { return 0; } return string.Compare(this.AsLongText(), other.AsLongText(), StringComparison.Ordinal); }
public int CompareTo(IChannelId other) { if (other.AsShortText() == Id) { return(1); } return(0); }
public int CompareTo(IChannelId other) { if (other is EmbeddedChannelId) { return(0); } return(string.Compare(this.AsLongText(), other.AsLongText(), StringComparison.Ordinal)); }
public int CompareTo(IChannelId other) { if (other is EmbeddedChannelId) { return 0; } return string.Compare(ToString(), other.ToString(), StringComparison.Ordinal); }
bool IEquatable <IChannelId> .Equals(IChannelId other) { if (ReferenceEquals(this, other)) { return(true); } return(other is Http2StreamChannelId streamChannelId && Equals(streamChannelId)); }
public int CompareTo(IChannelId other) { if (other is EmbeddedChannelId) { return(0); } return(string.Compare(ToString(), other.ToString(), StringComparison.Ordinal)); }
internal static bool Delete(NettyNetwork network, IChannelId channelId) { if (!NetworkConnections.TryGetValue(network.Id, out ConcurrentDictionary <IChannelId, ChannelContext> connections)) { return(false); } return(connections.TryRemove(channelId, out ChannelContext value)); }
/// <summary> /// Creates a new instance. /// </summary> /// <param name="parent">The parent of this channel. Pass <c>null</c> if there's no parent.</param> /// <param name="id">An <see cref="IChannelId"/> for the new channel.</param> protected AbstractChannel(IChannel parent, IChannelId id) { Parent = parent; Id = id; _channelUnsafe = NewUnsafe(); _pipeline = NewChannelPipeline(); _unsafeVoidPromise = new VoidChannelPromise(this, false); _closeFuture = NewPromise(); }
protected AbstractChannel(IChannelId id, IChannel parent) { Contract.Requires(id != null); Id = id; Parent = parent; // ReSharper disable once VirtualMemberCallInContructor _channelUnsafe = NewUnsafe(); _pipeline = new DefaultChannelPipeline(this); }
protected AbstractChannel(IChannelId id, IChannel parent) { Contract.Requires(id != null); Id = id; Parent = parent; // ReSharper disable once VirtualMemberCallInContructor _channelUnsafe = NewUnsafe(); _pipeline = new DefaultChannelPipeline(this); }
public IChannel Find(IChannelId id) { var connction = this.FindConnectionInfo(id); if (connction != null) { return(connction.Channel); } return(default);
private void AddCallContextAwaiter(IChannelId channelId, int rpcId, ICallContext callContext) { if (!CallContexts.TryGetValue(channelId, out ConcurrentDictionary <int, ICallContext> callContexts)) { callContexts = new ConcurrentDictionary <int, ICallContext>(); CallContexts.AddOrUpdate(channelId, callContexts, (k, v) => callContexts); } callContexts.AddOrUpdate(rpcId, callContext, (k, v) => callContext); }
public EmbeddedChannel(IChannelId id, bool hasDisconnect, IChannelConfiguration config, params IChannelHandler[] handlers) : base(null, id) { Contract.Requires(config != null); this.Metadata = GetMetadata(hasDisconnect); this.Configuration = config; this.Setup(true, handlers); }
public bool Remove(IChannelId channelId) { IChannel ch; if (this.nonServerChannels.TryRemove(channelId, out ch)) { return(true); } return(false); }
public EmbeddedChannel(IChannelId id, bool hasDisconnect, IChannelConfiguration config, params IChannelHandler[] handlers) : base(null, id) { if (config is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.config); } Metadata = GetMetadata(hasDisconnect); Configuration = config; Setup(true, handlers); }
public IChannel Find(IChannelId id) { if (_nonServerChannels.TryGetValue(id, out IChannel channel)) { return(channel); } else { _ = _serverChannels.TryGetValue(id, out channel); return(channel); } }
internal ICallContext CreateAwaiterCallContext <TResult>(IChannelId channelId, int rpcId, Type messageType) { var callContext = new CallContext <TResult>() { MessageType = messageType, Tcs = new TaskCompletionSource <TResult>(), }; AddCallContextAwaiter(channelId, rpcId, callContext); return(callContext); }
public void DisposeConnection(IChannelId clientID) { if (!TryGetClient(clientID, out GameClient Client)) { return; } if (Client != null) { Client.Dispose(); } this._clients.TryRemove(clientID, out Client); }
public IChannel Find(IChannelId id) { IChannel channel; if (this.nonServerChannels.TryGetValue(id, out channel)) { return(channel); } else { this.serverChannels.TryGetValue(id, out channel); return(channel); } }
public bool Remove(IChannelId channelId) { //IChannel ch; if (_serverChannels.TryRemove(channelId, out _)) { return(true); } if (_nonServerChannels.TryRemove(channelId, out _)) { return(true); } return(false); }
public int CompareTo(IChannelId other) { if (other is Http2StreamChannelId otherId) { int res = _parentId.CompareTo(otherId._parentId); if (0u >= (uint)res) { return(_id - otherId._id); } else { return(res); } } return(_parentId.CompareTo(other)); }
public EveryOneBut(IChannelId id) { _id = id; }
public int CompareTo(IChannelId other) => 0;
/// <summary> /// Create a new instance with an empty pipeline with the specified <see cref="IChannelId" />. /// </summary> /// <param name="channelId">The <see cref="IChannelId" /> of this channel. </param> public EmbeddedChannel(IChannelId channelId) : this(channelId, EMPTY_HANDLERS) { }
public EmbeddedChannel(IChannelId id, bool hasDisconnect, bool register, params IChannelHandler[] handlers) : this(null, id, hasDisconnect, register, handlers) { }
public EmbeddedChannel(IChannelId id, params IChannelHandler[] handlers) : this(id, false, handlers) { }
public EveryOneBut(IChannelId id) { this.id = id; }
public int CompareTo(IChannelId other) { return 0; }