diff options
author | lbsa71 | 2007-12-15 12:19:29 +0000 |
---|---|---|
committer | lbsa71 | 2007-12-15 12:19:29 +0000 |
commit | 653a41fa03765727e3b48d4862547ea02ac4f9ee (patch) | |
tree | 50e235e7b67ece210e6f3e52151b14680a6779c7 /OpenSim/Region/ClientStack | |
parent | * Added an Avatar control tweak that disables the PID controller in certain c... (diff) | |
download | opensim-SC-653a41fa03765727e3b48d4862547ea02ac4f9ee.zip opensim-SC-653a41fa03765727e3b48d4862547ea02ac4f9ee.tar.gz opensim-SC-653a41fa03765727e3b48d4862547ea02ac4f9ee.tar.bz2 opensim-SC-653a41fa03765727e3b48d4862547ea02ac4f9ee.tar.xz |
* some work on not storing the circuitPack (bad thing if we're going to reuse packets)
* some work on encapsulation, code convention compliance and beautification.
* also, some ignores
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 240 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/PacketQueue.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/PacketServer.cs | 7 |
3 files changed, 124 insertions, 127 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 1746db8..dffcd73 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs | |||
@@ -54,54 +54,53 @@ namespace OpenSim.Region.ClientStack | |||
54 | public static TerrainManager TerrainManager; | 54 | public static TerrainManager TerrainManager; |
55 | 55 | ||
56 | /* private variables */ | 56 | /* private variables */ |
57 | private LLUUID m_sessionId; | 57 | private readonly LLUUID m_sessionId; |
58 | private LLUUID m_secureSessionId = LLUUID.Zero; | 58 | private LLUUID m_secureSessionId = LLUUID.Zero; |
59 | private UseCircuitCodePacket cirpack; | ||
60 | //private AgentAssetUpload UploadAssets; | 59 | //private AgentAssetUpload UploadAssets; |
61 | private LLUUID newAssetFolder = LLUUID.Zero; | 60 | private int m_debug = 0; |
62 | private int debug = 0; | 61 | private readonly AssetCache m_assetCache; |
63 | private AssetCache m_assetCache; | ||
64 | // private InventoryCache m_inventoryCache; | 62 | // private InventoryCache m_inventoryCache; |
65 | private int cachedtextureserial = 0; | 63 | private int m_cachedTextureSerial = 0; |
66 | private Timer clientPingTimer; | 64 | private Timer m_clientPingTimer; |
67 | private int packetsReceived = 0; | 65 | private int m_packetsReceived = 0; |
68 | private int probesWithNoIngressPackets = 0; | 66 | private int m_probesWithNoIngressPackets = 0; |
69 | private int lastPacketsReceived = 0; | 67 | private int m_lastPacketsReceived = 0; |
70 | 68 | ||
71 | private Encoding enc = Encoding.ASCII; | 69 | private readonly Encoding m_encoding = Encoding.ASCII; |
72 | private LLUUID m_agentId; | 70 | private readonly LLUUID m_agentId; |
73 | private uint m_circuitCode; | 71 | private readonly uint m_circuitCode; |
74 | private int m_moneyBalance; | 72 | private int m_moneyBalance; |
75 | 73 | ||
76 | private byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL | 74 | private readonly byte[] m_channelVersion=new byte[] { 0x00} ; // Dummy value needed by libSL |
77 | 75 | ||
78 | /* protected variables */ | 76 | /* protected variables */ |
79 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = | 77 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = |
80 | new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients | 78 | new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients |
79 | |||
81 | protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); | 80 | protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); |
82 | 81 | ||
83 | protected IScene m_scene; | 82 | protected IScene m_scene; |
84 | protected AgentCircuitManager m_authenticateSessionsHandler; | 83 | protected AgentCircuitManager m_authenticateSessionsHandler; |
85 | 84 | ||
86 | protected PacketQueue PacketQueue; | 85 | protected PacketQueue m_packetQueue; |
87 | 86 | ||
88 | protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | 87 | protected Dictionary<uint, uint> m_pendingAcks = new Dictionary<uint, uint>(); |
89 | protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | 88 | protected Dictionary<uint, Packet> m_needAck = new Dictionary<uint, Packet>(); |
90 | 89 | ||
91 | protected Timer AckTimer; | 90 | protected Timer m_ackTimer; |
92 | protected uint Sequence = 0; | 91 | protected uint m_sequence = 0; |
93 | protected object SequenceLock = new object(); | 92 | protected object m_sequenceLock = new object(); |
94 | protected const int MAX_APPENDED_ACKS = 10; | 93 | protected const int MAX_APPENDED_ACKS = 10; |
95 | protected const int RESEND_TIMEOUT = 4000; | 94 | protected const int RESEND_TIMEOUT = 4000; |
96 | protected const int MAX_SEQUENCE = 0xFFFFFF; | 95 | protected const int MAX_SEQUENCE = 0xFFFFFF; |
97 | protected PacketServer m_networkServer; | 96 | protected PacketServer m_networkServer; |
98 | 97 | ||
99 | /* public variables */ | 98 | /* public variables */ |
100 | public string firstName; | 99 | protected string m_firstName; |
101 | public string lastName; | 100 | protected string m_lastName; |
102 | public Thread ClientThread; | 101 | protected Thread m_clientThread; |
103 | public LLVector3 startpos; | 102 | protected LLVector3 m_startpos; |
104 | public EndPoint userEP; | 103 | protected EndPoint m_userEndPoint; |
105 | 104 | ||
106 | 105 | ||
107 | /* Properties */ | 106 | /* Properties */ |
@@ -122,8 +121,8 @@ namespace OpenSim.Region.ClientStack | |||
122 | 121 | ||
123 | public LLVector3 StartPos | 122 | public LLVector3 StartPos |
124 | { | 123 | { |
125 | get { return startpos; } | 124 | get { return m_startpos; } |
126 | set { startpos = value; } | 125 | set { m_startpos = value; } |
127 | } | 126 | } |
128 | 127 | ||
129 | public LLUUID AgentId | 128 | public LLUUID AgentId |
@@ -136,7 +135,7 @@ namespace OpenSim.Region.ClientStack | |||
136 | /// </summary> | 135 | /// </summary> |
137 | public string FirstName | 136 | public string FirstName |
138 | { | 137 | { |
139 | get { return firstName; } | 138 | get { return m_firstName; } |
140 | } | 139 | } |
141 | 140 | ||
142 | /// <summary> | 141 | /// <summary> |
@@ -144,13 +143,12 @@ namespace OpenSim.Region.ClientStack | |||
144 | /// </summary> | 143 | /// </summary> |
145 | public string LastName | 144 | public string LastName |
146 | { | 145 | { |
147 | get { return lastName; } | 146 | get { return m_lastName; } |
148 | } | 147 | } |
149 | 148 | ||
150 | public uint CircuitCode | 149 | public uint CircuitCode |
151 | { | 150 | { |
152 | get { return m_circuitCode; } | 151 | get { return m_circuitCode; } |
153 | set { m_circuitCode = value; } | ||
154 | } | 152 | } |
155 | 153 | ||
156 | public int MoneyBalance | 154 | public int MoneyBalance |
@@ -160,10 +158,7 @@ namespace OpenSim.Region.ClientStack | |||
160 | 158 | ||
161 | /* METHODS */ | 159 | /* METHODS */ |
162 | 160 | ||
163 | /* TODO: pull out clientManager param */ | 161 | public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) |
164 | public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, | ||
165 | IScene scene, AssetCache assetCache, PacketServer packServer, | ||
166 | AgentCircuitManager authenSessions) | ||
167 | { | 162 | { |
168 | m_moneyBalance = 1000; | 163 | m_moneyBalance = 1000; |
169 | 164 | ||
@@ -175,29 +170,33 @@ namespace OpenSim.Region.ClientStack | |||
175 | m_authenticateSessionsHandler = authenSessions; | 170 | m_authenticateSessionsHandler = authenSessions; |
176 | 171 | ||
177 | MainLog.Instance.Verbose("CLIENT", "Started up new client thread to handle incoming request"); | 172 | MainLog.Instance.Verbose("CLIENT", "Started up new client thread to handle incoming request"); |
178 | cirpack = initialcirpack; | ||
179 | userEP = remoteEP; | ||
180 | 173 | ||
181 | startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); | 174 | m_agentId = agentId; |
175 | m_sessionId = sessionId; | ||
176 | m_circuitCode = circuitCode; | ||
177 | |||
178 | m_userEndPoint = remoteEP; | ||
179 | |||
180 | m_startpos = m_authenticateSessionsHandler.GetPosition(circuitCode); | ||
182 | 181 | ||
183 | // While working on this, the BlockingQueue had me fooled for a bit. | 182 | // While working on this, the BlockingQueue had me fooled for a bit. |
184 | // The Blocking queue causes the thread to stop until there's something | 183 | // The Blocking queue causes the thread to stop until there's something |
185 | // in it to process. it's an on-purpose threadlock though because | 184 | // in it to process. it's an on-purpose threadlock though because |
186 | // without it, the clientloop will suck up all sim resources. | 185 | // without it, the clientloop will suck up all sim resources. |
187 | 186 | ||
188 | PacketQueue = new PacketQueue(); | 187 | m_packetQueue = new PacketQueue(); |
189 | 188 | ||
190 | RegisterLocalPacketHandlers(); | 189 | RegisterLocalPacketHandlers(); |
191 | 190 | ||
192 | ClientThread = new Thread(new ThreadStart(AuthUser)); | 191 | m_clientThread = new Thread(new ThreadStart(AuthUser)); |
193 | ClientThread.IsBackground = true; | 192 | m_clientThread.IsBackground = true; |
194 | ClientThread.Start(); | 193 | m_clientThread.Start(); |
195 | } | 194 | } |
196 | 195 | ||
197 | 196 | ||
198 | public void SetDebug(int newDebug) | 197 | public void SetDebug(int newDebug) |
199 | { | 198 | { |
200 | debug = newDebug; | 199 | m_debug = newDebug; |
201 | } | 200 | } |
202 | 201 | ||
203 | # region Client Methods | 202 | # region Client Methods |
@@ -214,20 +213,20 @@ namespace OpenSim.Region.ClientStack | |||
214 | OutPacket(disable, ThrottleOutPacketType.Task); | 213 | OutPacket(disable, ThrottleOutPacketType.Task); |
215 | 214 | ||
216 | // FLUSH Packets | 215 | // FLUSH Packets |
217 | PacketQueue.Close(); | 216 | m_packetQueue.Close(); |
218 | PacketQueue.Flush(); | 217 | m_packetQueue.Flush(); |
219 | 218 | ||
220 | Thread.Sleep(2000); | 219 | Thread.Sleep(2000); |
221 | 220 | ||
222 | // Shut down timers | 221 | // Shut down timers |
223 | AckTimer.Stop(); | 222 | m_ackTimer.Stop(); |
224 | clientPingTimer.Stop(); | 223 | m_clientPingTimer.Stop(); |
225 | 224 | ||
226 | // This is just to give the client a reasonable chance of | 225 | // This is just to give the client a reasonable chance of |
227 | // flushing out all it's packets. There should probably | 226 | // flushing out all it's packets. There should probably |
228 | // be a better mechanism here | 227 | // be a better mechanism here |
229 | 228 | ||
230 | ClientThread.Abort(); | 229 | m_clientThread.Abort(); |
231 | } | 230 | } |
232 | 231 | ||
233 | public void Kick(string message) | 232 | public void Kick(string message) |
@@ -307,22 +306,22 @@ namespace OpenSim.Region.ClientStack | |||
307 | 306 | ||
308 | protected void DebugPacket(string direction, Packet packet) | 307 | protected void DebugPacket(string direction, Packet packet) |
309 | { | 308 | { |
310 | if (debug > 0) | 309 | if (m_debug > 0) |
311 | { | 310 | { |
312 | string info = ""; | 311 | string info = ""; |
313 | if (debug < 255 && packet.Type == PacketType.AgentUpdate) | 312 | if (m_debug < 255 && packet.Type == PacketType.AgentUpdate) |
314 | return; | 313 | return; |
315 | if (debug < 254 && packet.Type == PacketType.ViewerEffect) | 314 | if (m_debug < 254 && packet.Type == PacketType.ViewerEffect) |
316 | return; | 315 | return; |
317 | if (debug < 253 && ( | 316 | if (m_debug < 253 && ( |
318 | packet.Type == PacketType.CompletePingCheck || | 317 | packet.Type == PacketType.CompletePingCheck || |
319 | packet.Type == PacketType.StartPingCheck | 318 | packet.Type == PacketType.StartPingCheck |
320 | )) | 319 | )) |
321 | return; | 320 | return; |
322 | if (debug < 252 && packet.Type == PacketType.PacketAck) | 321 | if (m_debug < 252 && packet.Type == PacketType.PacketAck) |
323 | return; | 322 | return; |
324 | 323 | ||
325 | if (debug > 1) | 324 | if (m_debug > 1) |
326 | { | 325 | { |
327 | info = packet.ToString(); | 326 | info = packet.ToString(); |
328 | } | 327 | } |
@@ -339,13 +338,13 @@ namespace OpenSim.Region.ClientStack | |||
339 | MainLog.Instance.Verbose("CLIENT", "Entered loop"); | 338 | MainLog.Instance.Verbose("CLIENT", "Entered loop"); |
340 | while (true) | 339 | while (true) |
341 | { | 340 | { |
342 | QueItem nextPacket = PacketQueue.Dequeue(); | 341 | QueItem nextPacket = m_packetQueue.Dequeue(); |
343 | if (nextPacket.Incoming) | 342 | if (nextPacket.Incoming) |
344 | { | 343 | { |
345 | //is a incoming packet | 344 | //is a incoming packet |
346 | if (nextPacket.Packet.Type != PacketType.AgentUpdate) | 345 | if (nextPacket.Packet.Type != PacketType.AgentUpdate) |
347 | { | 346 | { |
348 | packetsReceived++; | 347 | m_packetsReceived++; |
349 | } | 348 | } |
350 | DebugPacket("IN", nextPacket.Packet); | 349 | DebugPacket("IN", nextPacket.Packet); |
351 | ProcessInPacket(nextPacket.Packet); | 350 | ProcessInPacket(nextPacket.Packet); |
@@ -362,10 +361,10 @@ namespace OpenSim.Region.ClientStack | |||
362 | 361 | ||
363 | protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) | 362 | protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) |
364 | { | 363 | { |
365 | if (packetsReceived == lastPacketsReceived) | 364 | if (m_packetsReceived == m_lastPacketsReceived) |
366 | { | 365 | { |
367 | probesWithNoIngressPackets++; | 366 | m_probesWithNoIngressPackets++; |
368 | if (probesWithNoIngressPackets > 30) | 367 | if (m_probesWithNoIngressPackets > 30) |
369 | { | 368 | { |
370 | if (OnConnectionClosed != null) | 369 | if (OnConnectionClosed != null) |
371 | { | 370 | { |
@@ -381,8 +380,8 @@ namespace OpenSim.Region.ClientStack | |||
381 | else | 380 | else |
382 | { | 381 | { |
383 | // Something received in the meantime - we can reset the counters | 382 | // Something received in the meantime - we can reset the counters |
384 | probesWithNoIngressPackets = 0; | 383 | m_probesWithNoIngressPackets = 0; |
385 | lastPacketsReceived = packetsReceived; | 384 | m_lastPacketsReceived = m_packetsReceived; |
386 | } | 385 | } |
387 | } | 386 | } |
388 | 387 | ||
@@ -393,13 +392,13 @@ namespace OpenSim.Region.ClientStack | |||
393 | //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); | 392 | //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); |
394 | 393 | ||
395 | // Establish our two timers. We could probably get this down to one | 394 | // Establish our two timers. We could probably get this down to one |
396 | AckTimer = new Timer(750); | 395 | m_ackTimer = new Timer(750); |
397 | AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); | 396 | m_ackTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); |
398 | AckTimer.Start(); | 397 | m_ackTimer.Start(); |
399 | 398 | ||
400 | clientPingTimer = new Timer(5000); | 399 | m_clientPingTimer = new Timer(5000); |
401 | clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); | 400 | m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); |
402 | clientPingTimer.Enabled = true; | 401 | m_clientPingTimer.Enabled = true; |
403 | 402 | ||
404 | MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene"); | 403 | MainLog.Instance.Verbose("CLIENT", "Adding viewer agent to scene"); |
405 | m_scene.AddNewClient(this, true); | 404 | m_scene.AddNewClient(this, true); |
@@ -407,26 +406,23 @@ namespace OpenSim.Region.ClientStack | |||
407 | 406 | ||
408 | protected virtual void AuthUser() | 407 | protected virtual void AuthUser() |
409 | { | 408 | { |
410 | // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.m_circuitCode.m_sessionId, cirpack.m_circuitCode.ID, cirpack.m_circuitCode.Code); | 409 | // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(m_cirpack.m_circuitCode.m_sessionId, m_cirpack.m_circuitCode.ID, m_cirpack.m_circuitCode.Code); |
411 | AuthenticateResponse sessionInfo = | 410 | AuthenticateResponse sessionInfo = |
412 | m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, | 411 | m_authenticateSessionsHandler.AuthenticateSession(m_sessionId, m_agentId, |
413 | cirpack.CircuitCode.Code); | 412 | m_circuitCode); |
414 | if (!sessionInfo.Authorised) | 413 | if (!sessionInfo.Authorised) |
415 | { | 414 | { |
416 | //session/circuit not authorised | 415 | //session/circuit not authorised |
417 | MainLog.Instance.Notice("CLIENT", "New user request denied to " + userEP.ToString()); | 416 | MainLog.Instance.Notice("CLIENT", "New user request denied to " + m_userEndPoint.ToString()); |
418 | PacketQueue.Close(); | 417 | m_packetQueue.Close(); |
419 | ClientThread.Abort(); | 418 | m_clientThread.Abort(); |
420 | } | 419 | } |
421 | else | 420 | else |
422 | { | 421 | { |
423 | MainLog.Instance.Notice("CLIENT", "Got authenticated connection from " + userEP.ToString()); | 422 | MainLog.Instance.Notice("CLIENT", "Got authenticated connection from " + m_userEndPoint.ToString()); |
424 | //session is authorised | 423 | //session is authorised |
425 | m_agentId = cirpack.CircuitCode.ID; | 424 | m_firstName = sessionInfo.LoginInfo.First; |
426 | m_sessionId = cirpack.CircuitCode.SessionID; | 425 | m_lastName = sessionInfo.LoginInfo.Last; |
427 | m_circuitCode = cirpack.CircuitCode.Code; | ||
428 | firstName = sessionInfo.LoginInfo.First; | ||
429 | lastName = sessionInfo.LoginInfo.Last; | ||
430 | 426 | ||
431 | if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) | 427 | if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) |
432 | { | 428 | { |
@@ -582,7 +578,7 @@ namespace OpenSim.Region.ClientStack | |||
582 | 578 | ||
583 | if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) | 579 | if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) |
584 | { | 580 | { |
585 | mov.Data.Position = startpos; | 581 | mov.Data.Position = m_startpos; |
586 | } | 582 | } |
587 | else | 583 | else |
588 | { | 584 | { |
@@ -743,8 +739,8 @@ namespace OpenSim.Region.ClientStack | |||
743 | agentData.SecureSessionID = SecureSessionId; | 739 | agentData.SecureSessionID = SecureSessionId; |
744 | agentData.circuitcode = m_circuitCode; | 740 | agentData.circuitcode = m_circuitCode; |
745 | agentData.child = false; | 741 | agentData.child = false; |
746 | agentData.firstname = firstName; | 742 | agentData.firstname = m_firstName; |
747 | agentData.lastname = lastName; | 743 | agentData.lastname = m_lastName; |
748 | agentData.CapsPath = ""; | 744 | agentData.CapsPath = ""; |
749 | return agentData; | 745 | return agentData; |
750 | } | 746 | } |
@@ -1915,8 +1911,8 @@ namespace OpenSim.Region.ClientStack | |||
1915 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); | 1911 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); |
1916 | cachedresp.AgentData.AgentID = AgentId; | 1912 | cachedresp.AgentData.AgentID = AgentId; |
1917 | cachedresp.AgentData.SessionID = m_sessionId; | 1913 | cachedresp.AgentData.SessionID = m_sessionId; |
1918 | cachedresp.AgentData.SerialNum = cachedtextureserial; | 1914 | cachedresp.AgentData.SerialNum = m_cachedTextureSerial; |
1919 | cachedtextureserial++; | 1915 | m_cachedTextureSerial++; |
1920 | cachedresp.WearableData = | 1916 | cachedresp.WearableData = |
1921 | new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; | 1917 | new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; |
1922 | for (int i = 0; i < chechedtex.WearableData.Length; i++) | 1918 | for (int i = 0; i < chechedtex.WearableData.Length; i++) |
@@ -2102,39 +2098,39 @@ namespace OpenSim.Region.ClientStack | |||
2102 | } | 2098 | } |
2103 | public void SetChildAgentThrottle(byte[] throttles) | 2099 | public void SetChildAgentThrottle(byte[] throttles) |
2104 | { | 2100 | { |
2105 | PacketQueue.SetThrottleFromClient(throttles); | 2101 | m_packetQueue.SetThrottleFromClient(throttles); |
2106 | } | 2102 | } |
2107 | // Previously ClientView.PacketQueue | 2103 | // Previously ClientView.m_packetQueue |
2108 | 2104 | ||
2109 | // A thread safe sequence number allocator. | 2105 | // A thread safe sequence number allocator. |
2110 | protected uint NextSeqNum() | 2106 | protected uint NextSeqNum() |
2111 | { | 2107 | { |
2112 | // Set the sequence number | 2108 | // Set the sequence number |
2113 | uint seq = 1; | 2109 | uint seq = 1; |
2114 | lock (SequenceLock) | 2110 | lock (m_sequenceLock) |
2115 | { | 2111 | { |
2116 | if (Sequence >= MAX_SEQUENCE) | 2112 | if (m_sequence >= MAX_SEQUENCE) |
2117 | { | 2113 | { |
2118 | Sequence = 1; | 2114 | m_sequence = 1; |
2119 | } | 2115 | } |
2120 | else | 2116 | else |
2121 | { | 2117 | { |
2122 | Sequence++; | 2118 | m_sequence++; |
2123 | } | 2119 | } |
2124 | seq = Sequence; | 2120 | seq = m_sequence; |
2125 | } | 2121 | } |
2126 | return seq; | 2122 | return seq; |
2127 | } | 2123 | } |
2128 | 2124 | ||
2129 | protected void AddAck(Packet Pack) | 2125 | protected void AddAck(Packet Pack) |
2130 | { | 2126 | { |
2131 | lock (NeedAck) | 2127 | lock (m_needAck) |
2132 | { | 2128 | { |
2133 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | 2129 | if (!m_needAck.ContainsKey(Pack.Header.Sequence)) |
2134 | { | 2130 | { |
2135 | try | 2131 | try |
2136 | { | 2132 | { |
2137 | NeedAck.Add(Pack.Header.Sequence, Pack); | 2133 | m_needAck.Add(Pack.Header.Sequence, Pack); |
2138 | } | 2134 | } |
2139 | catch (Exception) // HACKY | 2135 | catch (Exception) // HACKY |
2140 | { | 2136 | { |
@@ -2147,7 +2143,7 @@ namespace OpenSim.Region.ClientStack | |||
2147 | else | 2143 | else |
2148 | { | 2144 | { |
2149 | // Client.Log("Attempted to add a duplicate sequence number (" + | 2145 | // Client.Log("Attempted to add a duplicate sequence number (" + |
2150 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | 2146 | // packet.Header.m_sequence + ") to the m_needAck dictionary for packet type " + |
2151 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | 2147 | // packet.Type.ToString(), Helpers.LogLevel.Warning); |
2152 | } | 2148 | } |
2153 | } | 2149 | } |
@@ -2156,21 +2152,21 @@ namespace OpenSim.Region.ClientStack | |||
2156 | protected virtual void SetPendingAcks(ref Packet Pack) | 2152 | protected virtual void SetPendingAcks(ref Packet Pack) |
2157 | { | 2153 | { |
2158 | // Append any ACKs that need to be sent out to this packet | 2154 | // Append any ACKs that need to be sent out to this packet |
2159 | lock (PendingAcks) | 2155 | lock (m_pendingAcks) |
2160 | { | 2156 | { |
2161 | // TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these | 2157 | // TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these |
2162 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS) | 2158 | if (m_pendingAcks.Count > 0 && m_pendingAcks.Count < MAX_APPENDED_ACKS) |
2163 | { | 2159 | { |
2164 | Pack.Header.AckList = new uint[PendingAcks.Count]; | 2160 | Pack.Header.AckList = new uint[m_pendingAcks.Count]; |
2165 | int i = 0; | 2161 | int i = 0; |
2166 | 2162 | ||
2167 | foreach (uint ack in PendingAcks.Values) | 2163 | foreach (uint ack in m_pendingAcks.Values) |
2168 | { | 2164 | { |
2169 | Pack.Header.AckList[i] = ack; | 2165 | Pack.Header.AckList[i] = ack; |
2170 | i++; | 2166 | i++; |
2171 | } | 2167 | } |
2172 | 2168 | ||
2173 | PendingAcks.Clear(); | 2169 | m_pendingAcks.Clear(); |
2174 | Pack.Header.AppendedAcks = true; | 2170 | Pack.Header.AppendedAcks = true; |
2175 | } | 2171 | } |
2176 | } | 2172 | } |
@@ -2214,8 +2210,8 @@ namespace OpenSim.Region.ClientStack | |||
2214 | catch (Exception e) | 2210 | catch (Exception e) |
2215 | { | 2211 | { |
2216 | MainLog.Instance.Warn("client", | 2212 | MainLog.Instance.Warn("client", |
2217 | "ClientView.PacketQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + | 2213 | "ClientView.m_packetQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + |
2218 | userEP.ToString() + " - killing thread"); | 2214 | m_userEndPoint.ToString() + " - killing thread"); |
2219 | MainLog.Instance.Error(e.ToString()); | 2215 | MainLog.Instance.Error(e.ToString()); |
2220 | Close(); | 2216 | Close(); |
2221 | } | 2217 | } |
@@ -2226,11 +2222,11 @@ namespace OpenSim.Region.ClientStack | |||
2226 | // Handle appended ACKs | 2222 | // Handle appended ACKs |
2227 | if (NewPack.Header.AppendedAcks) | 2223 | if (NewPack.Header.AppendedAcks) |
2228 | { | 2224 | { |
2229 | lock (NeedAck) | 2225 | lock (m_needAck) |
2230 | { | 2226 | { |
2231 | foreach (uint ack in NewPack.Header.AckList) | 2227 | foreach (uint ack in NewPack.Header.AckList) |
2232 | { | 2228 | { |
2233 | NeedAck.Remove(ack); | 2229 | m_needAck.Remove(ack); |
2234 | } | 2230 | } |
2235 | } | 2231 | } |
2236 | } | 2232 | } |
@@ -2240,11 +2236,11 @@ namespace OpenSim.Region.ClientStack | |||
2240 | { | 2236 | { |
2241 | PacketAckPacket ackPacket = (PacketAckPacket) NewPack; | 2237 | PacketAckPacket ackPacket = (PacketAckPacket) NewPack; |
2242 | 2238 | ||
2243 | lock (NeedAck) | 2239 | lock (m_needAck) |
2244 | { | 2240 | { |
2245 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | 2241 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) |
2246 | { | 2242 | { |
2247 | NeedAck.Remove(block.ID); | 2243 | m_needAck.Remove(block.ID); |
2248 | } | 2244 | } |
2249 | } | 2245 | } |
2250 | } | 2246 | } |
@@ -2261,7 +2257,7 @@ namespace OpenSim.Region.ClientStack | |||
2261 | QueItem item = new QueItem(); | 2257 | QueItem item = new QueItem(); |
2262 | item.Packet = NewPack; | 2258 | item.Packet = NewPack; |
2263 | item.Incoming = true; | 2259 | item.Incoming = true; |
2264 | PacketQueue.Enqueue(item); | 2260 | m_packetQueue.Enqueue(item); |
2265 | } | 2261 | } |
2266 | } | 2262 | } |
2267 | 2263 | ||
@@ -2271,7 +2267,7 @@ namespace OpenSim.Region.ClientStack | |||
2271 | item.Packet = NewPack; | 2267 | item.Packet = NewPack; |
2272 | item.Incoming = false; | 2268 | item.Incoming = false; |
2273 | item.throttleType = throttlePacketType; // Packet throttle type | 2269 | item.throttleType = throttlePacketType; // Packet throttle type |
2274 | PacketQueue.Enqueue(item); | 2270 | m_packetQueue.Enqueue(item); |
2275 | } | 2271 | } |
2276 | 2272 | ||
2277 | # region Low Level Packet Methods | 2273 | # region Low Level Packet Methods |
@@ -2291,10 +2287,10 @@ namespace OpenSim.Region.ClientStack | |||
2291 | /* | 2287 | /* |
2292 | if (Pack.Header.Reliable) | 2288 | if (Pack.Header.Reliable) |
2293 | { | 2289 | { |
2294 | lock (PendingAcks) | 2290 | lock (m_pendingAcks) |
2295 | { | 2291 | { |
2296 | uint sequence = (uint)Pack.Header.Sequence; | 2292 | uint sequence = (uint)Pack.Header.m_sequence; |
2297 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | 2293 | if (!m_pendingAcks.ContainsKey(sequence)) { m_pendingAcks[sequence] = sequence; } |
2298 | } | 2294 | } |
2299 | }*/ | 2295 | }*/ |
2300 | } | 2296 | } |
@@ -2303,9 +2299,9 @@ namespace OpenSim.Region.ClientStack | |||
2303 | { | 2299 | { |
2304 | int now = System.Environment.TickCount; | 2300 | int now = System.Environment.TickCount; |
2305 | 2301 | ||
2306 | lock (NeedAck) | 2302 | lock (m_needAck) |
2307 | { | 2303 | { |
2308 | foreach (Packet packet in NeedAck.Values) | 2304 | foreach (Packet packet in m_needAck.Values) |
2309 | { | 2305 | { |
2310 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) | 2306 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) |
2311 | { | 2307 | { |
@@ -2321,11 +2317,11 @@ namespace OpenSim.Region.ClientStack | |||
2321 | 2317 | ||
2322 | protected void SendAcks() | 2318 | protected void SendAcks() |
2323 | { | 2319 | { |
2324 | lock (PendingAcks) | 2320 | lock (m_pendingAcks) |
2325 | { | 2321 | { |
2326 | if (PendingAcks.Count > 0) | 2322 | if (m_pendingAcks.Count > 0) |
2327 | { | 2323 | { |
2328 | if (PendingAcks.Count > 250) | 2324 | if (m_pendingAcks.Count > 250) |
2329 | { | 2325 | { |
2330 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | 2326 | // FIXME: Handle the odd case where we have too many pending ACKs queued up |
2331 | MainLog.Instance.Verbose("NETWORK", "Too many ACKs queued up!"); | 2327 | MainLog.Instance.Verbose("NETWORK", "Too many ACKs queued up!"); |
@@ -2336,9 +2332,9 @@ namespace OpenSim.Region.ClientStack | |||
2336 | 2332 | ||
2337 | int i = 0; | 2333 | int i = 0; |
2338 | PacketAckPacket acks = new PacketAckPacket(); | 2334 | PacketAckPacket acks = new PacketAckPacket(); |
2339 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | 2335 | acks.Packets = new PacketAckPacket.PacketsBlock[m_pendingAcks.Count]; |
2340 | 2336 | ||
2341 | foreach (uint ack in PendingAcks.Values) | 2337 | foreach (uint ack in m_pendingAcks.Values) |
2342 | { | 2338 | { |
2343 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | 2339 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); |
2344 | acks.Packets[i].ID = ack; | 2340 | acks.Packets[i].ID = ack; |
@@ -2348,7 +2344,7 @@ namespace OpenSim.Region.ClientStack | |||
2348 | acks.Header.Reliable = false; | 2344 | acks.Header.Reliable = false; |
2349 | OutPacket(acks, ThrottleOutPacketType.Unknown); | 2345 | OutPacket(acks, ThrottleOutPacketType.Unknown); |
2350 | 2346 | ||
2351 | PendingAcks.Clear(); | 2347 | m_pendingAcks.Clear(); |
2352 | } | 2348 | } |
2353 | } | 2349 | } |
2354 | } | 2350 | } |
@@ -2714,7 +2710,7 @@ namespace OpenSim.Region.ClientStack | |||
2714 | if (OnObjectDescription != null) | 2710 | if (OnObjectDescription != null) |
2715 | { | 2711 | { |
2716 | OnObjectDescription(this, objDes.ObjectData[i].LocalID, | 2712 | OnObjectDescription(this, objDes.ObjectData[i].LocalID, |
2717 | enc.GetString(objDes.ObjectData[i].Description)); | 2713 | m_encoding.GetString(objDes.ObjectData[i].Description)); |
2718 | } | 2714 | } |
2719 | } | 2715 | } |
2720 | break; | 2716 | break; |
@@ -2724,7 +2720,7 @@ namespace OpenSim.Region.ClientStack | |||
2724 | { | 2720 | { |
2725 | if (OnObjectName != null) | 2721 | if (OnObjectName != null) |
2726 | { | 2722 | { |
2727 | OnObjectName(this, objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); | 2723 | OnObjectName(this, objName.ObjectData[i].LocalID, m_encoding.GetString(objName.ObjectData[i].Name)); |
2728 | } | 2724 | } |
2729 | } | 2725 | } |
2730 | break; | 2726 | break; |
@@ -3189,7 +3185,7 @@ namespace OpenSim.Region.ClientStack | |||
3189 | 3185 | ||
3190 | case PacketType.AgentThrottle: | 3186 | case PacketType.AgentThrottle: |
3191 | AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; | 3187 | AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; |
3192 | PacketQueue.SetThrottleFromClient(atpack.Throttle.Throttles); | 3188 | m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles); |
3193 | break; | 3189 | break; |
3194 | 3190 | ||
3195 | #endregion | 3191 | #endregion |
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs index b1a649c..4c9295e 100644 --- a/OpenSim/Region/ClientStack/PacketQueue.cs +++ b/OpenSim/Region/ClientStack/PacketQueue.cs | |||
@@ -177,7 +177,7 @@ namespace OpenSim.Region.ClientStack | |||
177 | lock(this) { | 177 | lock(this) { |
178 | while (PacketsWaiting()) | 178 | while (PacketsWaiting()) |
179 | { | 179 | { |
180 | //Now comes the fun part.. we dump all our elements into PacketQueue that we've saved up. | 180 | //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. |
181 | if (ResendOutgoingPacketQueue.Count > 0) | 181 | if (ResendOutgoingPacketQueue.Count > 0) |
182 | { | 182 | { |
183 | SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue()); | 183 | SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue()); |
@@ -261,7 +261,7 @@ namespace OpenSim.Region.ClientStack | |||
261 | (throttleLoops <= MaxThrottleLoops)) | 261 | (throttleLoops <= MaxThrottleLoops)) |
262 | { | 262 | { |
263 | throttleLoops++; | 263 | throttleLoops++; |
264 | //Now comes the fun part.. we dump all our elements into PacketQueue that we've saved up. | 264 | //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. |
265 | if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) | 265 | if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) |
266 | { | 266 | { |
267 | QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); | 267 | QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); |
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index 945bb82..39c3d32 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | using System.Net; | 28 | using System.Net; |
29 | using System.Net.Sockets; | 29 | using System.Net.Sockets; |
30 | using libsecondlife; | ||
30 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Communications.Cache; | 33 | using OpenSim.Framework.Communications.Cache; |
@@ -67,10 +68,10 @@ namespace OpenSim.Region.ClientStack | |||
67 | 68 | ||
68 | protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, | 69 | protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, |
69 | ClientManager clientManager, IScene scene, AssetCache assetCache, | 70 | ClientManager clientManager, IScene scene, AssetCache assetCache, |
70 | PacketServer packServer, AgentCircuitManager authenSessions) | 71 | PacketServer packServer, AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) |
71 | { | 72 | { |
72 | return | 73 | return |
73 | new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions); | 74 | new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode ); |
74 | } | 75 | } |
75 | 76 | ||
76 | public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, | 77 | public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, |
@@ -85,7 +86,7 @@ namespace OpenSim.Region.ClientStack | |||
85 | else | 86 | else |
86 | { | 87 | { |
87 | newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, | 88 | newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, |
88 | authenticateSessionsClass); | 89 | authenticateSessionsClass, useCircuit.CircuitCode.ID, useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); |
89 | 90 | ||
90 | m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); | 91 | m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); |
91 | 92 | ||