diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs index f2e76d3..871e8e8 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | |||
@@ -33,16 +33,40 @@ using OpenMetaverse; | |||
33 | 33 | ||
34 | namespace OpenSim.Region.ClientStack.LindenUDP | 34 | namespace OpenSim.Region.ClientStack.LindenUDP |
35 | { | 35 | { |
36 | #region Delegates | ||
37 | |||
38 | /// <summary> | ||
39 | /// Fired when updated networking stats are produced for this client | ||
40 | /// </summary> | ||
41 | /// <param name="inPackets">Number of incoming packets received since this | ||
42 | /// event was last fired</param> | ||
43 | /// <param name="outPackets">Number of outgoing packets sent since this | ||
44 | /// event was last fired</param> | ||
45 | /// <param name="unAckedBytes">Current total number of bytes in packets we | ||
46 | /// are waiting on ACKs for</param> | ||
36 | public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); | 47 | public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); |
48 | /// <summary> | ||
49 | /// Fired when the queue for a packet category is empty. This event can be | ||
50 | /// hooked to put more data on the empty queue | ||
51 | /// </summary> | ||
52 | /// <param name="category">Category of the packet queue that is empty</param> | ||
37 | public delegate void QueueEmpty(ThrottleOutPacketType category); | 53 | public delegate void QueueEmpty(ThrottleOutPacketType category); |
38 | 54 | ||
39 | public class LLUDPClient | 55 | #endregion Delegates |
56 | |||
57 | /// <summary> | ||
58 | /// Tracks state for a client UDP connection and provides client-specific methods | ||
59 | /// </summary> | ||
60 | public sealed class LLUDPClient | ||
40 | { | 61 | { |
41 | /// <summary>The number of packet categories to throttle on. If a throttle category is added | 62 | /// <summary>The number of packet categories to throttle on. If a throttle category is added |
42 | /// or removed, this number must also change</summary> | 63 | /// or removed, this number must also change</summary> |
43 | const int THROTTLE_CATEGORY_COUNT = 7; | 64 | const int THROTTLE_CATEGORY_COUNT = 7; |
44 | 65 | ||
66 | /// <summary>Fired when updated networking stats are produced for this client</summary> | ||
45 | public event PacketStats OnPacketStats; | 67 | public event PacketStats OnPacketStats; |
68 | /// <summary>Fired when the queue for a packet category is empty. This event can be | ||
69 | /// hooked to put more data on the empty queue</summary> | ||
46 | public event QueueEmpty OnQueueEmpty; | 70 | public event QueueEmpty OnQueueEmpty; |
47 | 71 | ||
48 | /// <summary>AgentID for this client</summary> | 72 | /// <summary>AgentID for this client</summary> |
@@ -115,6 +139,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
115 | /// <summary>A reference to the LLUDPServer that is managing this client</summary> | 139 | /// <summary>A reference to the LLUDPServer that is managing this client</summary> |
116 | private readonly LLUDPServer udpServer; | 140 | private readonly LLUDPServer udpServer; |
117 | 141 | ||
142 | /// <summary> | ||
143 | /// Default constructor | ||
144 | /// </summary> | ||
145 | /// <param name="server">Reference to the UDP server this client is connected to</param> | ||
146 | /// <param name="rates">Default throttling rates and maximum throttle limits</param> | ||
147 | /// <param name="parentThrottle">Parent HTB (hierarchical token bucket) | ||
148 | /// that the child throttles will be governed by</param> | ||
149 | /// <param name="circuitCode">Circuit code for this connection</param> | ||
150 | /// <param name="agentID">AgentID for the connected agent</param> | ||
151 | /// <param name="remoteEndPoint">Remote endpoint for this connection</param> | ||
118 | public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint) | 152 | public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint) |
119 | { | 153 | { |
120 | udpServer = server; | 154 | udpServer = server; |
@@ -144,14 +178,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
144 | RTO = 3000; | 178 | RTO = 3000; |
145 | } | 179 | } |
146 | 180 | ||
181 | /// <summary> | ||
182 | /// Shuts down this client connection | ||
183 | /// </summary> | ||
147 | public void Shutdown() | 184 | public void Shutdown() |
148 | { | 185 | { |
186 | // TODO: Do we need to invalidate the circuit? | ||
149 | IsConnected = false; | 187 | IsConnected = false; |
150 | } | 188 | } |
151 | 189 | ||
190 | /// <summary> | ||
191 | /// Gets information about this client connection | ||
192 | /// </summary> | ||
193 | /// <returns>Information about the client connection</returns> | ||
152 | public ClientInfo GetClientInfo() | 194 | public ClientInfo GetClientInfo() |
153 | { | 195 | { |
154 | // TODO: This data structure is wrong in so many ways | 196 | // TODO: This data structure is wrong in so many ways. Locking and copying the entire lists |
197 | // of pending and needed ACKs for every client every time some method wants information about | ||
198 | // this connection is a recipe for poor performance | ||
155 | ClientInfo info = new ClientInfo(); | 199 | ClientInfo info = new ClientInfo(); |
156 | info.pendingAcks = new Dictionary<uint, uint>(); | 200 | info.pendingAcks = new Dictionary<uint, uint>(); |
157 | info.needAck = new Dictionary<uint, byte[]>(); | 201 | info.needAck = new Dictionary<uint, byte[]>(); |
@@ -169,8 +213,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
169 | return info; | 213 | return info; |
170 | } | 214 | } |
171 | 215 | ||
216 | /// <summary> | ||
217 | /// Modifies the UDP throttles | ||
218 | /// </summary> | ||
219 | /// <param name="info">New throttling values</param> | ||
172 | public void SetClientInfo(ClientInfo info) | 220 | public void SetClientInfo(ClientInfo info) |
173 | { | 221 | { |
222 | // TODO: Allowing throttles to be manually set from this function seems like a reasonable | ||
223 | // idea. On the other hand, letting external code manipulate our ACK accounting is not | ||
224 | // going to happen | ||
225 | throw new NotImplementedException(); | ||
174 | } | 226 | } |
175 | 227 | ||
176 | public string GetStats() | 228 | public string GetStats() |