コード例 #1
0
        internal TcpSocketSaeaEngineBased(
            TcpSocketSaeaSessionType saeaSessionType,
            TcpSocketConfigurationBase configuration,
            NotifyEventHandler <TcpSessionNotify, TcpSocketSaeaSession> completetionNotify)
        {
            TcpSocketSaeaSessions = new List <TcpSocketSaeaSession>();
            HandlerSaeaPool       = new SaeaAwaiterPool();
            SessionPool           = new SessionPool();

            SaeaSessionType    = saeaSessionType;
            Configuration      = configuration;
            CompletetionNotify = completetionNotify;

            HandlerSaeaPool.Initialize(() => new SaeaAwaiter(),
                                       (saea) =>
            {
                try
                {
                    saea.Saea.AcceptSocket = null;
                    saea.Saea.SetBuffer(EmptyArray, 0, EmptyArray.Length);
                    saea.Saea.RemoteEndPoint = null;
                    saea.Saea.SocketFlags    = SocketFlags.None;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("server_clean awaiter info:" + ex.Message);
                }
            },
                                       50);
            if (saeaSessionType == TcpSocketSaeaSessionType.Full)
            {
                SessionPool.Initialize(() => new TcpSocketSaeaFullBased(Configuration, HandlerSaeaPool, SessionPool, completetionNotify, this),
                                       (session) =>
                {
                    session.Detach();
                }, 50);
            }
            else
            {
                SessionPool.Initialize(() => new TcpSocketSaeaPackBased(Configuration, HandlerSaeaPool, SessionPool, completetionNotify, this),
                                       (session) =>
                {
                    session.Detach();
                }, 50);
            }
        }