public MulticastUdpConnection(NetworkEventLoop eventLoop, INode binding, INode multicastAddress, TimeSpan timeout, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator) : base(eventLoop, binding, timeout, encoder, decoder, allocator) { MulticastAddress = multicastAddress; InitMulticastClient(); }
public MulticastUdpConnection(NetworkEventLoop eventLoop, INode binding, INode multicastAddress, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator) : this( eventLoop, binding, multicastAddress, NetworkConstants.DefaultConnectivityTimeout, encoder, decoder, allocator) { }
public UdpConnection(Socket client, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator) { InitClient(client); Encoder = encoder; Decoder = decoder; Allocator = allocator; }
protected ProxyReactorBase(NodeConfig nodeConfig, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(nodeConfig, encoder, decoder, allocator, bufferSize) { BufferSize = bufferSize; }
protected UnstreamedConnectionBase(NetworkEventLoop eventLoop, INode binding, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : this( eventLoop, binding, NetworkConstants.DefaultConnectivityTimeout, encoder, decoder, allocator, bufferSize ) { }
protected SingleReceiveLoopProxyReactor(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, SocketType socketType = SocketType.Stream, ProtocolType protocol = ProtocolType.Tcp, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(localAddress, localPort, eventLoop, encoder, decoder, allocator, socketType, protocol, bufferSize) { }
public AlternativeCompositeByteBuf(IByteBufAllocator alloc, bool direct, params ByteBuf[] buffers) { _alloc = alloc; _direct = direct; AddComponent(buffers); // TODO leak needed? leak = leakDetector.open(this); }
public MulticastUdpConnection(Socket client, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator) : base(client) { InitMulticastClient(); Encoder = encoder; Decoder = decoder; Allocator = allocator; }
public SerialPortReactor(NodeConfig nodeConfig, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(nodeConfig, encoder, decoder, allocator, bufferSize) { networkState = CreateNetworkState(Listener, this.LocalEndpoint, allocator.Buffer(bufferSize), bufferSize); }
protected ProxyReactorBase(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, SocketType socketType = SocketType.Stream, ProtocolType protocol = ProtocolType.Tcp, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(localAddress, localPort, eventLoop, encoder, decoder, allocator, socketType, protocol, bufferSize) { BufferSize = bufferSize; }
public TcpConnection(Socket client, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(bufferSize) { InitClient(client); Encoder = encoder; Decoder = decoder; Allocator = allocator; }
/// <summary> /// Expand the existing cumulative <see cref="IByteBuf" />. /// </summary> private static IByteBuf ExpandCumulation(IByteBufAllocator alloc, IByteBuf cumulation, int readable) { var old = cumulation; cumulation = alloc.Buffer(old.ReadableBytes + readable); cumulation.WriteBytes(old); old.Release(); return cumulation; }
public TcpConnection(TcpClient client, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(bufferSize) { InitClient(client); Encoder = encoder; Decoder = decoder; Allocator = allocator; }
protected ProxyReactorBase(INode nodeConfig, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(nodeConfig, encoder, decoder, allocator, bufferSize) { BufferSize = bufferSize; networkState = CreateNetworkState(Listener, this.LocalEndpoint, allocator.Buffer(bufferSize), bufferSize); }
public MulticastUdpConnection(UdpClient client, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator) : base(client) { InitMulticastClient(); Encoder = encoder; Decoder = decoder; Allocator = allocator; }
/// <summary> /// Expand the existing cumulative <see cref="IByteBuf" />. /// </summary> private static IByteBuf ExpandCumulation(IByteBufAllocator alloc, IByteBuf cumulation, int readable) { var old = cumulation; cumulation = alloc.Buffer(old.ReadableBytes + readable); cumulation.WriteBytes(old); old.Release(); return(cumulation); }
public TcpProxyReactor(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base( localAddress, localPort, eventLoop, encoder, decoder, allocator, SocketType.Stream, ProtocolType.Tcp, bufferSize) { LocalEndpoint = new IPEndPoint(localAddress, localPort); Listener = new Socket(LocalEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); }
public TcpProxyReactor(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base( localAddress, localPort, eventLoop, encoder, decoder, allocator, SocketType.Stream, ProtocolType.Tcp, bufferSize) { LocalEndpoint = new IPEndPoint(localAddress, localPort); Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); }
public UdpProxyReactor(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base( localAddress, localPort, eventLoop, encoder, decoder, allocator, SocketType.Dgram, ProtocolType.Udp, bufferSize) { LocalEndpoint = new IPEndPoint(localAddress, localPort); RemoteEndPoint = new IPEndPoint(IPAddress.Any, 0); }
public UnpooledDirectByteBuf(IByteBufAllocator alloc, byte[] initialArray, int readerIndex, int writerIndex, int maxCapacity) : base(maxCapacity) { Contract.Requires(alloc != null); Contract.Requires(initialArray != null); Contract.Requires(initialArray.Length <= maxCapacity); Allocator = alloc; SetBuffer(initialArray); SetIndex(readerIndex, writerIndex); }
public UnpooledDirectByteBuf(IByteBufAllocator alloc, int initialCapacity, int maxCapacity) : base(maxCapacity) { if(alloc == null) throw new ArgumentNullException("alloc"); if(initialCapacity < 0) throw new ArgumentOutOfRangeException("initialCapacity", "initialCapacity must be at least 0"); if(maxCapacity < 0) throw new ArgumentOutOfRangeException("maxCapacity", "maxCapacity must be at least 0"); if(initialCapacity > maxCapacity) throw new ArgumentException(string.Format("initialCapacity {0} must be less than maxCapacity {1}", initialCapacity, maxCapacity)); _alloc = alloc; _capacity = initialCapacity; SetByteBuffer(ByteBuffer.AllocateDirect(initialCapacity)); }
protected ReactorBase(INode listener, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) { Decoder = decoder; Encoder = encoder; Allocator = allocator; Listener = listener; Backlog = NetworkConstants.DefaultBacklog; BufferSize = bufferSize; ConnectionAdapter = new ReactorConnectionAdapter(this); }
public SingleThreadEventloop() { this.alloc = DefaultByteBufAllocator.Default; this.taskQueue = new ConcurrentQueue <IRunnable>(); this.schedulerQueue = new PriorityQueue <ISchedulerRunable>(); thread = new Thread(loop) { IsBackground = true }; thread.Start(); }
public CompositeByteBuf(IByteBufAllocator alloc, bool direct, int maxNumComponents, params ByteBuf[] buffers) : base(Int32.MaxValue) { if (alloc == null) { throw new NullReferenceException("alloc"); } _alloc = alloc; _direct = direct; _maxNumComponents = maxNumComponents; // TODO leak detector needed? }
protected UnstreamedConnectionBase(NetworkEventLoop eventLoop, INode binding, TimeSpan timeout, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base() { Decoder = decoder; Encoder = encoder; Allocator = allocator; Created = DateTimeOffset.UtcNow; Binding = binding; Timeout = timeout; BufferSize = bufferSize; NetworkEventLoop = eventLoop; }
public UdpProxyReactor(INode listener, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(listener, encoder, decoder, allocator, bufferSize) { UdpNodeConfig nodeConfig = listener.nodeConfig as UdpNodeConfig; LocalEndPoint = new IPEndPoint(IPAddress.Parse(nodeConfig.LocalAddress), nodeConfig.LocalPort); RemoteEndPoint = new IPEndPoint(IPAddress.Any, nodeConfig.LocalPort); ListenerSocket = new Socket(LocalEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); }
protected ReactorBase(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, SocketType socketType = SocketType.Stream, ProtocolType protocol = ProtocolType.Tcp, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) { Decoder = decoder; Encoder = encoder; Allocator = allocator; LocalEndpoint = new IPEndPoint(localAddress, localPort); Listener = new Socket(AddressFamily.InterNetwork, socketType, protocol); if (protocol == ProtocolType.Tcp) { Transport = TransportType.Tcp; } else if (protocol == ProtocolType.Udp) { Transport = TransportType.Udp; } Backlog = NetworkConstants.DefaultBacklog; EventLoop = eventLoop; ConnectionAdapter = new ReactorConnectionAdapter(this); BufferSize = bufferSize; }
/// <summary> /// 执行通道已注册到Eventloop事件 /// </summary> public Task fireOnChannelRegister(TaskCompletionSource promise) { Execute(() => { alloc = NewByteBufAlloc(); pipeline.SetAlloc(alloc); if (eventloop.Alloc == null) { eventloop.SetAlloc(alloc); } pipeline.fireChannelRegister(); }); return(promise.Task); }
public MutlEventloopGroup(Func <IEventloop> eventloopFactory, int eventloopCount, IByteBufAllocator bufAlloc = null) { //Ensure.Ensures(bufAlloc.ArenaCounter < eventloopCount, "IByteBufAllocator.ArenaCounter数量不能小于EventloopCounter"); this.NewEventloopFactory = eventloopFactory; this.ByteBufAllocator = bufAlloc; loops = new IEventloop[eventloopCount]; for (int i = 0; i < eventloopCount; i++) { loops[i] = NewEventloopFactory(); if (bufAlloc != null) { loops[i].SetAlloc(bufAlloc); } } }
public SerialPortReactor(INode listener, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(listener, encoder, decoder, allocator, bufferSize) { SerialNodeConfig nodeConfig = listener.nodeConfig as SerialNodeConfig; ListenerSocket = new SerialPort { PortName = nodeConfig.PortName, BaudRate = nodeConfig.BaudRate, DataBits = nodeConfig.DataBits, StopBits = nodeConfig.StopBits, Parity = nodeConfig.Parity, ReceivedBytesThreshold = 1 }; }
protected ReactorBase(NodeConfig nodeConfig, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) { Decoder = decoder; Encoder = encoder; Allocator = allocator; Listener = new SerialPort(); Listener.PortName = nodeConfig.PortName; Listener.BaudRate = nodeConfig.BaudRate; Listener.DataBits = nodeConfig.DataBits; Listener.StopBits = nodeConfig.StopBits; Listener.Parity = nodeConfig.Parity; Listener.ReceivedBytesThreshold = 1; //LocalEndpoint = new IPEndPoint(localAddress, localPort); Backlog = NetworkConstants.DefaultBacklog; BufferSize = bufferSize; ConnectionAdapter = new ReactorConnectionAdapter(this); }
private UnpooledHeapByteBuf(IByteBufAllocator alloc, sbyte[] initialArray, int readerIndex, int writerIndex, int maxCapacity) : base(maxCapacity) { if (alloc == null) { throw new NullReferenceException("alloc"); } if (initialArray == null) { throw new NullReferenceException("initialArray"); } if (initialArray.Length > maxCapacity) { throw new ArgumentException(String.Format( "initialCapacity({0}) > maxCapacity({1})", initialArray.Length, maxCapacity)); } _alloc = alloc; SetArray(initialArray); SetIndex(readerIndex, writerIndex); }
public UnpooledDirectByteBuf(IByteBufAllocator alloc, int initialCapacity, int maxCapacity) : base(maxCapacity) { if (alloc == null) { throw new ArgumentNullException("alloc"); } if (initialCapacity < 0) { throw new ArgumentOutOfRangeException("initialCapacity", "initialCapacity must be at least 0"); } if (maxCapacity < 0) { throw new ArgumentOutOfRangeException("maxCapacity", "maxCapacity must be at least 0"); } if (initialCapacity > maxCapacity) { throw new ArgumentException(string.Format("initialCapacity {0} must be less than maxCapacity {1}", initialCapacity, maxCapacity)); } _alloc = alloc; _capacity = initialCapacity; SetByteBuffer(ByteBuffer.AllocateDirect(initialCapacity)); }
public UnpooledDirectByteBuf(IByteBufAllocator alloc, int initialCapacity, int maxCapacity) : base(maxCapacity) { if (alloc == null) { throw new NullReferenceException("alloc"); } if (initialCapacity < 0) { throw new ArgumentException("initialCapacity: " + initialCapacity); } if (maxCapacity < 0) { throw new ArgumentException("maxCapacity: " + maxCapacity); } if (initialCapacity > maxCapacity) { throw new ArgumentException(String.Format( "initialCapacity({0}) > maxCapacity({1})", initialCapacity, maxCapacity)); } _alloc = alloc; SetByteBuffer(Convenient.AllocateDirect(initialCapacity)); }
public DummyConnection(IByteBufAllocator allocator) { Allocator = allocator; }
public TcpSingleEventLoopProxyReactor(IPAddress localAddress, int localPort, NetworkEventLoop eventLoop, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(localAddress, localPort, eventLoop, encoder, decoder, allocator, bufferSize) { }
public UnpooledHeapByteBuf(IByteBufAllocator alloc, sbyte[] initialArray, int maxCapacity) : this(alloc, initialArray, 0, initialArray.Length, maxCapacity) { }
public IByteBuf Allocate(IByteBufAllocator allocator) { return(allocator.Buffer(_bufferSize)); }
/// <summary> /// Copy constructor /// </summary> internal protected CircularByteBuf(IByteBufAllocator allocator, ICircularBuffer<byte> buffer) : base(buffer.MaxCapacity) { InternalBuffer = buffer; Alloc = allocator; }
public IByteBuf Allocate(IByteBufAllocator allocator) { return allocator.Buffer(_bufferSize); }
//private MemoryStream _tmpNioBuf; public UnpooledHeapByteBuf(IByteBufAllocator alloc, int initialCapacity, int maxCapacity) : this(alloc, new sbyte[initialCapacity], 0, 0, maxCapacity) { }
public void SetAlloc(IByteBufAllocator bufAlloc) { this.alloc = bufAlloc; }
public new ServerBootstrap SetAllocator(IByteBufAllocator allocator) { base.SetAllocator(allocator); return(this); }
public virtual AbstractBootstrap SetAllocator(IByteBufAllocator allocator) { Allocator = allocator; return this; }
public EmptyByteBuf(IByteBufAllocator allocator) : base(0) { Allocator = allocator; }
public UdpConnection(NetworkEventLoop eventLoop, INode binding, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator) : base(eventLoop, binding, encoder, decoder, allocator) { InitClient(); }
public TcpConnection(NetworkEventLoop eventLoop, INode node, IMessageEncoder encoder, IMessageDecoder decoder, IByteBufAllocator allocator, int bufferSize = NetworkConstants.DEFAULT_BUFFER_SIZE) : base(eventLoop, node, encoder, decoder, allocator, bufferSize) { InitClient(); }
public new ClientBootstrap SetAllocator(IByteBufAllocator allocator) { base.SetAllocator(allocator); return this; }