aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService/GridUserService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs95
1 files changed, 89 insertions, 6 deletions
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index c6e33bb..697ba63 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using OpenSim.Data; 32using OpenSim.Data;
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34using OpenSim.Framework;
34using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion; 36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 37
@@ -50,27 +51,109 @@ namespace OpenSim.Services.UserAccountService
50 51
51 public GridUserInfo GetGridUserInfo(string userID) 52 public GridUserInfo GetGridUserInfo(string userID)
52 { 53 {
53 GridUserData d = m_Database.GetGridUserData(userID); 54 GridUserData d = m_Database.Get(userID);
54 55
56 if (d == null)
57 return null;
58
55 GridUserInfo info = new GridUserInfo(); 59 GridUserInfo info = new GridUserInfo();
56 info.UserID = d.UserID; 60 info.UserID = d.UserID;
57 info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); 61 info.HomeRegionID = new UUID(d.Data["HomeRegionID"]);
58 info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); 62 info.HomePosition = Vector3.Parse(d.Data["HomePosition"]);
59 info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); 63 info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]);
60 64
65 info.LastRegionID = new UUID(d.Data["LastRegionID"]);
66 info.LastPosition = Vector3.Parse(d.Data["LastPosition"]);
67 info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]);
68
69 info.Online = bool.Parse(d.Data["Online"]);
70 info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"]));
71 info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"]));
72
61 return info; 73 return info;
62 } 74 }
63 75
64 public bool StoreGridUserInfo(GridUserInfo info) 76 public GridUserInfo LoggedIn(string userID)
77 {
78 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID);
79 GridUserData d = m_Database.Get(userID);
80
81 if (d == null)
82 {
83 d = new GridUserData();
84 d.UserID = userID;
85 }
86
87 d.Data["Online"] = true.ToString();
88 d.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
89
90 m_Database.Store(d);
91
92 return GetGridUserInfo(userID);
93 }
94
95 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
96 {
97 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID);
98 GridUserData d = m_Database.Get(userID);
99
100 if (d == null)
101 {
102 d = new GridUserData();
103 d.UserID = userID;
104 }
105
106 d.Data["Online"] = false.ToString();
107 d.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
108 d.Data["LastRegionID"] = regionID.ToString();
109 d.Data["LastPosition"] = lastPosition.ToString();
110 d.Data["LastLookAt"] = lastLookAt.ToString();
111
112 return m_Database.Store(d);
113 }
114
115 protected bool StoreGridUserInfo(GridUserInfo info)
65 { 116 {
66 GridUserData d = new GridUserData(); 117 GridUserData d = new GridUserData();
67 118
68 d.Data["UserID"] = info.UserID;
69 d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); 119 d.Data["HomeRegionID"] = info.HomeRegionID.ToString();
70 d.Data["HomePosition"] = info.HomePosition.ToString(); 120 d.Data["HomePosition"] = info.HomePosition.ToString();
71 d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); 121 d.Data["HomeLookAt"] = info.HomeLookAt.ToString();
72 122
73 return m_Database.StoreGridUserData(d); 123 return m_Database.Store(d);
124 }
125
126 public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
127 {
128 GridUserData d = m_Database.Get(userID);
129 if (d == null)
130 {
131 d = new GridUserData();
132 d.UserID = userID;
133 }
134
135 d.Data["HomeRegionID"] = homeID.ToString();
136 d.Data["HomePosition"] = homePosition.ToString();
137 d.Data["HomeLookAt"] = homeLookAt.ToString();
138
139 return m_Database.Store(d);
140 }
141
142 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
143 {
144 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID);
145 GridUserData d = m_Database.Get(userID);
146 if (d == null)
147 {
148 d = new GridUserData();
149 d.UserID = userID;
150 }
151
152 d.Data["LastRegionID"] = regionID.ToString();
153 d.Data["LastPosition"] = lastPosition.ToString();
154 d.Data["LastLookAt"] = lastLookAt.ToString();
155
156 return m_Database.Store(d);
74 } 157 }
75 } 158 }
76} \ No newline at end of file 159} \ No newline at end of file