Ejemplo n.º 1
0
        private void SslAuthenticateAsyncCallback(IAsyncResult ar)
        {
            Tuple <TcpSession, SslStream> state = (Tuple <TcpSession, SslStream>)ar.AsyncState;
            ISession  session = state.Item1;
            TcpServer server  = (TcpServer)session.Server;

            try
            {
                if (server.EnableLog(LogType.Info))
                {
                    server.Log(LogType.Info, session, "{0} end ssl Authenticate", session.RemoteEndPoint);
                }
                SslStream sslStream = state.Item2;
                sslStream.EndAuthenticateAsServer(ar);
                EventArgs.ConnectedEventArgs cead = new EventArgs.ConnectedEventArgs();
                cead.Server  = server;
                cead.Session = session;
                server.OnConnected(cead);
                ((TcpSession)session).SyncSSLData();
                server.BeginReceive(state.Item1);
                if (server.EnableLog(LogType.Info))
                {
                    server.Log(LogType.Info, session, "{0} begin receive", session.RemoteEndPoint);
                }
            }
            catch (Exception e_)
            {
                if (this.EnableLog(LogType.Warring))
                {
                    this.Error(e_, state?.Item1, "create session ssl authenticate callback error {0}", e_.Message);
                }
                if (session != null)
                {
                    session.Dispose();
                }
            }
        }