Пример #1
0
        public bool OnSessionEstablished(Session session)
        {
            if (session == null || session.SessionType != SessionTypes.Management || session.Connection == null || _managementServer == null)
            {
                return(false);
            }
            try
            {
                IDualChannel channel;
                IPAddress    localAddress = DnsCache.Resolve(Environment.MachineName);
                channel = new DualChannel(session.Connection, session.IP.ToString(), session.RemotePort, localAddress.ToString(), session.SessionType, _traceProvider, _channelFormatter);

                switch (session.SessionType)
                {
                case SessionTypes.Management:
                    ManagementSession managementSession = (ManagementSession)_managementServer.OpenManagementSession(new UserCredentials());
                    channel.RegisterRequestHandler(managementSession);
                    managementSession.Channel = channel;
                    if (channel.Connect(true))
                    {
                        _sessionChannnelMap.Add(managementSession, channel);
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                if (LoggerManager.Instance.ServerLogger != null && LoggerManager.Instance.ServerLogger.IsErrorEnabled)
                {
                    LoggerManager.Instance.ServerLogger.Error("MgtSessionListener.OnSessionEstablished", "Error", ex);
                }
            }
            return(false);
        }