示例#1
0
        override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
        {
            Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>(); 
            try
            {
                foreach (UUID uuid in uuids)
                {
                    string sql = string.Format(@"SELECT agentOnline,currentHandle 
                                                 FROM {0} WHERE UUID = @uuid", m_agentsTableName);
                    using (AutoClosingSqlCommand command = database.Query(sql))
                    {
                        command.Parameters.Add(database.CreateParameter("@uuid", uuid));
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                FriendRegionInfo fri = new FriendRegionInfo();
                                fri.isOnline = (byte)reader["agentOnline"] != 0;
                                fri.regionHandle = Convert.ToUInt64(reader["currentHandle"].ToString());

                                infos[uuid] = fri;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Warn("[MSSQL]: Got exception on trying to find friends regions:", e);
            }

            return infos;
        }
示例#2
0
        override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
        {
            Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();

            DataTable agents = ds.Tables["useragents"];
            foreach (UUID uuid in uuids)
            {
                lock (ds)
                {
                    DataRow row = agents.Rows.Find(uuid.ToString());
                    if (row == null) infos[uuid] = null;
                    else
                    {
                        FriendRegionInfo fri = new FriendRegionInfo();
                        fri.isOnline = (bool)row["agentOnline"];
                        fri.regionHandle = Convert.ToUInt64(row["currentHandle"]);
                        infos[uuid] = fri;
                    }
                }
            }
            return infos;
        }
示例#3
0
        public override Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> friendsIds) 
        { 
            Dictionary<UUID, FriendRegionInfo> friendRegionInfos=new Dictionary<UUID, FriendRegionInfo>();

            foreach (UUID friendId in friendsIds)
            {
                UserAgentData agent=GetAgentByUUID(friendId);
                if (agent != null)
                {
                    FriendRegionInfo fri = new FriendRegionInfo();
                    fri.isOnline = agent.AgentOnline;
                    fri.regionHandle = agent.Handle;

                    friendRegionInfos[friendId] = fri;
                }
            }

            return friendRegionInfos;
        }
示例#4
0
        public virtual Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
        {
            Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>();

            // ask MessageServer about the current on-/offline status and regions the friends are in
            ArrayList parameters = new ArrayList();
            Hashtable map = new Hashtable();

            ArrayList list = new ArrayList();
            foreach (UUID uuid in uuids)
            {
                list.Add(uuid.ToString());
                list.Add(uuid.ToString());
            }
            map["uuids"] = list;

            map["recv_key"] = m_commsManager.NetworkServersInfo.UserRecvKey;
            map["send_key"] = m_commsManager.NetworkServersInfo.UserSendKey;

            parameters.Add(map);

            try
            {
                XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters);
                XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.MessagingURL, 8000);
                Hashtable respData = resp != null ? (Hashtable)resp.Value : null;

                if (respData == null || respData.ContainsKey("faultMessage"))
                {
                    m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessagingServer about user-regions resulted in error: {0}",
                                     respData == null ? "<unknown error>" : respData["faultMessage"]);
                }
                else if (!respData.ContainsKey("count"))
                {
                    m_log.WarnFormat("[OGS1 USER SERVICES]: Wrong format in response for MessagingServer request get_presence_info_bulk: missing 'count' field");
                }
                else
                {
                    int count = (int)respData["count"];
                    m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count);
                    for (int i = 0; i < count; ++i)
                    {
                        if (respData.ContainsKey("uuid_" + i) && respData.ContainsKey("isOnline_" + i) && respData.ContainsKey("regionHandle_" + i))
                        {
                            UUID uuid;
                            if (UUID.TryParse((string)respData["uuid_" + i], out uuid))
                            {
                                FriendRegionInfo info = new FriendRegionInfo();
                                info.isOnline = (bool)respData["isOnline_" + i];
                                if (info.isOnline)
                                {
                                    // TODO remove this after the next protocol update (say, r7800?)
                                    info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]);

                                    // accept missing id
                                    if (respData.ContainsKey("regionID_" + i))
                                        UUID.TryParse((string)respData["regionID_" + i], out info.regionID);
                                }

                                result.Add(uuid, info);
                            }
                        }
                        else
                        {
                            m_log.WarnFormat("[OGS1 USER SERVICES]: Response to get_presence_info_bulk contained an error in entry {0}", i);
                        }
                    }
                }
            }
            catch (WebException e)
            {
                m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message);
            }

            m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count);

            return result;
        }
示例#5
0
        override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
        {
            Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID, FriendRegionInfo>();
            if (uuids.Count == 0) return infos;

            try
            {
                using (ISimpleDB conn = _connFactory.GetConnection())
                {
                    string query = "select UUID, agentOnline, currentHandle from " + m_agentsTableName +
                                          " where UUID IN " + GenerateInList(uuids);

                    using (IDataReader reader = conn.QueryAndUseReader(query))
                    {
                        while (reader.Read())
                        {
                            FriendRegionInfo fri = new FriendRegionInfo();
                            fri.isOnline = (sbyte)reader["agentOnline"] != 0;
                            fri.regionHandle = (ulong)reader["currentHandle"];

                            infos[new UUID((string)reader["UUID"])] = fri;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
                m_log.Error(e.ToString());
            }

            return infos;
        }
示例#6
0
        override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
        {
            MySQLSuperManager dbm = GetLockedConnection("GetFriendRegionInfos");
            Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();

            try
            {
                foreach (UUID uuid in uuids)
                {
                    Dictionary<string, object> param = new Dictionary<string, object>();
                    param["?uuid"] = uuid.ToString();

                    using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
                                          " where UUID = ?uuid", param))
                    {
                        using (IDataReader reader = result.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                FriendRegionInfo fri = new FriendRegionInfo();
                                fri.isOnline = (sbyte)reader["agentOnline"] != 0;
                                fri.regionHandle = (ulong)reader["currentHandle"];

                                infos[uuid] = fri;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
                dbm.Manager.Reconnect();
                m_log.Error(e.Message, e);
            }
            finally
            {
                dbm.Release();
            }

            return infos;
        }
示例#7
0
        override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
        {
            Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();

            try
            {
                using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
                {
                    dbcon.Open();

                    foreach (UUID uuid in uuids)
                    {
                        Dictionary<string, object> param = new Dictionary<string, object>();
                        param["?uuid"] = uuid.ToString();

                        using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName +
                                              " where UUID = ?uuid", param))
                        {
                            using (IDataReader reader = result.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    FriendRegionInfo fri = new FriendRegionInfo();
                                    fri.isOnline = (sbyte)reader["agentOnline"] != 0;
                                    fri.regionHandle = (ulong)reader["currentHandle"];

                                    infos[uuid] = fri;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
                m_log.Error(e.Message, e);
            }

            return infos;
        }