diff options
author | Melanie | 2009-12-28 23:42:08 +0000 |
---|---|---|
committer | Melanie | 2009-12-28 23:42:08 +0000 |
commit | e0fc854f05b137c353196356e5b26d11b6ee6867 (patch) | |
tree | 9a1c0a29178a9f3e10b10f5e184f46bce1c61078 /OpenSim/Data/MySQL/MySQLPresenceData.cs | |
parent | Add the second step of the friends migration to pull data from the old table ... (diff) | |
download | opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.zip opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.gz opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.bz2 opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.xz |
Adding new fields and home location methid to presence. Adding cleanup
(deleting all but one presence record) on logout so that they don't pile up.
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLPresenceData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLPresenceData.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 8ccad90..72b8a0c 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs | |||
@@ -93,5 +93,57 @@ namespace OpenSim.Data.MySQL | |||
93 | 93 | ||
94 | return true; | 94 | return true; |
95 | } | 95 | } |
96 | |||
97 | public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
98 | { | ||
99 | PresenceData[] pd = Get("UserID", userID); | ||
100 | if (pd.Length == 0) | ||
101 | return false; | ||
102 | |||
103 | MySqlCommand cmd = new MySqlCommand(); | ||
104 | |||
105 | cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); | ||
106 | |||
107 | cmd.Parameters.AddWithValue("?UserID", userID); | ||
108 | cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); | ||
109 | cmd.Parameters.AddWithValue("?HomePosition", position); | ||
110 | cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); | ||
111 | |||
112 | if (ExecuteNonQuery(cmd) == 0) | ||
113 | return false; | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | public void Prune(string userID) | ||
119 | { | ||
120 | MySqlCommand cmd = new MySqlCommand(); | ||
121 | |||
122 | cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); | ||
123 | |||
124 | cmd.Parameters.AddWithValue("?UserID", userID); | ||
125 | |||
126 | IDataReader reader = ExecuteReader(cmd); | ||
127 | |||
128 | List<UUID> deleteSessions = new List<UUID>(); | ||
129 | int online = 0; | ||
130 | |||
131 | while(reader.Read()) | ||
132 | { | ||
133 | if (bool.Parse(reader["Online"].ToString())) | ||
134 | online++; | ||
135 | else | ||
136 | deleteSessions.Add(new UUID(reader["SessionID"].ToString())); | ||
137 | } | ||
138 | |||
139 | if (online == 0 && deleteSessions.Count > 0) | ||
140 | deleteSessions.RemoveAt(0); | ||
141 | |||
142 | reader.Close(); | ||
143 | CloseReaderCommand(cmd); | ||
144 | |||
145 | foreach (UUID s in deleteSessions) | ||
146 | Delete("SessionID", s.ToString()); | ||
147 | } | ||
96 | } | 148 | } |
97 | } | 149 | } |