diff options
Diffstat (limited to 'OpenSim/Services/PresenceService/PresenceService.cs')
-rw-r--r-- | OpenSim/Services/PresenceService/PresenceService.cs | 100 |
1 files changed, 93 insertions, 7 deletions
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 2157462..56ec504 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs | |||
@@ -50,18 +50,104 @@ namespace OpenSim.Services.PresenceService | |||
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | public bool Report(PresenceInfo presence) | 53 | public bool LoginAgent(UUID principalID, UUID sessionID, |
54 | UUID secureSessionID) | ||
54 | { | 55 | { |
55 | PresenceData p = new PresenceData(); | 56 | // We have just logged in. If there is any info in the table |
56 | p.Data = new Dictionary<string, string>(); | 57 | // it's OK to overwrite. So we won't bother reading it first |
58 | // | ||
59 | PresenceData data = new PresenceData(); | ||
57 | 60 | ||
58 | p.UUID = presence.PrincipalID; | 61 | data.PrincipalID = principalID; |
59 | p.currentRegion = presence.RegionID; | 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); | ||
60 | 68 | ||
61 | foreach (KeyValuePair<string, string> kvp in presence.Data) | 69 | return true; |
62 | p.Data[kvp.Key] = kvp.Value; | 70 | } |
71 | |||
72 | public bool LogoutAgent(UUID sessionID) | ||
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); | ||
63 | 82 | ||
64 | return false; | 83 | return false; |
65 | } | 84 | } |
85 | |||
86 | public bool LogoutRegionAgents(UUID regionID) | ||
87 | { | ||
88 | m_Database.LogoutRegionAgents(regionID); | ||
89 | |||
90 | return true; | ||
91 | } | ||
92 | |||
93 | |||
94 | public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) | ||
95 | { | ||
96 | return m_Database.ReportAgent(sessionID, regionID, | ||
97 | position.ToString(), lookAt.ToString()); | ||
98 | } | ||
99 | |||
100 | public PresenceInfo GetAgent(UUID sessionID) | ||
101 | { | ||
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; | ||
119 | } | ||
120 | |||
121 | public PresenceInfo[] GetAgents(UUID[] PrincipalIDs) | ||
122 | { | ||
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(); | ||
151 | } | ||
66 | } | 152 | } |
67 | } | 153 | } |