Пример #1
0
        public bool TryGetSessionInfo(Request request, out SessionInfo sinfo)
        {
            bool success = false;

            sinfo = new SessionInfo();
            if (request.Query.ContainsKey("sid"))
            {
                string sid = request.Query["sid"].ToString();
                if (m_Sessions.Contains(sid))
                {
                    SessionInfo session;
                    if (m_Sessions.TryGetValue(sid, out session) &&
                        session.IpAddress == request.IPEndPoint.Address.ToString())
                    {
                        sinfo = session;
                        m_Sessions.AddOrUpdate(sid, session, m_WebApp.SessionTimeout);
                        success = true;
                    }
                }
                else
                {
                    UUID sessionid = UUID.Zero;
                    if (UUID.TryParse(request.Query["sid"].ToString(), out sessionid))
                    {
                        PresenceInfo pinfo = m_PresenceService.GetAgent(sessionid);
                        if (pinfo != null)
                        {
                            m_log.DebugFormat("[Wifi]: User is present in the grid");
                            success = true;

                            UserAccount account = null;
                            if (request.Query.ContainsKey("uid"))
                            {
                                UUID userID = UUID.Zero;
                                if (UUID.TryParse(request.Query["uid"].ToString(), out userID))
                                {
                                    account = m_UserAccountService.GetUserAccount(UUID.Zero, userID);
                                }
                            }
                            else
                            {
                                m_log.DebugFormat("[Wifi]: No uid in Query");
                            }

                            sinfo.IpAddress = request.IPEndPoint.Address.ToString();
                            sinfo.Sid       = request.Query["sid"].ToString();
                            sinfo.Account   = account;
                            sinfo.Notify    = new NotificationData();

                            m_Sessions.Add(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
                        }
                        else
                        {
                            m_log.DebugFormat("[Wifi]: User is not present in the grid");
                        }
                    }
                    else
                    {
                        m_log.DebugFormat("[Wifi]: Unable o parse sid {0}", request.Query["sid"].ToString());
                    }
                }
            }
            //else
            //    m_log.DebugFormat("[Wifi]: no sid in Query");

            return(success);
        }
Пример #2
0
 public Environment(Request req)
 {
     m_Request = req;
 }