aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/IPresenceData.cs8
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs78
2 files changed, 78 insertions, 8 deletions
diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
index b46b92d..1ccabcc 100644
--- a/OpenSim/Data/IPresenceData.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -37,6 +37,7 @@ namespace OpenSim.Data
37 { 37 {
38 public UUID PrincipalID; 38 public UUID PrincipalID;
39 public UUID RegionID; 39 public UUID RegionID;
40 public UUID SessionID;
40 public Dictionary<string, string> Data; 41 public Dictionary<string, string> Data;
41 } 42 }
42 43
@@ -47,8 +48,9 @@ namespace OpenSim.Data
47 { 48 {
48 bool Store(PresenceData data); 49 bool Store(PresenceData data);
49 50
50 PresenceData Get(UUID principalID); 51 PresenceData Get(UUID sessionID);
51 52 void LogoutRegionAgents(UUID regionID);
52 bool Delete(UUID regionID); 53 bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt);
54 PresenceData[] Get(string field, string data);
53 } 55 }
54} 56}
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index 9f0e4da..56ec504 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -53,33 +53,101 @@ namespace OpenSim.Services.PresenceService
53 public bool LoginAgent(UUID principalID, UUID sessionID, 53 public bool LoginAgent(UUID principalID, UUID sessionID,
54 UUID secureSessionID) 54 UUID secureSessionID)
55 { 55 {
56 return false; 56 // We have just logged in. If there is any info in the table
57 // it's OK to overwrite. So we won't bother reading it first
58 //
59 PresenceData data = new PresenceData();
60
61 data.PrincipalID = principalID;
62 data.RegionID = UUID.Zero;
63 data.SessionID = sessionID;
64 data.Data["SecureSessionID"] = secureSessionID.ToString();
65 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
66
67 m_Database.Store(data);
68
69 return true;
57 } 70 }
58 71
59 public bool LogoutAgent(UUID sessionID) 72 public bool LogoutAgent(UUID sessionID)
60 { 73 {
74 PresenceData data = m_Database.Get(sessionID);
75 if (data == null)
76 return false;
77
78 data.Data["Online"] = "false";
79 data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
80
81 m_Database.Store(data);
82
61 return false; 83 return false;
62 } 84 }
63 85
64 public bool LogoutRegionAgents(UUID regionID) 86 public bool LogoutRegionAgents(UUID regionID)
65 { 87 {
66 return false; 88 m_Database.LogoutRegionAgents(regionID);
89
90 return true;
67 } 91 }
68 92
69 93
70 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 94 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
71 { 95 {
72 return false; 96 return m_Database.ReportAgent(sessionID, regionID,
97 position.ToString(), lookAt.ToString());
73 } 98 }
74 99
75 public PresenceInfo GetAgent(UUID sessionID) 100 public PresenceInfo GetAgent(UUID sessionID)
76 { 101 {
77 return null; 102 PresenceInfo ret = new PresenceInfo();
103
104 PresenceData data = m_Database.Get(sessionID);
105 if (data == null)
106 return null;
107
108 ret.PrincipalID = data.PrincipalID;
109 ret.RegionID = data.RegionID;
110 ret.SessionID = data.SessionID;
111 ret.SecureSessionID = new UUID(data.Data["SecureSessionID"]);
112 ret.Online = bool.Parse(data.Data["Online"]);
113 ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"]));
114 ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"]));
115 ret.Position = Vector3.Parse(data.Data["Position"]);
116 ret.LookAt = Vector3.Parse(data.Data["LookAt"]);
117
118 return ret;
78 } 119 }
79 120
80 public PresenceInfo[] GetAgents(UUID[] PrincipalIDs) 121 public PresenceInfo[] GetAgents(UUID[] PrincipalIDs)
81 { 122 {
82 return null; 123 List<PresenceInfo> info = new List<PresenceInfo>();
124
125 foreach (UUID principalID in PrincipalIDs)
126 {
127 PresenceData[] data = m_Database.Get("PrincipalID",
128 principalID.ToString());
129
130 foreach (PresenceData d in data)
131 {
132 PresenceInfo ret = new PresenceInfo();
133
134 ret.PrincipalID = d.PrincipalID;
135 ret.RegionID = d.RegionID;
136 ret.SessionID = d.SessionID;
137 ret.SecureSessionID = new UUID(d.Data["SecureSessionID"]);
138 ret.Online = bool.Parse(d.Data["Online"]);
139 ret.Login = Util.ToDateTime(Convert.ToInt32(
140 d.Data["Login"]));
141 ret.Logout = Util.ToDateTime(Convert.ToInt32(
142 d.Data["Logout"]));
143 ret.Position = Vector3.Parse(d.Data["Position"]);
144 ret.LookAt = Vector3.Parse(d.Data["LookAt"]);
145
146 info.Add(ret);
147 }
148 }
149
150 return info.ToArray();
83 } 151 }
84 } 152 }
85} 153}