Exemplo n.º 1
0
 internal ConnectionBlock(Server server, ILayerFactory layerFactory, int connectionCount)
 {
     _connections = new SaeaLayerCallback[connectionCount];
     var perConnectionBufferSize = layerFactory.PerConnectionBufferSize;
     var reserveAtEnd = layerFactory.CommonBufferSize;
     var constantsOffset = checked(connectionCount * perConnectionBufferSize);
     var buffer = new byte[checked(constantsOffset + reserveAtEnd)];
     layerFactory.InitCommonBuffer(buffer, constantsOffset);
     for (var i = 0; i < connectionCount; i++)
     {
         var handler = (ITransportLayerHandler)layerFactory.Create(buffer, i * perConnectionBufferSize, constantsOffset, i);
         var callback = new SaeaLayerCallback(handler, server.ListenSocket, server, i, server.ContextFlow);
         _connections[i] = callback;
         handler.PrepareAccept();
     }
 }
Exemplo n.º 2
0
        internal ConnectionBlock(Server server, ILayerFactory layerFactory, int connectionCount)
        {
            _connections = new SaeaLayerCallback[connectionCount];
            var perConnectionBufferSize = layerFactory.PerConnectionBufferSize;
            var reserveAtEnd            = layerFactory.CommonBufferSize;
            var constantsOffset         = checked (connectionCount * perConnectionBufferSize);
            var buffer = new byte[checked (constantsOffset + reserveAtEnd)];

            layerFactory.InitCommonBuffer(buffer, constantsOffset);
            for (var i = 0; i < connectionCount; i++)
            {
                var handler  = (ITransportLayerHandler)layerFactory.Create(buffer, i * perConnectionBufferSize, constantsOffset, i);
                var callback = new SaeaLayerCallback(handler, server.ListenSocket, server, i, server.ContextFlow);
                _connections[i] = callback;
                handler.PrepareAccept();
            }
        }