diff options
author | Melanie | 2009-10-08 10:32:15 +0100 |
---|---|---|
committer | Melanie | 2009-10-08 10:32:15 +0100 |
commit | f6b8bac0fab3dfc3d25775e51bb89ee10feebb53 (patch) | |
tree | de16f4c7c14fce6851a4cd9c80117d1cbdd4b38e | |
parent | Correct a build break caused by an optimization in trunk (diff) | |
parent | Remove ThreadTrackerTest. It's no longer relevant because the thread (diff) | |
download | opensim-SC_OLD-f6b8bac0fab3dfc3d25775e51bb89ee10feebb53.zip opensim-SC_OLD-f6b8bac0fab3dfc3d25775e51bb89ee10feebb53.tar.gz opensim-SC_OLD-f6b8bac0fab3dfc3d25775e51bb89ee10feebb53.tar.bz2 opensim-SC_OLD-f6b8bac0fab3dfc3d25775e51bb89ee10feebb53.tar.xz |
Merge branch 'master' into vehicles
56 files changed, 3428 insertions, 4906 deletions
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index 332ff70..4910ab1 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | |||
@@ -89,7 +89,6 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
89 | m_clientThread.Name = "MXPThread"; | 89 | m_clientThread.Name = "MXPThread"; |
90 | m_clientThread.IsBackground = true; | 90 | m_clientThread.IsBackground = true; |
91 | m_clientThread.Start(); | 91 | m_clientThread.Start(); |
92 | ThreadTracker.Add(m_clientThread); | ||
93 | } | 92 | } |
94 | 93 | ||
95 | public void StartListener() | 94 | public void StartListener() |
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 8f97440..259e186 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs | |||
@@ -239,10 +239,8 @@ namespace OpenSim.Data.MySQL | |||
239 | } | 239 | } |
240 | catch (Exception e) | 240 | catch (Exception e) |
241 | { | 241 | { |
242 | m_log.ErrorFormat( | 242 | m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Attempting reconnect. Error: {2}", |
243 | "[ASSETS DB]: " + | 243 | asset.FullID, asset.Name, e.Message); |
244 | "MySql failure creating asset {0} with name {1}" + Environment.NewLine + e.ToString() | ||
245 | + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); | ||
246 | _dbConnection.Reconnect(); | 244 | _dbConnection.Reconnect(); |
247 | } | 245 | } |
248 | } | 246 | } |
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs index 10be069..220a9b6 100644 --- a/OpenSim/Framework/Communications/Clients/RegionClient.cs +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs | |||
@@ -124,9 +124,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
124 | // Let's wait for the response | 124 | // Let's wait for the response |
125 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 125 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); |
126 | 126 | ||
127 | WebResponse webResponse = null; | ||
128 | StreamReader sr = null; | ||
127 | try | 129 | try |
128 | { | 130 | { |
129 | WebResponse webResponse = AgentCreateRequest.GetResponse(); | 131 | webResponse = AgentCreateRequest.GetResponse(); |
130 | if (webResponse == null) | 132 | if (webResponse == null) |
131 | { | 133 | { |
132 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); | 134 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); |
@@ -134,11 +136,10 @@ namespace OpenSim.Framework.Communications.Clients | |||
134 | else | 136 | else |
135 | { | 137 | { |
136 | 138 | ||
137 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 139 | sr = new StreamReader(webResponse.GetResponseStream()); |
138 | string response = sr.ReadToEnd().Trim(); | 140 | string response = sr.ReadToEnd().Trim(); |
139 | sr.Close(); | ||
140 | m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); | 141 | m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); |
141 | 142 | ||
142 | if (!String.IsNullOrEmpty(response)) | 143 | if (!String.IsNullOrEmpty(response)) |
143 | { | 144 | { |
144 | try | 145 | try |
@@ -167,6 +168,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
167 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | 168 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); |
168 | // ignore, really | 169 | // ignore, really |
169 | } | 170 | } |
171 | finally | ||
172 | { | ||
173 | if (sr != null) | ||
174 | sr.Close(); | ||
175 | } | ||
170 | 176 | ||
171 | return true; | 177 | return true; |
172 | 178 | ||
@@ -246,15 +252,17 @@ namespace OpenSim.Framework.Communications.Clients | |||
246 | // Let's wait for the response | 252 | // Let's wait for the response |
247 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); | 253 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); |
248 | 254 | ||
255 | WebResponse webResponse = null; | ||
256 | StreamReader sr = null; | ||
249 | try | 257 | try |
250 | { | 258 | { |
251 | WebResponse webResponse = ChildUpdateRequest.GetResponse(); | 259 | webResponse = ChildUpdateRequest.GetResponse(); |
252 | if (webResponse == null) | 260 | if (webResponse == null) |
253 | { | 261 | { |
254 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); | 262 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); |
255 | } | 263 | } |
256 | 264 | ||
257 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 265 | sr = new StreamReader(webResponse.GetResponseStream()); |
258 | //reply = sr.ReadToEnd().Trim(); | 266 | //reply = sr.ReadToEnd().Trim(); |
259 | sr.ReadToEnd().Trim(); | 267 | sr.ReadToEnd().Trim(); |
260 | sr.Close(); | 268 | sr.Close(); |
@@ -266,6 +274,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
266 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); | 274 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); |
267 | // ignore, really | 275 | // ignore, really |
268 | } | 276 | } |
277 | finally | ||
278 | { | ||
279 | if (sr != null) | ||
280 | sr.Close(); | ||
281 | } | ||
269 | 282 | ||
270 | return true; | 283 | return true; |
271 | } | 284 | } |
@@ -284,6 +297,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
284 | 297 | ||
285 | HttpWebResponse webResponse = null; | 298 | HttpWebResponse webResponse = null; |
286 | string reply = string.Empty; | 299 | string reply = string.Empty; |
300 | StreamReader sr = null; | ||
287 | try | 301 | try |
288 | { | 302 | { |
289 | webResponse = (HttpWebResponse)request.GetResponse(); | 303 | webResponse = (HttpWebResponse)request.GetResponse(); |
@@ -292,9 +306,8 @@ namespace OpenSim.Framework.Communications.Clients | |||
292 | m_log.Info("[REST COMMS]: Null reply on agent get "); | 306 | m_log.Info("[REST COMMS]: Null reply on agent get "); |
293 | } | 307 | } |
294 | 308 | ||
295 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 309 | sr = new StreamReader(webResponse.GetResponseStream()); |
296 | reply = sr.ReadToEnd().Trim(); | 310 | reply = sr.ReadToEnd().Trim(); |
297 | sr.Close(); | ||
298 | 311 | ||
299 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); | 312 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); |
300 | 313 | ||
@@ -305,6 +318,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
305 | // ignore, really | 318 | // ignore, really |
306 | return false; | 319 | return false; |
307 | } | 320 | } |
321 | finally | ||
322 | { | ||
323 | if (sr != null) | ||
324 | sr.Close(); | ||
325 | } | ||
308 | 326 | ||
309 | if (webResponse.StatusCode == HttpStatusCode.OK) | 327 | if (webResponse.StatusCode == HttpStatusCode.OK) |
310 | { | 328 | { |
@@ -333,6 +351,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
333 | request.Method = "DELETE"; | 351 | request.Method = "DELETE"; |
334 | request.Timeout = 10000; | 352 | request.Timeout = 10000; |
335 | 353 | ||
354 | StreamReader sr = null; | ||
336 | try | 355 | try |
337 | { | 356 | { |
338 | WebResponse webResponse = request.GetResponse(); | 357 | WebResponse webResponse = request.GetResponse(); |
@@ -341,7 +360,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
341 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | 360 | m_log.Info("[REST COMMS]: Null reply on agent delete "); |
342 | } | 361 | } |
343 | 362 | ||
344 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 363 | sr = new StreamReader(webResponse.GetResponseStream()); |
345 | //reply = sr.ReadToEnd().Trim(); | 364 | //reply = sr.ReadToEnd().Trim(); |
346 | sr.ReadToEnd().Trim(); | 365 | sr.ReadToEnd().Trim(); |
347 | sr.Close(); | 366 | sr.Close(); |
@@ -353,6 +372,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
353 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | 372 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); |
354 | // ignore, really | 373 | // ignore, really |
355 | } | 374 | } |
375 | finally | ||
376 | { | ||
377 | if (sr != null) | ||
378 | sr.Close(); | ||
379 | } | ||
356 | 380 | ||
357 | return true; | 381 | return true; |
358 | } | 382 | } |
@@ -377,6 +401,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
377 | request.Method = "DELETE"; | 401 | request.Method = "DELETE"; |
378 | request.Timeout = 10000; | 402 | request.Timeout = 10000; |
379 | 403 | ||
404 | StreamReader sr = null; | ||
380 | try | 405 | try |
381 | { | 406 | { |
382 | WebResponse webResponse = request.GetResponse(); | 407 | WebResponse webResponse = request.GetResponse(); |
@@ -385,7 +410,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
385 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | 410 | m_log.Info("[REST COMMS]: Null reply on agent delete "); |
386 | } | 411 | } |
387 | 412 | ||
388 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 413 | sr = new StreamReader(webResponse.GetResponseStream()); |
389 | //reply = sr.ReadToEnd().Trim(); | 414 | //reply = sr.ReadToEnd().Trim(); |
390 | sr.ReadToEnd().Trim(); | 415 | sr.ReadToEnd().Trim(); |
391 | sr.Close(); | 416 | sr.Close(); |
@@ -397,6 +422,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
397 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | 422 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); |
398 | // ignore, really | 423 | // ignore, really |
399 | } | 424 | } |
425 | finally | ||
426 | { | ||
427 | if (sr != null) | ||
428 | sr.Close(); | ||
429 | } | ||
400 | 430 | ||
401 | return true; | 431 | return true; |
402 | } | 432 | } |
@@ -463,6 +493,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
463 | // Let's wait for the response | 493 | // Let's wait for the response |
464 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 494 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); |
465 | 495 | ||
496 | StreamReader sr = null; | ||
466 | try | 497 | try |
467 | { | 498 | { |
468 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | 499 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); |
@@ -471,10 +502,9 @@ namespace OpenSim.Framework.Communications.Clients | |||
471 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | 502 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); |
472 | } | 503 | } |
473 | 504 | ||
474 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 505 | sr = new StreamReader(webResponse.GetResponseStream()); |
475 | //reply = sr.ReadToEnd().Trim(); | 506 | //reply = sr.ReadToEnd().Trim(); |
476 | sr.ReadToEnd().Trim(); | 507 | sr.ReadToEnd().Trim(); |
477 | sr.Close(); | ||
478 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | 508 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); |
479 | 509 | ||
480 | } | 510 | } |
@@ -483,6 +513,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
483 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | 513 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); |
484 | // ignore, really | 514 | // ignore, really |
485 | } | 515 | } |
516 | finally | ||
517 | { | ||
518 | if (sr != null) | ||
519 | sr.Close(); | ||
520 | } | ||
486 | 521 | ||
487 | return true; | 522 | return true; |
488 | 523 | ||
@@ -542,6 +577,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
542 | // Let's wait for the response | 577 | // Let's wait for the response |
543 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | 578 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); |
544 | 579 | ||
580 | StreamReader sr = null; | ||
545 | try | 581 | try |
546 | { | 582 | { |
547 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | 583 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); |
@@ -550,11 +586,10 @@ namespace OpenSim.Framework.Communications.Clients | |||
550 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | 586 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); |
551 | } | 587 | } |
552 | 588 | ||
553 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 589 | sr = new StreamReader(webResponse.GetResponseStream()); |
554 | sr.ReadToEnd().Trim(); | 590 | sr.ReadToEnd().Trim(); |
555 | sr.ReadToEnd().Trim(); | 591 | sr.ReadToEnd().Trim(); |
556 | sr.Close(); | 592 | |
557 | |||
558 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | 593 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); |
559 | 594 | ||
560 | } | 595 | } |
@@ -563,6 +598,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
563 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | 598 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); |
564 | // ignore, really | 599 | // ignore, really |
565 | } | 600 | } |
601 | finally | ||
602 | { | ||
603 | if (sr != null) | ||
604 | sr.Close(); | ||
605 | } | ||
566 | 606 | ||
567 | return true; | 607 | return true; |
568 | 608 | ||
@@ -630,6 +670,7 @@ namespace OpenSim.Framework.Communications.Clients | |||
630 | // Let's wait for the response | 670 | // Let's wait for the response |
631 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); | 671 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); |
632 | 672 | ||
673 | StreamReader sr = null; | ||
633 | try | 674 | try |
634 | { | 675 | { |
635 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); | 676 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); |
@@ -638,10 +679,9 @@ namespace OpenSim.Framework.Communications.Clients | |||
638 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); | 679 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); |
639 | } | 680 | } |
640 | 681 | ||
641 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 682 | sr = new StreamReader(webResponse.GetResponseStream()); |
642 | //reply = sr.ReadToEnd().Trim(); | 683 | //reply = sr.ReadToEnd().Trim(); |
643 | sr.ReadToEnd().Trim(); | 684 | sr.ReadToEnd().Trim(); |
644 | sr.Close(); | ||
645 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); | 685 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); |
646 | 686 | ||
647 | } | 687 | } |
@@ -650,6 +690,11 @@ namespace OpenSim.Framework.Communications.Clients | |||
650 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); | 690 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); |
651 | // ignore, really | 691 | // ignore, really |
652 | } | 692 | } |
693 | finally | ||
694 | { | ||
695 | if (sr != null) | ||
696 | sr.Close(); | ||
697 | } | ||
653 | 698 | ||
654 | return true; | 699 | return true; |
655 | 700 | ||
diff --git a/OpenSim/Framework/Parallel.cs b/OpenSim/Framework/Parallel.cs new file mode 100644 index 0000000..74537ba --- /dev/null +++ b/OpenSim/Framework/Parallel.cs | |||
@@ -0,0 +1,207 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Threading; | ||
31 | |||
32 | namespace OpenSim.Framework | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Provides helper methods for parallelizing loops | ||
36 | /// </summary> | ||
37 | public static class Parallel | ||
38 | { | ||
39 | private static readonly int processorCount = System.Environment.ProcessorCount; | ||
40 | |||
41 | /// <summary> | ||
42 | /// Executes a for loop in which iterations may run in parallel | ||
43 | /// </summary> | ||
44 | /// <param name="fromInclusive">The loop will be started at this index</param> | ||
45 | /// <param name="toExclusive">The loop will be terminated before this index is reached</param> | ||
46 | /// <param name="body">Method body to run for each iteration of the loop</param> | ||
47 | public static void For(int fromInclusive, int toExclusive, Action<int> body) | ||
48 | { | ||
49 | For(processorCount, fromInclusive, toExclusive, body); | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Executes a for loop in which iterations may run in parallel | ||
54 | /// </summary> | ||
55 | /// <param name="threadCount">The number of concurrent execution threads to run</param> | ||
56 | /// <param name="fromInclusive">The loop will be started at this index</param> | ||
57 | /// <param name="toExclusive">The loop will be terminated before this index is reached</param> | ||
58 | /// <param name="body">Method body to run for each iteration of the loop</param> | ||
59 | public static void For(int threadCount, int fromInclusive, int toExclusive, Action<int> body) | ||
60 | { | ||
61 | int counter = threadCount; | ||
62 | AutoResetEvent threadFinishEvent = new AutoResetEvent(false); | ||
63 | Exception exception = null; | ||
64 | |||
65 | --fromInclusive; | ||
66 | |||
67 | for (int i = 0; i < threadCount; i++) | ||
68 | { | ||
69 | ThreadPool.QueueUserWorkItem( | ||
70 | delegate(object o) | ||
71 | { | ||
72 | int threadIndex = (int)o; | ||
73 | |||
74 | while (exception == null) | ||
75 | { | ||
76 | int currentIndex = Interlocked.Increment(ref fromInclusive); | ||
77 | |||
78 | if (currentIndex >= toExclusive) | ||
79 | break; | ||
80 | |||
81 | try { body(currentIndex); } | ||
82 | catch (Exception ex) { exception = ex; break; } | ||
83 | } | ||
84 | |||
85 | if (Interlocked.Decrement(ref counter) == 0) | ||
86 | threadFinishEvent.Set(); | ||
87 | }, i | ||
88 | ); | ||
89 | } | ||
90 | |||
91 | threadFinishEvent.WaitOne(); | ||
92 | |||
93 | if (exception != null) | ||
94 | throw new Exception(exception.Message, exception); | ||
95 | } | ||
96 | |||
97 | /// <summary> | ||
98 | /// Executes a foreach loop in which iterations may run in parallel | ||
99 | /// </summary> | ||
100 | /// <typeparam name="T">Object type that the collection wraps</typeparam> | ||
101 | /// <param name="enumerable">An enumerable collection to iterate over</param> | ||
102 | /// <param name="body">Method body to run for each object in the collection</param> | ||
103 | public static void ForEach<T>(IEnumerable<T> enumerable, Action<T> body) | ||
104 | { | ||
105 | ForEach<T>(processorCount, enumerable, body); | ||
106 | } | ||
107 | |||
108 | /// <summary> | ||
109 | /// Executes a foreach loop in which iterations may run in parallel | ||
110 | /// </summary> | ||
111 | /// <typeparam name="T">Object type that the collection wraps</typeparam> | ||
112 | /// <param name="threadCount">The number of concurrent execution threads to run</param> | ||
113 | /// <param name="enumerable">An enumerable collection to iterate over</param> | ||
114 | /// <param name="body">Method body to run for each object in the collection</param> | ||
115 | public static void ForEach<T>(int threadCount, IEnumerable<T> enumerable, Action<T> body) | ||
116 | { | ||
117 | int counter = threadCount; | ||
118 | AutoResetEvent threadFinishEvent = new AutoResetEvent(false); | ||
119 | IEnumerator<T> enumerator = enumerable.GetEnumerator(); | ||
120 | Exception exception = null; | ||
121 | |||
122 | for (int i = 0; i < threadCount; i++) | ||
123 | { | ||
124 | ThreadPool.QueueUserWorkItem( | ||
125 | delegate(object o) | ||
126 | { | ||
127 | int threadIndex = (int)o; | ||
128 | |||
129 | while (exception == null) | ||
130 | { | ||
131 | T entry; | ||
132 | |||
133 | lock (enumerator) | ||
134 | { | ||
135 | if (!enumerator.MoveNext()) | ||
136 | break; | ||
137 | entry = (T)enumerator.Current; // Explicit typecast for Mono's sake | ||
138 | } | ||
139 | |||
140 | try { body(entry); } | ||
141 | catch (Exception ex) { exception = ex; break; } | ||
142 | } | ||
143 | |||
144 | if (Interlocked.Decrement(ref counter) == 0) | ||
145 | threadFinishEvent.Set(); | ||
146 | }, i | ||
147 | ); | ||
148 | } | ||
149 | |||
150 | threadFinishEvent.WaitOne(); | ||
151 | |||
152 | if (exception != null) | ||
153 | throw new Exception(exception.Message, exception); | ||
154 | } | ||
155 | |||
156 | /// <summary> | ||
157 | /// Executes a series of tasks in parallel | ||
158 | /// </summary> | ||
159 | /// <param name="actions">A series of method bodies to execute</param> | ||
160 | public static void Invoke(params Action[] actions) | ||
161 | { | ||
162 | Invoke(processorCount, actions); | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Executes a series of tasks in parallel | ||
167 | /// </summary> | ||
168 | /// <param name="threadCount">The number of concurrent execution threads to run</param> | ||
169 | /// <param name="actions">A series of method bodies to execute</param> | ||
170 | public static void Invoke(int threadCount, params Action[] actions) | ||
171 | { | ||
172 | int counter = threadCount; | ||
173 | AutoResetEvent threadFinishEvent = new AutoResetEvent(false); | ||
174 | int index = -1; | ||
175 | Exception exception = null; | ||
176 | |||
177 | for (int i = 0; i < threadCount; i++) | ||
178 | { | ||
179 | ThreadPool.QueueUserWorkItem( | ||
180 | delegate(object o) | ||
181 | { | ||
182 | int threadIndex = (int)o; | ||
183 | |||
184 | while (exception == null) | ||
185 | { | ||
186 | int currentIndex = Interlocked.Increment(ref index); | ||
187 | |||
188 | if (currentIndex >= actions.Length) | ||
189 | break; | ||
190 | |||
191 | try { actions[currentIndex](); } | ||
192 | catch (Exception ex) { exception = ex; break; } | ||
193 | } | ||
194 | |||
195 | if (Interlocked.Decrement(ref counter) == 0) | ||
196 | threadFinishEvent.Set(); | ||
197 | }, i | ||
198 | ); | ||
199 | } | ||
200 | |||
201 | threadFinishEvent.WaitOne(); | ||
202 | |||
203 | if (exception != null) | ||
204 | throw new Exception(exception.Message, exception); | ||
205 | } | ||
206 | } | ||
207 | } | ||
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 56155dd..845a9fe 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Text; | 33 | using System.Text; |
@@ -109,9 +110,8 @@ namespace OpenSim.Framework.Servers | |||
109 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | 110 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); |
110 | m_periodicDiagnosticsTimer.Enabled = true; | 111 | m_periodicDiagnosticsTimer.Enabled = true; |
111 | 112 | ||
112 | // Add ourselves to thread monitoring. This thread will go on to become the console listening thread | 113 | // This thread will go on to become the console listening thread |
113 | Thread.CurrentThread.Name = "ConsoleThread"; | 114 | Thread.CurrentThread.Name = "ConsoleThread"; |
114 | ThreadTracker.Add(Thread.CurrentThread); | ||
115 | 115 | ||
116 | ILoggerRepository repository = LogManager.GetRepository(); | 116 | ILoggerRepository repository = LogManager.GetRepository(); |
117 | IAppender[] appenders = repository.GetAppenders(); | 117 | IAppender[] appenders = repository.GetAppenders(); |
@@ -235,7 +235,7 @@ namespace OpenSim.Framework.Servers | |||
235 | { | 235 | { |
236 | StringBuilder sb = new StringBuilder(); | 236 | StringBuilder sb = new StringBuilder(); |
237 | 237 | ||
238 | List<Thread> threads = ThreadTracker.GetThreads(); | 238 | ProcessThreadCollection threads = ThreadTracker.GetThreads(); |
239 | if (threads == null) | 239 | if (threads == null) |
240 | { | 240 | { |
241 | sb.Append("OpenSim thread tracking is only enabled in DEBUG mode."); | 241 | sb.Append("OpenSim thread tracking is only enabled in DEBUG mode."); |
@@ -243,25 +243,15 @@ namespace OpenSim.Framework.Servers | |||
243 | else | 243 | else |
244 | { | 244 | { |
245 | sb.Append(threads.Count + " threads are being tracked:" + Environment.NewLine); | 245 | sb.Append(threads.Count + " threads are being tracked:" + Environment.NewLine); |
246 | foreach (Thread t in threads) | 246 | foreach (ProcessThread t in threads) |
247 | { | 247 | { |
248 | if (t.IsAlive) | 248 | sb.Append("ID: " + t.Id + ", TotalProcessorTime: " + t.TotalProcessorTime + ", TimeRunning: " + |
249 | { | 249 | (DateTime.Now - t.StartTime) + ", Pri: " + t.CurrentPriority + ", State: " + t.ThreadState ); |
250 | sb.Append( | 250 | if (t.ThreadState == System.Diagnostics.ThreadState.Wait) |
251 | "ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", Alive: " + t.IsAlive | 251 | sb.Append(", Reason: " + t.WaitReason + Environment.NewLine); |
252 | + ", Pri: " + t.Priority + ", State: " + t.ThreadState + Environment.NewLine); | ||
253 | } | ||
254 | else | 252 | else |
255 | { | 253 | sb.Append(Environment.NewLine); |
256 | try | 254 | |
257 | { | ||
258 | sb.Append("ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", DEAD" + Environment.NewLine); | ||
259 | } | ||
260 | catch | ||
261 | { | ||
262 | sb.Append("THREAD ERROR" + Environment.NewLine); | ||
263 | } | ||
264 | } | ||
265 | } | 255 | } |
266 | } | 256 | } |
267 | int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; | 257 | int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; |
diff --git a/OpenSim/Framework/Tests/ThreadTrackerTests.cs b/OpenSim/Framework/Tests/ThreadTrackerTests.cs deleted file mode 100644 index 15d5b73..0000000 --- a/OpenSim/Framework/Tests/ThreadTrackerTests.cs +++ /dev/null | |||
@@ -1,192 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using NUnit.Framework; | ||
30 | using System.Threading; | ||
31 | using System.Collections.Generic; | ||
32 | |||
33 | namespace OpenSim.Framework.Tests | ||
34 | { | ||
35 | [TestFixture] | ||
36 | public class ThreadTrackerTests | ||
37 | { | ||
38 | private bool running = true; | ||
39 | private bool running2 = true; | ||
40 | |||
41 | [Test] | ||
42 | public void DefaultThreadTrackerTest() | ||
43 | { | ||
44 | List<Thread> lThread = ThreadTracker.GetThreads(); | ||
45 | |||
46 | /* | ||
47 | foreach (Thread t in lThread) | ||
48 | { | ||
49 | System.Console.WriteLine(t.Name); | ||
50 | } | ||
51 | */ | ||
52 | |||
53 | Assert.That(lThread.Count == 1); | ||
54 | Assert.That(lThread[0].Name == "ThreadTrackerThread"); | ||
55 | } | ||
56 | |||
57 | /// <summary> | ||
58 | /// Validate that adding a thread to the thread tracker works | ||
59 | /// Validate that removing a thread from the thread tracker also works. | ||
60 | /// </summary> | ||
61 | [Test] | ||
62 | public void AddThreadToThreadTrackerTestAndRemoveTest() | ||
63 | { | ||
64 | Thread t = new Thread(run); | ||
65 | t.Name = "TestThread"; | ||
66 | t.Priority = ThreadPriority.BelowNormal; | ||
67 | t.IsBackground = true; | ||
68 | t.SetApartmentState(ApartmentState.MTA); | ||
69 | t.Start(); | ||
70 | ThreadTracker.Add(t); | ||
71 | |||
72 | List<Thread> lThread = ThreadTracker.GetThreads(); | ||
73 | |||
74 | Assert.That(lThread.Count == 2); | ||
75 | |||
76 | foreach (Thread tr in lThread) | ||
77 | { | ||
78 | Assert.That((tr.Name == "ThreadTrackerThread" || tr.Name == "TestThread")); | ||
79 | } | ||
80 | running = false; | ||
81 | ThreadTracker.Remove(t); | ||
82 | |||
83 | lThread = ThreadTracker.GetThreads(); | ||
84 | |||
85 | Assert.That(lThread.Count == 1); | ||
86 | |||
87 | foreach (Thread tr in lThread) | ||
88 | { | ||
89 | Assert.That((tr.Name == "ThreadTrackerThread")); | ||
90 | } | ||
91 | |||
92 | |||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Test a dead thread removal by aborting it and setting it's last seen active date to 50 seconds | ||
97 | /// </summary> | ||
98 | [Test] | ||
99 | public void DeadThreadTest() | ||
100 | { | ||
101 | Thread t = new Thread(run2); | ||
102 | t.Name = "TestThread"; | ||
103 | t.Priority = ThreadPriority.BelowNormal; | ||
104 | t.IsBackground = true; | ||
105 | t.SetApartmentState(ApartmentState.MTA); | ||
106 | t.Start(); | ||
107 | ThreadTracker.Add(t); | ||
108 | t.Abort(); | ||
109 | Thread.Sleep(5000); | ||
110 | ThreadTracker.m_Threads[1].LastSeenActive = DateTime.Now.Ticks - (50*10000000); | ||
111 | ThreadTracker.CleanUp(); | ||
112 | List<Thread> lThread = ThreadTracker.GetThreads(); | ||
113 | |||
114 | Assert.That(lThread.Count == 1); | ||
115 | |||
116 | foreach (Thread tr in lThread) | ||
117 | { | ||
118 | Assert.That((tr.Name == "ThreadTrackerThread")); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | [Test] | ||
123 | public void UnstartedThreadTest() | ||
124 | { | ||
125 | Thread t = new Thread(run2); | ||
126 | t.Name = "TestThread"; | ||
127 | t.Priority = ThreadPriority.BelowNormal; | ||
128 | t.IsBackground = true; | ||
129 | t.SetApartmentState(ApartmentState.MTA); | ||
130 | ThreadTracker.Add(t); | ||
131 | ThreadTracker.m_Threads[1].LastSeenActive = DateTime.Now.Ticks - (50 * 10000000); | ||
132 | ThreadTracker.CleanUp(); | ||
133 | List<Thread> lThread = ThreadTracker.GetThreads(); | ||
134 | |||
135 | Assert.That(lThread.Count == 1); | ||
136 | |||
137 | foreach (Thread tr in lThread) | ||
138 | { | ||
139 | Assert.That((tr.Name == "ThreadTrackerThread")); | ||
140 | } | ||
141 | } | ||
142 | |||
143 | [Test] | ||
144 | public void NullThreadTest() | ||
145 | { | ||
146 | Thread t = null; | ||
147 | ThreadTracker.Add(t); | ||
148 | |||
149 | List<Thread> lThread = ThreadTracker.GetThreads(); | ||
150 | |||
151 | Assert.That(lThread.Count == 1); | ||
152 | |||
153 | foreach (Thread tr in lThread) | ||
154 | { | ||
155 | Assert.That((tr.Name == "ThreadTrackerThread")); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | |||
160 | /// <summary> | ||
161 | /// Worker thread 0 | ||
162 | /// </summary> | ||
163 | /// <param name="o"></param> | ||
164 | public void run(object o) | ||
165 | { | ||
166 | while (running) | ||
167 | { | ||
168 | Thread.Sleep(5000); | ||
169 | } | ||
170 | } | ||
171 | |||
172 | /// <summary> | ||
173 | /// Worker thread 1 | ||
174 | /// </summary> | ||
175 | /// <param name="o"></param> | ||
176 | public void run2(object o) | ||
177 | { | ||
178 | try | ||
179 | { | ||
180 | while (running2) | ||
181 | { | ||
182 | Thread.Sleep(5000); | ||
183 | } | ||
184 | |||
185 | } | ||
186 | catch (ThreadAbortException) | ||
187 | { | ||
188 | } | ||
189 | } | ||
190 | |||
191 | } | ||
192 | } | ||
diff --git a/OpenSim/Framework/ThreadTracker.cs b/OpenSim/Framework/ThreadTracker.cs index d3a239d..b68d9b3 100644 --- a/OpenSim/Framework/ThreadTracker.cs +++ b/OpenSim/Framework/ThreadTracker.cs | |||
@@ -26,138 +26,21 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
31 | using System.Reflection; | 30 | using System.Reflection; |
32 | using System.Threading; | 31 | using System.Diagnostics; |
33 | using log4net; | 32 | using log4net; |
34 | 33 | ||
35 | namespace OpenSim.Framework | 34 | namespace OpenSim.Framework |
36 | { | 35 | { |
37 | public static class ThreadTracker | 36 | public static class ThreadTracker |
38 | { | 37 | { |
39 | private static readonly ILog m_log | 38 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
41 | |||
42 | private static readonly long ThreadTimeout = 30 * 10000000; | ||
43 | public static List<ThreadTrackerItem> m_Threads; | ||
44 | public static Thread ThreadTrackerThread; | ||
45 | 39 | ||
46 | static ThreadTracker() | 40 | public static ProcessThreadCollection GetThreads() |
47 | { | 41 | { |
48 | #if DEBUG | 42 | Process thisProc = Process.GetCurrentProcess(); |
49 | m_Threads = new List<ThreadTrackerItem>(); | 43 | return thisProc.Threads; |
50 | ThreadTrackerThread = new Thread(ThreadTrackerThreadLoop); | ||
51 | ThreadTrackerThread.Name = "ThreadTrackerThread"; | ||
52 | ThreadTrackerThread.IsBackground = true; | ||
53 | ThreadTrackerThread.Priority = ThreadPriority.BelowNormal; | ||
54 | ThreadTrackerThread.Start(); | ||
55 | Add(ThreadTrackerThread); | ||
56 | #endif | ||
57 | } | 44 | } |
58 | |||
59 | private static void ThreadTrackerThreadLoop() | ||
60 | { | ||
61 | try | ||
62 | { | ||
63 | while (true) | ||
64 | { | ||
65 | Thread.Sleep(5000); | ||
66 | CleanUp(); | ||
67 | } | ||
68 | } | ||
69 | catch (Exception e) | ||
70 | { | ||
71 | m_log.ErrorFormat( | ||
72 | "[THREAD TRACKER]: Thread tracker cleanup thread terminating with exception. Please report this error. Exception is {0}", | ||
73 | e); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | public static void Add(Thread thread) | ||
78 | { | ||
79 | #if DEBUG | ||
80 | if (thread != null) | ||
81 | { | ||
82 | lock (m_Threads) | ||
83 | { | ||
84 | ThreadTrackerItem tti = new ThreadTrackerItem(); | ||
85 | tti.Thread = thread; | ||
86 | tti.LastSeenActive = DateTime.Now.Ticks; | ||
87 | m_Threads.Add(tti); | ||
88 | } | ||
89 | } | ||
90 | #endif | ||
91 | } | ||
92 | |||
93 | public static void Remove(Thread thread) | ||
94 | { | ||
95 | #if DEBUG | ||
96 | lock (m_Threads) | ||
97 | { | ||
98 | foreach (ThreadTrackerItem tti in new ArrayList(m_Threads)) | ||
99 | { | ||
100 | if (tti.Thread == thread) | ||
101 | m_Threads.Remove(tti); | ||
102 | } | ||
103 | } | ||
104 | #endif | ||
105 | } | ||
106 | |||
107 | public static void CleanUp() | ||
108 | { | ||
109 | lock (m_Threads) | ||
110 | { | ||
111 | foreach (ThreadTrackerItem tti in new ArrayList(m_Threads)) | ||
112 | { | ||
113 | try | ||
114 | { | ||
115 | |||
116 | |||
117 | if (tti.Thread.IsAlive) | ||
118 | { | ||
119 | // Its active | ||
120 | tti.LastSeenActive = DateTime.Now.Ticks; | ||
121 | } | ||
122 | else | ||
123 | { | ||
124 | // Its not active -- if its expired then remove it | ||
125 | if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks) | ||
126 | m_Threads.Remove(tti); | ||
127 | } | ||
128 | } | ||
129 | catch (NullReferenceException) | ||
130 | { | ||
131 | m_Threads.Remove(tti); | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | public static List<Thread> GetThreads() | ||
138 | { | ||
139 | if (m_Threads == null) | ||
140 | return null; | ||
141 | |||
142 | List<Thread> threads = new List<Thread>(); | ||
143 | lock (m_Threads) | ||
144 | { | ||
145 | foreach (ThreadTrackerItem tti in new ArrayList(m_Threads)) | ||
146 | { | ||
147 | threads.Add(tti.Thread); | ||
148 | } | ||
149 | } | ||
150 | return threads; | ||
151 | } | ||
152 | |||
153 | #region Nested type: ThreadTrackerItem | ||
154 | |||
155 | public class ThreadTrackerItem | ||
156 | { | ||
157 | public long LastSeenActive; | ||
158 | public Thread Thread; | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | } | 45 | } |
163 | } | 46 | } |
diff --git a/OpenSim/Framework/ThrottleOutPacketType.cs b/OpenSim/Framework/ThrottleOutPacketType.cs index 0843757..fd490a5 100644 --- a/OpenSim/Framework/ThrottleOutPacketType.cs +++ b/OpenSim/Framework/ThrottleOutPacketType.cs | |||
@@ -29,9 +29,9 @@ using System; | |||
29 | 29 | ||
30 | namespace OpenSim.Framework | 30 | namespace OpenSim.Framework |
31 | { | 31 | { |
32 | [Flags] | ||
33 | public enum ThrottleOutPacketType : int | 32 | public enum ThrottleOutPacketType : int |
34 | { | 33 | { |
34 | Unknown = -1, // Also doubles as 'do not throttle' | ||
35 | Resend = 0, | 35 | Resend = 0, |
36 | Land = 1, | 36 | Land = 1, |
37 | Wind = 2, | 37 | Wind = 2, |
@@ -39,11 +39,5 @@ namespace OpenSim.Framework | |||
39 | Task = 4, | 39 | Task = 4, |
40 | Texture = 5, | 40 | Texture = 5, |
41 | Asset = 6, | 41 | Asset = 6, |
42 | Unknown = 7, // Also doubles as 'do not throttle' | ||
43 | Back = 8, | ||
44 | |||
45 | TypeMask = 15, // The mask to mask off the flags | ||
46 | |||
47 | LowPriority = 128 // Additional flags | ||
48 | } | 42 | } |
49 | } | 43 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 0851d26..38729c6 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1231,6 +1231,42 @@ namespace OpenSim.Framework | |||
1231 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; | 1231 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | public static byte[] StringToBytes256(string str) | ||
1235 | { | ||
1236 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } | ||
1237 | if (str.Length > 254) str = str.Remove(254); | ||
1238 | if (!str.EndsWith("\0")) { str += "\0"; } | ||
1239 | |||
1240 | // Because this is UTF-8 encoding and not ASCII, it's possible we | ||
1241 | // might have gotten an oversized array even after the string trim | ||
1242 | byte[] data = UTF8.GetBytes(str); | ||
1243 | if (data.Length > 256) | ||
1244 | { | ||
1245 | Array.Resize<byte>(ref data, 256); | ||
1246 | data[255] = 0; | ||
1247 | } | ||
1248 | |||
1249 | return data; | ||
1250 | } | ||
1251 | |||
1252 | public static byte[] StringToBytes1024(string str) | ||
1253 | { | ||
1254 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } | ||
1255 | if (str.Length > 1023) str = str.Remove(1023); | ||
1256 | if (!str.EndsWith("\0")) { str += "\0"; } | ||
1257 | |||
1258 | // Because this is UTF-8 encoding and not ASCII, it's possible we | ||
1259 | // might have gotten an oversized array even after the string trim | ||
1260 | byte[] data = UTF8.GetBytes(str); | ||
1261 | if (data.Length > 1024) | ||
1262 | { | ||
1263 | Array.Resize<byte>(ref data, 1024); | ||
1264 | data[1023] = 0; | ||
1265 | } | ||
1266 | |||
1267 | return data; | ||
1268 | } | ||
1269 | |||
1234 | #region FireAndForget Threading Pattern | 1270 | #region FireAndForget Threading Pattern |
1235 | 1271 | ||
1236 | public static void FireAndForget(System.Threading.WaitCallback callback) | 1272 | public static void FireAndForget(System.Threading.WaitCallback callback) |
@@ -1247,7 +1283,9 @@ namespace OpenSim.Framework | |||
1247 | { | 1283 | { |
1248 | System.Threading.WaitCallback callback = (System.Threading.WaitCallback)ar.AsyncState; | 1284 | System.Threading.WaitCallback callback = (System.Threading.WaitCallback)ar.AsyncState; |
1249 | 1285 | ||
1250 | callback.EndInvoke(ar); | 1286 | try { callback.EndInvoke(ar); } |
1287 | catch (Exception ex) { m_log.Error("[UTIL]: Asynchronous method threw an exception: " + ex.Message, ex); } | ||
1288 | |||
1251 | ar.AsyncWaitHandle.Close(); | 1289 | ar.AsyncWaitHandle.Close(); |
1252 | } | 1290 | } |
1253 | 1291 | ||
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index 33b01e5..555baa4 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs | |||
@@ -91,6 +91,18 @@ namespace OpenSim | |||
91 | m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config"); | 91 | m_log.Info("[OPENSIM MAIN]: configured log4net using default OpenSim.exe.config"); |
92 | } | 92 | } |
93 | 93 | ||
94 | // Increase the number of IOCP threads available. Mono defaults to a tragically low number | ||
95 | int workerThreads, iocpThreads; | ||
96 | System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads); | ||
97 | m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads); | ||
98 | if (workerThreads < 500 || iocpThreads < 1000) | ||
99 | { | ||
100 | workerThreads = 500; | ||
101 | iocpThreads = 1000; | ||
102 | m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads"); | ||
103 | System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads); | ||
104 | } | ||
105 | |||
94 | // Check if the system is compatible with OpenSimulator. | 106 | // Check if the system is compatible with OpenSimulator. |
95 | // Ensures that the minimum system requirements are met | 107 | // Ensures that the minimum system requirements are met |
96 | m_log.Info("Performing compatibility checks... "); | 108 | m_log.Info("Performing compatibility checks... "); |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 6e7a2a0..4592c31 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -675,7 +675,7 @@ namespace OpenSim | |||
675 | 675 | ||
676 | if (foundClientServer) | 676 | if (foundClientServer) |
677 | { | 677 | { |
678 | m_clientServers[clientServerElement].Server.Close(); | 678 | m_clientServers[clientServerElement].NetworkStop(); |
679 | m_clientServers.RemoveAt(clientServerElement); | 679 | m_clientServers.RemoveAt(clientServerElement); |
680 | } | 680 | } |
681 | IScene scene; | 681 | IScene scene; |
diff --git a/OpenSim/Region/ClientStack/IClientNetworkServer.cs b/OpenSim/Region/ClientStack/IClientNetworkServer.cs index a71ad4d..54a441b 100644 --- a/OpenSim/Region/ClientStack/IClientNetworkServer.cs +++ b/OpenSim/Region/ClientStack/IClientNetworkServer.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Region.ClientStack | |||
38 | IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, | 38 | IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, |
39 | AgentCircuitManager authenticateClass); | 39 | AgentCircuitManager authenticateClass); |
40 | 40 | ||
41 | Socket Server { get; } | 41 | void NetworkStop(); |
42 | bool HandlesRegion(Location x); | 42 | bool HandlesRegion(Location x); |
43 | void AddScene(IScene x); | 43 | void AddScene(IScene x); |
44 | 44 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs deleted file mode 100644 index ee15171..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Net.Sockets; | ||
29 | |||
30 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
31 | { | ||
32 | public interface ILLClientStackNetworkHandler | ||
33 | { | ||
34 | void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode); // EndPoint packetSender); | ||
35 | void RemoveClientCircuit(uint circuitcode); | ||
36 | void RegisterPacketServer(LLPacketServer server); | ||
37 | } | ||
38 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs deleted file mode 100644 index 31f9580..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | using OpenMetaverse.Packets; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
34 | { | ||
35 | public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); | ||
36 | public delegate void PacketDrop(Packet pack, Object id); | ||
37 | public delegate void QueueEmpty(ThrottleOutPacketType queue); | ||
38 | public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); | ||
39 | |||
40 | /// <summary> | ||
41 | /// Interface to a class that handles all the activity involved with maintaining the client circuit (handling acks, | ||
42 | /// resends, pings, etc.) | ||
43 | /// </summary> | ||
44 | public interface ILLPacketHandler : IDisposable | ||
45 | { | ||
46 | event PacketStats OnPacketStats; | ||
47 | event PacketDrop OnPacketDrop; | ||
48 | event QueueEmpty OnQueueEmpty; | ||
49 | SynchronizeClientHandler SynchronizeClient { set; } | ||
50 | |||
51 | int PacketsReceived { get; } | ||
52 | int PacketsReceivedReported { get; } | ||
53 | uint ResendTimeout { get; set; } | ||
54 | bool ReliableIsImportant { get; set; } | ||
55 | int MaxReliableResends { get; set; } | ||
56 | |||
57 | /// <summary> | ||
58 | /// Initial handling of a received packet. It will be processed later in ProcessInPacket() | ||
59 | /// </summary> | ||
60 | /// <param name="packet"></param> | ||
61 | void InPacket(Packet packet); | ||
62 | |||
63 | /// <summary> | ||
64 | /// Take action depending on the type and contents of an received packet. | ||
65 | /// </summary> | ||
66 | /// <param name="item"></param> | ||
67 | void ProcessInPacket(LLQueItem item); | ||
68 | |||
69 | void ProcessOutPacket(LLQueItem item); | ||
70 | void OutPacket(Packet NewPack, | ||
71 | ThrottleOutPacketType throttlePacketType); | ||
72 | void OutPacket(Packet NewPack, | ||
73 | ThrottleOutPacketType throttlePacketType, Object id); | ||
74 | LLPacketQueue PacketQueue { get; } | ||
75 | void Flush(); | ||
76 | void Clear(); | ||
77 | ClientInfo GetClientInfo(); | ||
78 | void SetClientInfo(ClientInfo info); | ||
79 | void AddImportantPacket(PacketType type); | ||
80 | void RemoveImportantPacket(PacketType type); | ||
81 | int GetQueueCount(ThrottleOutPacketType queue); | ||
82 | } | ||
83 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs b/OpenSim/Region/ClientStack/LindenUDP/IncomingPacket.cs index 0ed2bc1..90b3ede 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/IncomingPacket.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -26,24 +26,32 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse.Packets; | ||
30 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.Packets; | ||
31 | 32 | ||
32 | namespace OpenSim.Region.ClientStack.LindenUDP | 33 | namespace OpenSim.Region.ClientStack.LindenUDP |
33 | { | 34 | { |
34 | public class LLQueItem | 35 | /// <summary> |
36 | /// Holds a reference to a <seealso cref="LLUDPClient"/> and a <seealso cref="Packet"/> | ||
37 | /// for incoming packets | ||
38 | /// </summary> | ||
39 | public sealed class IncomingPacket | ||
35 | { | 40 | { |
36 | public LLQueItem() | 41 | /// <summary>Client this packet came from</summary> |
42 | public LLUDPClient Client; | ||
43 | /// <summary>Packet data that has been received</summary> | ||
44 | public Packet Packet; | ||
45 | |||
46 | /// <summary> | ||
47 | /// Default constructor | ||
48 | /// </summary> | ||
49 | /// <param name="client">Reference to the client this packet came from</param> | ||
50 | /// <param name="packet">Packet data</param> | ||
51 | public IncomingPacket(LLUDPClient client, Packet packet) | ||
37 | { | 52 | { |
53 | Client = client; | ||
54 | Packet = packet; | ||
38 | } | 55 | } |
39 | |||
40 | public Packet Packet; | ||
41 | public bool Incoming; | ||
42 | public ThrottleOutPacketType throttleType; | ||
43 | public int TickCount; | ||
44 | public Object Identifier; | ||
45 | public int Resends; | ||
46 | public int Length; | ||
47 | public uint Sequence; | ||
48 | } | 56 | } |
49 | } | 57 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs index a80c1f0..1f73a1d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/KillPacket.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/IncomingPacketHistoryCollection.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -25,47 +25,49 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenMetaverse.Packets; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | 30 | ||
30 | namespace OpenSim.Region.ClientStack.LindenUDP | 31 | namespace OpenSim.Region.ClientStack.LindenUDP |
31 | { | 32 | { |
32 | /// <summary> | 33 | /// <summary> |
33 | /// When packetqueue dequeues this packet in the outgoing stream, it thread aborts | 34 | /// A circular buffer and hashset for tracking incoming packet sequence |
34 | /// Ensures that the thread abort happens from within the client thread | 35 | /// numbers |
35 | /// regardless of where the close method is called | ||
36 | /// </summary> | 36 | /// </summary> |
37 | class KillPacket : Packet | 37 | public sealed class IncomingPacketHistoryCollection |
38 | { | 38 | { |
39 | public override int Length | 39 | private readonly uint[] m_items; |
40 | { | 40 | private HashSet<uint> m_hashSet; |
41 | get { return 0; } | 41 | private int m_first; |
42 | } | 42 | private int m_next; |
43 | private int m_capacity; | ||
43 | 44 | ||
44 | public override void FromBytes(Header header, byte[] bytes, ref int i, ref int packetEnd) | 45 | public IncomingPacketHistoryCollection(int capacity) |
45 | { | 46 | { |
47 | this.m_capacity = capacity; | ||
48 | m_items = new uint[capacity]; | ||
49 | m_hashSet = new HashSet<uint>(); | ||
46 | } | 50 | } |
47 | 51 | ||
48 | public override void FromBytes(byte[] bytes, ref int i, ref int packetEnd, byte[] zeroBuffer) | 52 | public bool TryEnqueue(uint ack) |
49 | { | 53 | { |
50 | } | 54 | lock (m_hashSet) |
55 | { | ||
56 | if (m_hashSet.Add(ack)) | ||
57 | { | ||
58 | m_items[m_next] = ack; | ||
59 | m_next = (m_next + 1) % m_capacity; | ||
60 | if (m_next == m_first) | ||
61 | { | ||
62 | m_hashSet.Remove(m_items[m_first]); | ||
63 | m_first = (m_first + 1) % m_capacity; | ||
64 | } | ||
51 | 65 | ||
52 | public override byte[] ToBytes() | 66 | return true; |
53 | { | 67 | } |
54 | return new byte[0]; | 68 | } |
55 | } | ||
56 | 69 | ||
57 | public override byte[][] ToBytesMultiple() | 70 | return false; |
58 | { | ||
59 | return new byte[][] { new byte[0] }; | ||
60 | } | ||
61 | |||
62 | public KillPacket() | ||
63 | { | ||
64 | Type = PacketType.UseCircuitCode; | ||
65 | Header = new Header(); | ||
66 | Header.Frequency = OpenMetaverse.PacketFrequency.Low; | ||
67 | Header.ID = 65531; | ||
68 | Header.Reliable = true; | ||
69 | } | 71 | } |
70 | } | 72 | } |
71 | } | 73 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 19ad0b4..2f1face 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | |||
@@ -76,27 +76,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
76 | { | 76 | { |
77 | if (m_currentPacket <= m_stopPacket) | 77 | if (m_currentPacket <= m_stopPacket) |
78 | { | 78 | { |
79 | bool SendMore = true; | 79 | int count = 0; |
80 | bool sendMore = true; | ||
81 | |||
80 | if (!m_sentInfo || (m_currentPacket == 0)) | 82 | if (!m_sentInfo || (m_currentPacket == 0)) |
81 | { | 83 | { |
82 | if (SendFirstPacket(client)) | 84 | sendMore = !SendFirstPacket(client); |
83 | { | 85 | |
84 | SendMore = false; | ||
85 | } | ||
86 | m_sentInfo = true; | 86 | m_sentInfo = true; |
87 | m_currentPacket++; | 87 | ++m_currentPacket; |
88 | ++count; | ||
88 | } | 89 | } |
89 | if (m_currentPacket < 2) | 90 | if (m_currentPacket < 2) |
90 | { | 91 | { |
91 | m_currentPacket = 2; | 92 | m_currentPacket = 2; |
92 | } | 93 | } |
93 | 94 | ||
94 | int count = 0; | 95 | while (sendMore && count < maxpack && m_currentPacket <= m_stopPacket) |
95 | while (SendMore && count < maxpack && m_currentPacket <= m_stopPacket) | ||
96 | { | 96 | { |
97 | count++; | 97 | sendMore = SendPacket(client); |
98 | SendMore = SendPacket(client); | 98 | ++m_currentPacket; |
99 | m_currentPacket++; | 99 | ++count; |
100 | } | 100 | } |
101 | 101 | ||
102 | if (m_currentPacket > m_stopPacket) | 102 | if (m_currentPacket > m_stopPacket) |
@@ -196,13 +196,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
196 | 196 | ||
197 | m_currentPacket = StartPacket; | 197 | m_currentPacket = StartPacket; |
198 | } | 198 | } |
199 | |||
200 | if ((m_imageManager != null) && (m_imageManager.Client != null) && (m_imageManager.Client.PacketHandler != null)) | ||
201 | if (m_imageManager.Client.PacketHandler.GetQueueCount(ThrottleOutPacketType.Texture) == 0) | ||
202 | { | ||
203 | //m_log.Debug("No textures queued, sending one packet to kickstart it"); | ||
204 | SendPacket(m_imageManager.Client); | ||
205 | } | ||
206 | } | 199 | } |
207 | } | 200 | } |
208 | } | 201 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 0052729..84e705a 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -58,526 +58,180 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
58 | /// </summary> | 58 | /// </summary> |
59 | public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector | 59 | public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector |
60 | { | 60 | { |
61 | // LLClientView Only | ||
62 | public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args); | ||
63 | |||
64 | /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary> | ||
65 | private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; | ||
66 | |||
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 67 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
68 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients | ||
62 | 69 | ||
63 | /* static variables */ | 70 | private readonly LLUDPServer m_udpServer; |
64 | public static SynchronizeClientHandler SynchronizeClient; | 71 | private readonly LLUDPClient m_udpClient; |
65 | /* private variables */ | ||
66 | private readonly UUID m_sessionId; | 72 | private readonly UUID m_sessionId; |
67 | private readonly UUID m_secureSessionId = UUID.Zero; | 73 | private readonly UUID m_secureSessionId; |
68 | 74 | private readonly UUID m_agentId; | |
69 | private int m_debugPacketLevel; | 75 | private readonly uint m_circuitCode; |
76 | private readonly byte[] m_channelVersion = Utils.EmptyBytes; | ||
77 | private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>(); | ||
78 | private readonly IGroupsModule m_GroupsModule; | ||
70 | 79 | ||
71 | //private readonly IAssetCache m_assetCache; | ||
72 | private int m_cachedTextureSerial; | 80 | private int m_cachedTextureSerial; |
73 | private Timer m_clientPingTimer; | ||
74 | |||
75 | private Timer m_avatarTerseUpdateTimer; | 81 | private Timer m_avatarTerseUpdateTimer; |
76 | private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); | 82 | private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); |
77 | |||
78 | private Timer m_primTerseUpdateTimer; | 83 | private Timer m_primTerseUpdateTimer; |
79 | private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); | 84 | private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); |
80 | private Timer m_primFullUpdateTimer; | 85 | private Timer m_primFullUpdateTimer; |
81 | private List<ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates = | 86 | private List<ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates = new List<ObjectUpdatePacket.ObjectDataBlock>(); |
82 | new List<ObjectUpdatePacket.ObjectDataBlock>(); | ||
83 | |||
84 | private bool m_clientBlocked; | ||
85 | |||
86 | private int m_probesWithNoIngressPackets; | ||
87 | |||
88 | private readonly UUID m_agentId; | ||
89 | private readonly uint m_circuitCode; | ||
90 | private int m_moneyBalance; | 87 | private int m_moneyBalance; |
91 | private readonly ILLPacketHandler m_PacketHandler; | ||
92 | |||
93 | private int m_animationSequenceNumber = 1; | 88 | private int m_animationSequenceNumber = 1; |
94 | |||
95 | private readonly byte[] m_channelVersion = Utils.StringToBytes("OpenSimulator Server"); // Dummy value needed by libSL | ||
96 | |||
97 | private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>(); | ||
98 | |||
99 | private bool m_SendLogoutPacketWhenClosing = true; | 89 | private bool m_SendLogoutPacketWhenClosing = true; |
100 | 90 | private AgentUpdateArgs lastarg; | |
101 | private int m_inPacketsChecked; | 91 | private bool m_IsActive = true; |
102 | |||
103 | // Used to adjust Sun Orbit values so Linden based viewers properly position sun | ||
104 | private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; | ||
105 | |||
106 | |||
107 | /* protected variables */ | ||
108 | |||
109 | protected static Dictionary<PacketType, PacketMethod> PacketHandlers = | ||
110 | new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients | ||
111 | 92 | ||
112 | protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); | 93 | protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); |
113 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers | 94 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers |
114 | |||
115 | protected IScene m_scene; | 95 | protected IScene m_scene; |
116 | |||
117 | protected LLPacketServer m_networkServer; | ||
118 | |||
119 | protected LLImageManager m_imageManager; | 96 | protected LLImageManager m_imageManager; |
120 | |||
121 | /* public variables */ | ||
122 | protected string m_firstName; | 97 | protected string m_firstName; |
123 | protected string m_lastName; | 98 | protected string m_lastName; |
124 | protected Thread m_clientThread; | 99 | protected Thread m_clientThread; |
125 | protected Vector3 m_startpos; | 100 | protected Vector3 m_startpos; |
126 | protected EndPoint m_userEndPoint; | 101 | protected EndPoint m_userEndPoint; |
127 | protected EndPoint m_proxyEndPoint; | ||
128 | protected UUID m_activeGroupID = UUID.Zero; | 102 | protected UUID m_activeGroupID = UUID.Zero; |
129 | protected string m_activeGroupName = String.Empty; | 103 | protected string m_activeGroupName = String.Empty; |
130 | protected ulong m_activeGroupPowers; | 104 | protected ulong m_activeGroupPowers; |
131 | protected Dictionary<UUID,ulong> m_groupPowers = new Dictionary<UUID, ulong>(); | 105 | protected Dictionary<UUID,ulong> m_groupPowers = new Dictionary<UUID, ulong>(); |
132 | protected int m_avatarTerseUpdateRate = 50; | 106 | protected int m_terrainCheckerCount; |
133 | protected int m_avatarTerseUpdatesPerPacket = 5; | ||
134 | 107 | ||
135 | // LL uses these limits, apparently. Compressed terse would be | 108 | // LL uses these limits, apparently. Compressed terse would be 23, but we don't have that yet |
136 | // 23, but we don't have that yet | ||
137 | // | ||
138 | protected int m_primTerseUpdatesPerPacket = 10; | 109 | protected int m_primTerseUpdatesPerPacket = 10; |
139 | protected int m_primFullUpdatesPerPacket = 14; | 110 | protected int m_primFullUpdatesPerPacket = 14; |
140 | |||
141 | protected int m_primTerseUpdateRate = 10; | 111 | protected int m_primTerseUpdateRate = 10; |
142 | protected int m_primFullUpdateRate = 14; | 112 | protected int m_primFullUpdateRate = 14; |
143 | |||
144 | protected int m_textureSendLimit = 20; | 113 | protected int m_textureSendLimit = 20; |
145 | protected int m_textureDataLimit = 10; | 114 | protected int m_textureDataLimit = 10; |
146 | 115 | protected int m_avatarTerseUpdateRate = 50; | |
116 | protected int m_avatarTerseUpdatesPerPacket = 5; | ||
147 | protected int m_packetMTU = 1400; | 117 | protected int m_packetMTU = 1400; |
148 | |||
149 | protected IAssetService m_assetService; | 118 | protected IAssetService m_assetService; |
150 | 119 | ||
151 | // LLClientView Only | 120 | #region Properties |
152 | public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args); | ||
153 | |||
154 | /* Instantiated Designated Event Delegates */ | ||
155 | //- used so we don't create new objects for each incoming packet and then toss it out later */ | ||
156 | |||
157 | private GenericMessage handlerGenericMessage; | ||
158 | private RequestAvatarProperties handlerRequestAvatarProperties; //OnRequestAvatarProperties; | ||
159 | private UpdateAvatarProperties handlerUpdateAvatarProperties; // OnUpdateAvatarProperties; | ||
160 | private ChatMessage handlerChatFromClient; //OnChatFromClient; | ||
161 | private ChatMessage handlerChatFromClient2; //OnChatFromClient; | ||
162 | private ImprovedInstantMessage handlerInstantMessage; //OnInstantMessage; | ||
163 | private FriendActionDelegate handlerApproveFriendRequest; //OnApproveFriendRequest; | ||
164 | private FriendshipTermination handlerTerminateFriendship; //OnTerminateFriendship; | ||
165 | private RezObject handlerRezObject; //OnRezObject; | ||
166 | private DeRezObject handlerDeRezObject; //OnDeRezObject; | ||
167 | private ModifyTerrain handlerModifyTerrain; | ||
168 | private BakeTerrain handlerBakeTerrain; | ||
169 | private EstateChangeInfo handlerEstateChangeInfo; | ||
170 | private Action<IClientAPI> handlerRegionHandShakeReply; //OnRegionHandShakeReply; | ||
171 | private GenericCall2 handlerRequestWearables; //OnRequestWearables; | ||
172 | private Action<IClientAPI> handlerRequestAvatarsData; //OnRequestAvatarsData; | ||
173 | private SetAppearance handlerSetAppearance; //OnSetAppearance; | ||
174 | private AvatarNowWearing handlerAvatarNowWearing; //OnAvatarNowWearing; | ||
175 | private RezSingleAttachmentFromInv handlerRezSingleAttachment; //OnRezSingleAttachmentFromInv; | ||
176 | private RezMultipleAttachmentsFromInv handlerRezMultipleAttachments; //OnRezMultipleAttachmentsFromInv; | ||
177 | private UUIDNameRequest handlerDetachAttachmentIntoInv; // Detach attachment! | ||
178 | private ObjectAttach handlerObjectAttach; //OnObjectAttach; | ||
179 | private SetAlwaysRun handlerSetAlwaysRun; //OnSetAlwaysRun; | ||
180 | private GenericCall2 handlerCompleteMovementToRegion; //OnCompleteMovementToRegion; | ||
181 | private UpdateAgent handlerAgentUpdate; //OnAgentUpdate; | ||
182 | private StartAnim handlerStartAnim; | ||
183 | private StopAnim handlerStopAnim; | ||
184 | private AgentRequestSit handlerAgentRequestSit; //OnAgentRequestSit; | ||
185 | private AgentSit handlerAgentSit; //OnAgentSit; | ||
186 | private AvatarPickerRequest handlerAvatarPickerRequest; //OnAvatarPickerRequest; | ||
187 | private FetchInventory handlerAgentDataUpdateRequest; //OnAgentDataUpdateRequest; | ||
188 | private TeleportLocationRequest handlerSetStartLocationRequest; //OnSetStartLocationRequest; | ||
189 | private TeleportLandmarkRequest handlerTeleportLandmarkRequest; //OnTeleportLandmarkRequest; | ||
190 | private LinkObjects handlerLinkObjects; //OnLinkObjects; | ||
191 | private DelinkObjects handlerDelinkObjects; //OnDelinkObjects; | ||
192 | private AddNewPrim handlerAddPrim; //OnAddPrim; | ||
193 | private UpdateShape handlerUpdatePrimShape; //null; | ||
194 | private ObjectExtraParams handlerUpdateExtraParams; //OnUpdateExtraParams; | ||
195 | private ObjectDuplicate handlerObjectDuplicate; | ||
196 | private ObjectDuplicateOnRay handlerObjectDuplicateOnRay; | ||
197 | private ObjectRequest handlerObjectRequest; | ||
198 | private ObjectSelect handlerObjectSelect; | ||
199 | private ObjectDeselect handlerObjectDeselect; | ||
200 | private ObjectIncludeInSearch handlerObjectIncludeInSearch; | ||
201 | private UpdatePrimFlags handlerUpdatePrimFlags; //OnUpdatePrimFlags; | ||
202 | private UpdatePrimTexture handlerUpdatePrimTexture; | ||
203 | private GrabObject handlerGrabObject; //OnGrabObject; | ||
204 | private MoveObject handlerGrabUpdate; //OnGrabUpdate; | ||
205 | private DeGrabObject handlerDeGrabObject; //OnDeGrabObject; | ||
206 | private SpinStart handlerSpinStart; //OnSpinStart; | ||
207 | private SpinObject handlerSpinUpdate; //OnSpinUpdate; | ||
208 | private SpinStop handlerSpinStop; //OnSpinStop; | ||
209 | private GenericCall7 handlerObjectDescription; | ||
210 | private GenericCall7 handlerObjectName; | ||
211 | private GenericCall7 handlerObjectClickAction; | ||
212 | private GenericCall7 handlerObjectMaterial; | ||
213 | private ObjectPermissions handlerObjectPermissions; | ||
214 | private RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily; //OnRequestObjectPropertiesFamily; | ||
215 | //private TextureRequest handlerTextureRequest; | ||
216 | private UDPAssetUploadRequest handlerAssetUploadRequest; //OnAssetUploadRequest; | ||
217 | private RequestXfer handlerRequestXfer; //OnRequestXfer; | ||
218 | private XferReceive handlerXferReceive; //OnXferReceive; | ||
219 | private ConfirmXfer handlerConfirmXfer; //OnConfirmXfer; | ||
220 | private AbortXfer handlerAbortXfer; | ||
221 | private CreateInventoryFolder handlerCreateInventoryFolder; //OnCreateNewInventoryFolder; | ||
222 | private UpdateInventoryFolder handlerUpdateInventoryFolder; | ||
223 | private MoveInventoryFolder handlerMoveInventoryFolder; | ||
224 | private CreateNewInventoryItem handlerCreateNewInventoryItem; //OnCreateNewInventoryItem; | ||
225 | private FetchInventory handlerFetchInventory; | ||
226 | private FetchInventoryDescendents handlerFetchInventoryDescendents; //OnFetchInventoryDescendents; | ||
227 | private PurgeInventoryDescendents handlerPurgeInventoryDescendents; //OnPurgeInventoryDescendents; | ||
228 | private UpdateInventoryItem handlerUpdateInventoryItem; | ||
229 | private CopyInventoryItem handlerCopyInventoryItem; | ||
230 | private MoveInventoryItem handlerMoveInventoryItem; | ||
231 | private RemoveInventoryItem handlerRemoveInventoryItem; | ||
232 | private RemoveInventoryFolder handlerRemoveInventoryFolder; | ||
233 | private RequestTaskInventory handlerRequestTaskInventory; //OnRequestTaskInventory; | ||
234 | private UpdateTaskInventory handlerUpdateTaskInventory; //OnUpdateTaskInventory; | ||
235 | private MoveTaskInventory handlerMoveTaskItem; | ||
236 | private RemoveTaskInventory handlerRemoveTaskItem; //OnRemoveTaskItem; | ||
237 | private RezScript handlerRezScript; //OnRezScript; | ||
238 | private RequestMapBlocks handlerRequestMapBlocks; //OnRequestMapBlocks; | ||
239 | private RequestMapName handlerMapNameRequest; //OnMapNameRequest; | ||
240 | private TeleportLocationRequest handlerTeleportLocationRequest; //OnTeleportLocationRequest; | ||
241 | private MoneyBalanceRequest handlerMoneyBalanceRequest; //OnMoneyBalanceRequest; | ||
242 | private UUIDNameRequest handlerNameRequest; | ||
243 | private ParcelAccessListRequest handlerParcelAccessListRequest; //OnParcelAccessListRequest; | ||
244 | private ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest; //OnParcelAccessListUpdateRequest; | ||
245 | private ParcelPropertiesRequest handlerParcelPropertiesRequest; //OnParcelPropertiesRequest; | ||
246 | private ParcelDivideRequest handlerParcelDivideRequest; //OnParcelDivideRequest; | ||
247 | private ParcelJoinRequest handlerParcelJoinRequest; //OnParcelJoinRequest; | ||
248 | private ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest; //OnParcelPropertiesUpdateRequest; | ||
249 | private ParcelSelectObjects handlerParcelSelectObjects; //OnParcelSelectObjects; | ||
250 | private ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest; //OnParcelObjectOwnerRequest; | ||
251 | private ParcelAbandonRequest handlerParcelAbandonRequest; | ||
252 | private ParcelGodForceOwner handlerParcelGodForceOwner; | ||
253 | private ParcelReclaim handlerParcelReclaim; | ||
254 | private RequestTerrain handlerRequestTerrain; | ||
255 | private RequestTerrain handlerUploadTerrain; | ||
256 | private ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest; | ||
257 | private RegionInfoRequest handlerRegionInfoRequest; //OnRegionInfoRequest; | ||
258 | private EstateCovenantRequest handlerEstateCovenantRequest; //OnEstateCovenantRequest; | ||
259 | private RequestGodlikePowers handlerReqGodlikePowers; //OnRequestGodlikePowers; | ||
260 | private GodKickUser handlerGodKickUser; //OnGodKickUser; | ||
261 | private ViewerEffectEventHandler handlerViewerEffect; //OnViewerEffect; | ||
262 | private Action<IClientAPI> handlerLogout; //OnLogout; | ||
263 | private MoneyTransferRequest handlerMoneyTransferRequest; //OnMoneyTransferRequest; | ||
264 | private ParcelBuy handlerParcelBuy; | ||
265 | private EconomyDataRequest handlerEconomoyDataRequest; | ||
266 | |||
267 | private UpdateVector handlerUpdatePrimSinglePosition; //OnUpdatePrimSinglePosition; | ||
268 | private UpdatePrimSingleRotation handlerUpdatePrimSingleRotation; //OnUpdatePrimSingleRotation; | ||
269 | private UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition; //OnUpdatePrimSingleRotation; | ||
270 | private UpdateVector handlerUpdatePrimScale; //OnUpdatePrimScale; | ||
271 | private UpdateVector handlerUpdatePrimGroupScale; //OnUpdateGroupScale; | ||
272 | private UpdateVector handlerUpdateVector; //OnUpdatePrimGroupPosition; | ||
273 | private UpdatePrimRotation handlerUpdatePrimRotation; //OnUpdatePrimGroupRotation; | ||
274 | // private UpdatePrimGroupRotation handlerUpdatePrimGroupRotation; //OnUpdatePrimGroupMouseRotation; | ||
275 | // private RequestAsset handlerRequestAsset; // OnRequestAsset; | ||
276 | private UUIDNameRequest handlerTeleportHomeRequest; | ||
277 | |||
278 | private RegionHandleRequest handlerRegionHandleRequest; // OnRegionHandleRequest | ||
279 | private ParcelInfoRequest handlerParcelInfoRequest; // OnParcelInfoRequest | ||
280 | |||
281 | private ScriptAnswer handlerScriptAnswer; | ||
282 | private RequestPayPrice handlerRequestPayPrice; | ||
283 | private ObjectSaleInfo handlerObjectSaleInfo; | ||
284 | private ObjectBuy handlerObjectBuy; | ||
285 | //private BuyObjectInventory handlerBuyObjectInventory; | ||
286 | private ObjectDeselect handlerObjectDetach; | ||
287 | private ObjectDrop handlerObjectDrop; | ||
288 | private AgentSit handlerOnUndo; | ||
289 | |||
290 | private ForceReleaseControls handlerForceReleaseControls; | ||
291 | |||
292 | private GodLandStatRequest handlerLandStatRequest; | ||
293 | |||
294 | private UUIDNameRequest handlerUUIDGroupNameRequest; | ||
295 | |||
296 | private ParcelDeedToGroup handlerParcelDeedToGroup; | ||
297 | |||
298 | private RequestObjectPropertiesFamily handlerObjectGroupRequest; | ||
299 | private ScriptReset handlerScriptReset; | ||
300 | private GetScriptRunning handlerGetScriptRunning; | ||
301 | private SetScriptRunning handlerSetScriptRunning; | ||
302 | private UpdateVector handlerAutoPilotGo; | ||
303 | //Gesture | ||
304 | private ActivateGesture handlerActivateGesture; | ||
305 | private DeactivateGesture handlerDeactivateGesture; | ||
306 | //Sound | ||
307 | private SoundTrigger handlerSoundTrigger; | ||
308 | private ObjectOwner handlerObjectOwner; | ||
309 | |||
310 | private DirPlacesQuery handlerDirPlacesQuery; | ||
311 | private DirFindQuery handlerDirFindQuery; | ||
312 | private DirLandQuery handlerDirLandQuery; | ||
313 | private DirPopularQuery handlerDirPopularQuery; | ||
314 | private DirClassifiedQuery handlerDirClassifiedQuery; | ||
315 | private ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime; | ||
316 | |||
317 | private MapItemRequest handlerMapItemRequest; | ||
318 | |||
319 | private StartLure handlerStartLure; | ||
320 | private TeleportLureRequest handlerTeleportLureRequest; | ||
321 | |||
322 | private NetworkStats handlerNetworkStatsUpdate; | ||
323 | |||
324 | private ClassifiedInfoRequest handlerClassifiedInfoRequest; | ||
325 | private ClassifiedInfoUpdate handlerClassifiedInfoUpdate; | ||
326 | private ClassifiedDelete handlerClassifiedDelete; | ||
327 | private ClassifiedDelete handlerClassifiedGodDelete; | ||
328 | |||
329 | private EventNotificationAddRequest handlerEventNotificationAddRequest; | ||
330 | private EventNotificationRemoveRequest handlerEventNotificationRemoveRequest; | ||
331 | private EventGodDelete handlerEventGodDelete; | ||
332 | |||
333 | private ParcelDwellRequest handlerParcelDwellRequest; | ||
334 | |||
335 | private UserInfoRequest handlerUserInfoRequest; | ||
336 | private UpdateUserInfo handlerUpdateUserInfo; | ||
337 | |||
338 | private RetrieveInstantMessages handlerRetrieveInstantMessages; | ||
339 | |||
340 | private PickDelete handlerPickDelete; | ||
341 | private PickGodDelete handlerPickGodDelete; | ||
342 | private PickInfoUpdate handlerPickInfoUpdate; | ||
343 | private AvatarNotesUpdate handlerAvatarNotesUpdate; | ||
344 | |||
345 | private MuteListRequest handlerMuteListRequest; | ||
346 | |||
347 | //private AvatarInterestUpdate handlerAvatarInterestUpdate; | ||
348 | |||
349 | private PlacesQuery handlerPlacesQuery; | ||
350 | |||
351 | private readonly IGroupsModule m_GroupsModule; | ||
352 | |||
353 | private AgentUpdateArgs lastarg = null; | ||
354 | |||
355 | //private TerrainUnacked handlerUnackedTerrain = null; | ||
356 | |||
357 | //** | ||
358 | |||
359 | /* Properties */ | ||
360 | |||
361 | public UUID SecureSessionId | ||
362 | { | ||
363 | get { return m_secureSessionId; } | ||
364 | } | ||
365 | |||
366 | public IScene Scene | ||
367 | { | ||
368 | get { return m_scene; } | ||
369 | } | ||
370 | |||
371 | public UUID SessionId | ||
372 | { | ||
373 | get { return m_sessionId; } | ||
374 | } | ||
375 | 121 | ||
122 | public UUID SecureSessionId { get { return m_secureSessionId; } } | ||
123 | public IScene Scene { get { return m_scene; } } | ||
124 | public UUID SessionId { get { return m_sessionId; } } | ||
376 | public Vector3 StartPos | 125 | public Vector3 StartPos |
377 | { | 126 | { |
378 | get { return m_startpos; } | 127 | get { return m_startpos; } |
379 | set { m_startpos = value; } | 128 | set { m_startpos = value; } |
380 | } | 129 | } |
381 | 130 | public UUID AgentId { get { return m_agentId; } } | |
382 | public UUID AgentId | 131 | public UUID ActiveGroupId { get { return m_activeGroupID; } } |
383 | { | 132 | public string ActiveGroupName { get { return m_activeGroupName; } } |
384 | get { return m_agentId; } | 133 | public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } |
385 | } | 134 | public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); } |
386 | |||
387 | public UUID ActiveGroupId | ||
388 | { | ||
389 | get { return m_activeGroupID; } | ||
390 | } | ||
391 | |||
392 | public string ActiveGroupName | ||
393 | { | ||
394 | get { return m_activeGroupName; } | ||
395 | } | ||
396 | |||
397 | public ulong ActiveGroupPowers | ||
398 | { | ||
399 | get { return m_activeGroupPowers; } | ||
400 | } | ||
401 | |||
402 | public bool IsGroupMember(UUID groupID) | ||
403 | { | ||
404 | return m_groupPowers.ContainsKey(groupID); | ||
405 | } | ||
406 | |||
407 | public ulong GetGroupPowers(UUID groupID) | ||
408 | { | ||
409 | if (groupID == m_activeGroupID) | ||
410 | return m_activeGroupPowers; | ||
411 | |||
412 | if (m_groupPowers.ContainsKey(groupID)) | ||
413 | return m_groupPowers[groupID]; | ||
414 | |||
415 | return 0; | ||
416 | } | ||
417 | |||
418 | /// <summary> | ||
419 | /// This is a utility method used by single states to not duplicate kicks and blue card of death messages. | ||
420 | /// </summary> | ||
421 | public bool ChildAgentStatus() | ||
422 | { | ||
423 | return m_scene.PresenceChildStatus(AgentId); | ||
424 | } | ||
425 | |||
426 | /// <summary> | 135 | /// <summary> |
427 | /// First name of the agent/avatar represented by the client | 136 | /// First name of the agent/avatar represented by the client |
428 | /// </summary> | 137 | /// </summary> |
429 | public string FirstName | 138 | public string FirstName { get { return m_firstName; } } |
430 | { | ||
431 | get { return m_firstName; } | ||
432 | } | ||
433 | |||
434 | /// <summary> | 139 | /// <summary> |
435 | /// Last name of the agent/avatar represented by the client | 140 | /// Last name of the agent/avatar represented by the client |
436 | /// </summary> | 141 | /// </summary> |
437 | public string LastName | 142 | public string LastName { get { return m_lastName; } } |
438 | { | ||
439 | get { return m_lastName; } | ||
440 | } | ||
441 | |||
442 | /// <summary> | 143 | /// <summary> |
443 | /// Full name of the client (first name and last name) | 144 | /// Full name of the client (first name and last name) |
444 | /// </summary> | 145 | /// </summary> |
445 | public string Name | 146 | public string Name { get { return FirstName + " " + LastName; } } |
446 | { | 147 | public uint CircuitCode { get { return m_circuitCode; } } |
447 | get { return FirstName + " " + LastName; } | 148 | public int MoneyBalance { get { return m_moneyBalance; } } |
448 | } | 149 | public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } } |
449 | |||
450 | public uint CircuitCode | ||
451 | { | ||
452 | get { return m_circuitCode; } | ||
453 | } | ||
454 | |||
455 | public int MoneyBalance | ||
456 | { | ||
457 | get { return m_moneyBalance; } | ||
458 | } | ||
459 | |||
460 | public int NextAnimationSequenceNumber | ||
461 | { | ||
462 | get { return m_animationSequenceNumber++; } | ||
463 | } | ||
464 | |||
465 | public ILLPacketHandler PacketHandler | ||
466 | { | ||
467 | get { return m_PacketHandler; } | ||
468 | } | ||
469 | |||
470 | bool m_IsActive = true; | ||
471 | |||
472 | public bool IsActive | 150 | public bool IsActive |
473 | { | 151 | { |
474 | get { return m_IsActive; } | 152 | get { return m_IsActive; } |
475 | set { m_IsActive = value; } | 153 | set { m_IsActive = value; } |
476 | } | 154 | } |
155 | public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } } | ||
477 | 156 | ||
478 | public bool SendLogoutPacketWhenClosing | 157 | #endregion Properties |
479 | { | ||
480 | set { m_SendLogoutPacketWhenClosing = value; } | ||
481 | } | ||
482 | |||
483 | /* METHODS */ | ||
484 | 158 | ||
485 | /// <summary> | 159 | /// <summary> |
486 | /// Constructor | 160 | /// Constructor |
487 | /// </summary> | 161 | /// </summary> |
488 | public LLClientView( | 162 | public LLClientView(EndPoint remoteEP, IScene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo, |
489 | EndPoint remoteEP, IScene scene, LLPacketServer packServer, | 163 | UUID agentId, UUID sessionId, uint circuitCode) |
490 | AuthenticateResponse sessionInfo, UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP, | ||
491 | ClientStackUserSettings userSettings) | ||
492 | { | 164 | { |
493 | // Should be called first? | 165 | RegisterInterface<IClientIM>(this); |
494 | RegisterInterfaces(); | 166 | RegisterInterface<IClientChat>(this); |
495 | 167 | RegisterInterface<IClientIPEndpoint>(this); | |
496 | m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); | 168 | |
497 | m_moneyBalance = 1000; | ||
498 | |||
499 | m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion()); | ||
500 | |||
501 | InitDefaultAnimations(); | 169 | InitDefaultAnimations(); |
502 | 170 | ||
503 | m_scene = scene; | 171 | m_scene = scene; |
504 | //m_assetCache = assetCache; | ||
505 | |||
506 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); | 172 | m_assetService = m_scene.RequestModuleInterface<IAssetService>(); |
507 | 173 | m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); | |
508 | m_networkServer = packServer; | 174 | m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); |
509 | 175 | m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion()); | |
510 | m_agentId = agentId; | 176 | m_agentId = agentId; |
511 | m_sessionId = sessionId; | 177 | m_sessionId = sessionId; |
178 | m_secureSessionId = sessionInfo.LoginInfo.SecureSession; | ||
512 | m_circuitCode = circuitCode; | 179 | m_circuitCode = circuitCode; |
513 | |||
514 | m_userEndPoint = remoteEP; | 180 | m_userEndPoint = remoteEP; |
515 | m_proxyEndPoint = proxyEP; | ||
516 | |||
517 | m_firstName = sessionInfo.LoginInfo.First; | 181 | m_firstName = sessionInfo.LoginInfo.First; |
518 | m_lastName = sessionInfo.LoginInfo.Last; | 182 | m_lastName = sessionInfo.LoginInfo.Last; |
519 | m_startpos = sessionInfo.LoginInfo.StartPos; | 183 | m_startpos = sessionInfo.LoginInfo.StartPos; |
184 | m_moneyBalance = 1000; | ||
520 | 185 | ||
521 | if (sessionInfo.LoginInfo.SecureSession != UUID.Zero) | 186 | m_udpServer = udpServer; |
522 | { | 187 | m_udpClient = udpClient; |
523 | m_secureSessionId = sessionInfo.LoginInfo.SecureSession; | 188 | m_udpClient.OnQueueEmpty += HandleQueueEmpty; |
524 | } | 189 | m_udpClient.OnPacketStats += PopulateStats; |
525 | |||
526 | // While working on this, the BlockingQueue had me fooled for a bit. | ||
527 | // The Blocking queue causes the thread to stop until there's something | ||
528 | // in it to process. It's an on-purpose threadlock though because | ||
529 | // without it, the clientloop will suck up all sim resources. | ||
530 | |||
531 | m_PacketHandler = new LLPacketHandler(this, m_networkServer, userSettings); | ||
532 | m_PacketHandler.SynchronizeClient = SynchronizeClient; | ||
533 | m_PacketHandler.OnPacketStats += PopulateStats; | ||
534 | m_PacketHandler.OnQueueEmpty += HandleQueueEmpty; | ||
535 | |||
536 | if (scene.Config != null) | ||
537 | { | ||
538 | IConfig clientConfig = scene.Config.Configs["LLClient"]; | ||
539 | if (clientConfig != null) | ||
540 | { | ||
541 | m_PacketHandler.ReliableIsImportant = | ||
542 | clientConfig.GetBoolean("ReliableIsImportant", | ||
543 | false); | ||
544 | m_PacketHandler.MaxReliableResends = clientConfig.GetInt("MaxReliableResends", | ||
545 | m_PacketHandler.MaxReliableResends); | ||
546 | m_primTerseUpdatesPerPacket = clientConfig.GetInt("TerseUpdatesPerPacket", | ||
547 | m_primTerseUpdatesPerPacket); | ||
548 | m_primFullUpdatesPerPacket = clientConfig.GetInt("FullUpdatesPerPacket", | ||
549 | m_primFullUpdatesPerPacket); | ||
550 | |||
551 | m_primTerseUpdateRate = clientConfig.GetInt("TerseUpdateRate", | ||
552 | m_primTerseUpdateRate); | ||
553 | m_primFullUpdateRate = clientConfig.GetInt("FullUpdateRate", | ||
554 | m_primFullUpdateRate); | ||
555 | |||
556 | m_textureSendLimit = clientConfig.GetInt("TextureSendLimit", | ||
557 | m_textureSendLimit); | ||
558 | |||
559 | m_textureDataLimit = clientConfig.GetInt("TextureDataLimit", | ||
560 | m_textureDataLimit); | ||
561 | |||
562 | m_packetMTU = clientConfig.GetInt("PacketMTU", 1400); | ||
563 | } | ||
564 | } | ||
565 | 190 | ||
566 | RegisterLocalPacketHandlers(); | 191 | RegisterLocalPacketHandlers(); |
567 | m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>()); | ||
568 | } | 192 | } |
569 | 193 | ||
570 | public void SetDebugPacketLevel(int newDebugPacketLevel) | 194 | public void SetDebugPacketLevel(int newDebug) |
571 | { | 195 | { |
572 | m_debugPacketLevel = newDebugPacketLevel; | ||
573 | } | 196 | } |
574 | 197 | ||
575 | # region Client Methods | 198 | #region Client Methods |
576 | 199 | ||
577 | private void CloseCleanup(bool shutdownCircuit) | 200 | /// <summary> |
201 | /// Close down the client view. This *must* be the last method called, since the last # | ||
202 | /// statement of CloseCleanup() aborts the thread. | ||
203 | /// </summary> | ||
204 | /// <param name="shutdownCircuit"></param> | ||
205 | public void Close(bool shutdownCircuit) | ||
578 | { | 206 | { |
207 | m_log.DebugFormat( | ||
208 | "[CLIENT]: Close has been called with shutdownCircuit = {0} for {1} attached to scene {2}", | ||
209 | shutdownCircuit, Name, m_scene.RegionInfo.RegionName); | ||
579 | 210 | ||
580 | 211 | if (m_imageManager != null) | |
212 | m_imageManager.Close(); | ||
213 | |||
214 | if (m_udpServer != null) | ||
215 | m_udpServer.Flush(); | ||
216 | |||
217 | // raise an event on the packet server to Shutdown the circuit | ||
218 | // Now, if we raise the event then the packet server will call this method itself, so don't try cleanup | ||
219 | // here otherwise we'll end up calling it twice. | ||
220 | // FIXME: In truth, I might be wrong but this whole business of calling this method twice (with different args) looks | ||
221 | // horribly tangly. Hopefully it should be possible to greatly simplify it. | ||
222 | if (shutdownCircuit) | ||
223 | { | ||
224 | if (OnConnectionClosed != null) | ||
225 | OnConnectionClosed(this); | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | CloseCleanup(shutdownCircuit); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | private void CloseCleanup(bool shutdownCircuit) | ||
234 | { | ||
581 | m_scene.RemoveClient(AgentId); | 235 | m_scene.RemoveClient(AgentId); |
582 | 236 | ||
583 | //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 237 | //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
@@ -590,9 +244,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
590 | Thread.Sleep(2000); | 244 | Thread.Sleep(2000); |
591 | 245 | ||
592 | // Shut down timers. Thread Context of this method is murky. Lock all timers | 246 | // Shut down timers. Thread Context of this method is murky. Lock all timers |
593 | if (m_clientPingTimer.Enabled) | ||
594 | lock (m_clientPingTimer) | ||
595 | m_clientPingTimer.Stop(); | ||
596 | if (m_avatarTerseUpdateTimer.Enabled) | 247 | if (m_avatarTerseUpdateTimer.Enabled) |
597 | lock (m_avatarTerseUpdateTimer) | 248 | lock (m_avatarTerseUpdateTimer) |
598 | m_avatarTerseUpdateTimer.Stop(); | 249 | m_avatarTerseUpdateTimer.Stop(); |
@@ -625,43 +276,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
625 | // of the client thread regardless of where Close() is called. | 276 | // of the client thread regardless of where Close() is called. |
626 | KillEndDone(); | 277 | KillEndDone(); |
627 | } | 278 | } |
628 | |||
629 | Terminate(); | ||
630 | } | ||
631 | 279 | ||
632 | /// <summary> | 280 | IsActive = false; |
633 | /// Close down the client view. This *must* be the last method called, since the last # | ||
634 | /// statement of CloseCleanup() aborts the thread. | ||
635 | /// </summary> | ||
636 | /// <param name="shutdownCircuit"></param> | ||
637 | public void Close(bool shutdownCircuit) | ||
638 | { | ||
639 | m_clientPingTimer.Enabled = false; | ||
640 | 281 | ||
641 | m_log.DebugFormat( | 282 | m_avatarTerseUpdateTimer.Close(); |
642 | "[CLIENT]: Close has been called with shutdownCircuit = {0} for {1} attached to scene {2}", | 283 | m_primTerseUpdateTimer.Close(); |
643 | shutdownCircuit, Name, m_scene.RegionInfo.RegionName); | 284 | m_primFullUpdateTimer.Close(); |
644 | 285 | ||
645 | if (m_imageManager != null) | 286 | //m_udpServer.OnPacketStats -= PopulateStats; |
646 | m_imageManager.Close(); | 287 | m_udpClient.Shutdown(); |
647 | 288 | ||
648 | if (m_PacketHandler != null) | 289 | // wait for thread stoped |
649 | m_PacketHandler.Flush(); | 290 | // m_clientThread.Join(); |
650 | 291 | ||
651 | // raise an event on the packet server to Shutdown the circuit | 292 | // delete circuit code |
652 | // Now, if we raise the event then the packet server will call this method itself, so don't try cleanup | 293 | //m_networkServer.CloseClient(this); |
653 | // here otherwise we'll end up calling it twice. | ||
654 | // FIXME: In truth, I might be wrong but this whole business of calling this method twice (with different args) looks | ||
655 | // horribly tangly. Hopefully it should be possible to greatly simplify it. | ||
656 | if (shutdownCircuit) | ||
657 | { | ||
658 | if (OnConnectionClosed != null) | ||
659 | OnConnectionClosed(this); | ||
660 | } | ||
661 | else | ||
662 | { | ||
663 | CloseCleanup(shutdownCircuit); | ||
664 | } | ||
665 | } | 294 | } |
666 | 295 | ||
667 | public void Kick(string message) | 296 | public void Kick(string message) |
@@ -683,10 +312,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
683 | public void Stop() | 312 | public void Stop() |
684 | { | 313 | { |
685 | // Shut down timers. Thread Context is Murky, lock all timers! | 314 | // Shut down timers. Thread Context is Murky, lock all timers! |
686 | if (m_clientPingTimer.Enabled) | ||
687 | lock (m_clientPingTimer) | ||
688 | m_clientPingTimer.Stop(); | ||
689 | |||
690 | if (m_avatarTerseUpdateTimer.Enabled) | 315 | if (m_avatarTerseUpdateTimer.Enabled) |
691 | lock (m_avatarTerseUpdateTimer) | 316 | lock (m_avatarTerseUpdateTimer) |
692 | m_avatarTerseUpdateTimer.Stop(); | 317 | m_avatarTerseUpdateTimer.Stop(); |
@@ -700,54 +325,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
700 | m_primFullUpdateTimer.Stop(); | 325 | m_primFullUpdateTimer.Stop(); |
701 | } | 326 | } |
702 | 327 | ||
703 | public void Restart() | 328 | #endregion Client Methods |
704 | { | ||
705 | // re-construct | ||
706 | m_PacketHandler.Clear(); | ||
707 | |||
708 | m_clientPingTimer = new Timer(5000); | ||
709 | m_clientPingTimer.Elapsed += CheckClientConnectivity; | ||
710 | m_clientPingTimer.Enabled = true; | ||
711 | |||
712 | m_avatarTerseUpdateTimer = new Timer(m_avatarTerseUpdateRate); | ||
713 | m_avatarTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessAvatarTerseUpdates); | ||
714 | m_avatarTerseUpdateTimer.AutoReset = false; | ||
715 | |||
716 | m_primTerseUpdateTimer = new Timer(m_primTerseUpdateRate); | ||
717 | m_primTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessPrimTerseUpdates); | ||
718 | m_primTerseUpdateTimer.AutoReset = false; | ||
719 | |||
720 | m_primFullUpdateTimer = new Timer(m_primFullUpdateRate); | ||
721 | m_primFullUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessPrimFullUpdates); | ||
722 | m_primFullUpdateTimer.AutoReset = false; | ||
723 | } | ||
724 | |||
725 | private void Terminate() | ||
726 | { | ||
727 | IsActive = false; | ||
728 | |||
729 | m_clientPingTimer.Close(); | ||
730 | m_avatarTerseUpdateTimer.Close(); | ||
731 | m_primTerseUpdateTimer.Close(); | ||
732 | m_primFullUpdateTimer.Close(); | ||
733 | |||
734 | m_PacketHandler.OnPacketStats -= PopulateStats; | ||
735 | m_PacketHandler.Dispose(); | ||
736 | |||
737 | // wait for thread stoped | ||
738 | // m_clientThread.Join(); | ||
739 | |||
740 | // delete circuit code | ||
741 | //m_networkServer.CloseClient(this); | ||
742 | } | ||
743 | |||
744 | #endregion | ||
745 | 329 | ||
746 | # region Packet Handling | 330 | #region Packet Handling |
747 | 331 | ||
748 | public void PopulateStats(int inPackets, int outPackets, int unAckedBytes) | 332 | public void PopulateStats(int inPackets, int outPackets, int unAckedBytes) |
749 | { | 333 | { |
750 | handlerNetworkStatsUpdate = OnNetworkStatsUpdate; | 334 | NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate; |
751 | if (handlerNetworkStatsUpdate != null) | 335 | if (handlerNetworkStatsUpdate != null) |
752 | { | 336 | { |
753 | handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes); | 337 | handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes); |
@@ -828,7 +412,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
828 | return result; | 412 | return result; |
829 | } | 413 | } |
830 | 414 | ||
831 | protected void DebugPacket(string direction, Packet packet) | 415 | /*protected void DebugPacket(string direction, Packet packet) |
832 | { | 416 | { |
833 | string info; | 417 | string info; |
834 | 418 | ||
@@ -854,88 +438,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
854 | } | 438 | } |
855 | 439 | ||
856 | Console.WriteLine(m_circuitCode + ":" + direction + ": " + info); | 440 | Console.WriteLine(m_circuitCode + ":" + direction + ": " + info); |
857 | } | 441 | }*/ |
858 | 442 | ||
859 | /// <summary> | 443 | #endregion Packet Handling |
860 | /// Main packet processing loop for the UDP component of the client session. Both incoming and outgoing | ||
861 | /// packets are processed here. | ||
862 | /// </summary> | ||
863 | protected virtual void ClientLoop() | ||
864 | { | ||
865 | m_log.DebugFormat( | ||
866 | "[CLIENT]: Entered main packet processing loop for {0} in {1}", Name, Scene.RegionInfo.RegionName); | ||
867 | |||
868 | while (IsActive) | ||
869 | { | ||
870 | LLQueItem nextPacket = m_PacketHandler.PacketQueue.Dequeue(); | ||
871 | |||
872 | if (nextPacket == null) { | ||
873 | m_log.DebugFormat("[CLIENT]: PacketQueue return null LLQueItem"); | ||
874 | continue; | ||
875 | } | ||
876 | |||
877 | if (nextPacket.Incoming) | ||
878 | { | ||
879 | if (m_debugPacketLevel > 0) | ||
880 | DebugPacket("IN", nextPacket.Packet); | ||
881 | m_PacketHandler.ProcessInPacket(nextPacket); | ||
882 | } | ||
883 | else | ||
884 | { | ||
885 | if (m_debugPacketLevel > 0) | ||
886 | DebugPacket("OUT", nextPacket.Packet); | ||
887 | m_PacketHandler.ProcessOutPacket(nextPacket); | ||
888 | } | ||
889 | } | ||
890 | } | ||
891 | |||
892 | # endregion | ||
893 | |||
894 | protected int m_terrainCheckerCount; | ||
895 | |||
896 | /// <summary> | ||
897 | /// Event handler for check client timer | ||
898 | /// Checks to ensure that the client is still connected. If the client has failed to respond to many pings | ||
899 | /// in succession then close down the connection. | ||
900 | /// </summary> | ||
901 | /// <param name="sender"></param> | ||
902 | /// <param name="e"></param> | ||
903 | protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) | ||
904 | { | ||
905 | if (m_PacketHandler.PacketsReceived == m_inPacketsChecked) | ||
906 | { | ||
907 | // no packet came in since the last time we checked... | ||
908 | |||
909 | m_probesWithNoIngressPackets++; | ||
910 | if ((m_probesWithNoIngressPackets > 30 && !m_clientBlocked) // agent active | ||
911 | || (m_probesWithNoIngressPackets > 90 && m_clientBlocked)) // agent paused | ||
912 | { | ||
913 | m_clientPingTimer.Enabled = false; | ||
914 | |||
915 | m_log.WarnFormat( | ||
916 | "[CLIENT]: Client for agent {0} {1} has stopped responding to pings. Closing connection", | ||
917 | Name, AgentId); | ||
918 | |||
919 | if (OnConnectionClosed != null) | ||
920 | { | ||
921 | OnConnectionClosed(this); | ||
922 | } | ||
923 | } | ||
924 | else | ||
925 | { | ||
926 | // this will normally trigger at least one packet (ping response) | ||
927 | SendStartPingCheck(0); | ||
928 | } | ||
929 | } | ||
930 | else | ||
931 | { | ||
932 | // Something received in the meantime - we can reset the counters | ||
933 | m_probesWithNoIngressPackets = 0; | ||
934 | // ... and store the current number of packets received to find out if another one got in on the next cycle | ||
935 | m_inPacketsChecked = m_PacketHandler.PacketsReceived; | ||
936 | } | ||
937 | |||
938 | } | ||
939 | 444 | ||
940 | # region Setup | 445 | # region Setup |
941 | 446 | ||
@@ -945,13 +450,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
945 | /// </summary> | 450 | /// </summary> |
946 | protected virtual void InitNewClient() | 451 | protected virtual void InitNewClient() |
947 | { | 452 | { |
948 | //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); | ||
949 | |||
950 | // Ping the client regularly to check that it's still there | ||
951 | m_clientPingTimer = new Timer(5000); | ||
952 | m_clientPingTimer.Elapsed += CheckClientConnectivity; | ||
953 | m_clientPingTimer.Enabled = true; | ||
954 | |||
955 | m_avatarTerseUpdateTimer = new Timer(m_avatarTerseUpdateRate); | 453 | m_avatarTerseUpdateTimer = new Timer(m_avatarTerseUpdateRate); |
956 | m_avatarTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessAvatarTerseUpdates); | 454 | m_avatarTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessAvatarTerseUpdates); |
957 | m_avatarTerseUpdateTimer.AutoReset = false; | 455 | m_avatarTerseUpdateTimer.AutoReset = false; |
@@ -971,27 +469,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
971 | 469 | ||
972 | public virtual void Start() | 470 | public virtual void Start() |
973 | { | 471 | { |
974 | m_clientThread = new Thread(RunUserSession); | 472 | // This sets up all the timers |
975 | m_clientThread.Name = "ClientThread"; | 473 | InitNewClient(); |
976 | m_clientThread.IsBackground = true; | ||
977 | m_clientThread.Start(); | ||
978 | ThreadTracker.Add(m_clientThread); | ||
979 | } | 474 | } |
980 | 475 | ||
981 | /// <summary> | 476 | /// <summary> |
982 | /// Run a user session. This method lies at the base of the entire client thread. | 477 | /// Run a user session. This method lies at the base of the entire client thread. |
983 | /// </summary> | 478 | /// </summary> |
984 | protected virtual void RunUserSession() | 479 | protected void RunUserSession() |
985 | { | 480 | { |
986 | //tell this thread we are using the culture set up for the sim (currently hardcoded to en_US) | ||
987 | //otherwise it will override this and use the system default | ||
988 | Culture.SetCurrentCulture(); | ||
989 | |||
990 | try | 481 | try |
991 | { | 482 | { |
992 | // This sets up all the timers | 483 | |
993 | InitNewClient(); | ||
994 | ClientLoop(); | ||
995 | } | 484 | } |
996 | catch (Exception e) | 485 | catch (Exception e) |
997 | { | 486 | { |
@@ -1015,11 +504,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1015 | + "Any further actions taken will not be processed.\n" | 504 | + "Any further actions taken will not be processed.\n" |
1016 | + "Please relog", true); | 505 | + "Please relog", true); |
1017 | 506 | ||
1018 | LLQueItem item = new LLQueItem(); | 507 | m_udpServer.SendPacket(m_agentId, packet, ThrottleOutPacketType.Unknown, false); |
1019 | item.Packet = packet; | ||
1020 | item.Sequence = packet.Header.Sequence; | ||
1021 | |||
1022 | m_PacketHandler.ProcessOutPacket(item); | ||
1023 | 508 | ||
1024 | // There may be a better way to do this. Perhaps kick? Not sure this propogates notifications to | 509 | // There may be a better way to do this. Perhaps kick? Not sure this propogates notifications to |
1025 | // listeners yet, though. | 510 | // listeners yet, though. |
@@ -1037,7 +522,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1037 | 522 | ||
1038 | # endregion | 523 | # endregion |
1039 | 524 | ||
1040 | // Previously ClientView.API partial class | 525 | #region Events |
526 | |||
1041 | public event GenericMessage OnGenericMessage; | 527 | public event GenericMessage OnGenericMessage; |
1042 | public event BinaryGenericMessage OnBinaryGenericMessage; | 528 | public event BinaryGenericMessage OnBinaryGenericMessage; |
1043 | public event Action<IClientAPI> OnLogout; | 529 | public event Action<IClientAPI> OnLogout; |
@@ -1197,13 +683,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1197 | public event GetScriptRunning OnGetScriptRunning; | 683 | public event GetScriptRunning OnGetScriptRunning; |
1198 | public event SetScriptRunning OnSetScriptRunning; | 684 | public event SetScriptRunning OnSetScriptRunning; |
1199 | public event UpdateVector OnAutoPilotGo; | 685 | public event UpdateVector OnAutoPilotGo; |
1200 | |||
1201 | public event TerrainUnacked OnUnackedTerrain; | 686 | public event TerrainUnacked OnUnackedTerrain; |
1202 | |||
1203 | public event ActivateGesture OnActivateGesture; | 687 | public event ActivateGesture OnActivateGesture; |
1204 | public event DeactivateGesture OnDeactivateGesture; | 688 | public event DeactivateGesture OnDeactivateGesture; |
1205 | public event ObjectOwner OnObjectOwner; | 689 | public event ObjectOwner OnObjectOwner; |
1206 | |||
1207 | public event DirPlacesQuery OnDirPlacesQuery; | 690 | public event DirPlacesQuery OnDirPlacesQuery; |
1208 | public event DirFindQuery OnDirFindQuery; | 691 | public event DirFindQuery OnDirFindQuery; |
1209 | public event DirLandQuery OnDirLandQuery; | 692 | public event DirLandQuery OnDirLandQuery; |
@@ -1211,45 +694,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1211 | public event DirClassifiedQuery OnDirClassifiedQuery; | 694 | public event DirClassifiedQuery OnDirClassifiedQuery; |
1212 | public event EventInfoRequest OnEventInfoRequest; | 695 | public event EventInfoRequest OnEventInfoRequest; |
1213 | public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime; | 696 | public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime; |
1214 | |||
1215 | public event MapItemRequest OnMapItemRequest; | 697 | public event MapItemRequest OnMapItemRequest; |
1216 | |||
1217 | public event OfferCallingCard OnOfferCallingCard; | 698 | public event OfferCallingCard OnOfferCallingCard; |
1218 | public event AcceptCallingCard OnAcceptCallingCard; | 699 | public event AcceptCallingCard OnAcceptCallingCard; |
1219 | public event DeclineCallingCard OnDeclineCallingCard; | 700 | public event DeclineCallingCard OnDeclineCallingCard; |
1220 | public event SoundTrigger OnSoundTrigger; | 701 | public event SoundTrigger OnSoundTrigger; |
1221 | |||
1222 | public event StartLure OnStartLure; | 702 | public event StartLure OnStartLure; |
1223 | public event TeleportLureRequest OnTeleportLureRequest; | 703 | public event TeleportLureRequest OnTeleportLureRequest; |
1224 | public event NetworkStats OnNetworkStatsUpdate; | 704 | public event NetworkStats OnNetworkStatsUpdate; |
1225 | |||
1226 | public event ClassifiedInfoRequest OnClassifiedInfoRequest; | 705 | public event ClassifiedInfoRequest OnClassifiedInfoRequest; |
1227 | public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; | 706 | public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; |
1228 | public event ClassifiedDelete OnClassifiedDelete; | 707 | public event ClassifiedDelete OnClassifiedDelete; |
1229 | public event ClassifiedDelete OnClassifiedGodDelete; | 708 | public event ClassifiedDelete OnClassifiedGodDelete; |
1230 | |||
1231 | public event EventNotificationAddRequest OnEventNotificationAddRequest; | 709 | public event EventNotificationAddRequest OnEventNotificationAddRequest; |
1232 | public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; | 710 | public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; |
1233 | public event EventGodDelete OnEventGodDelete; | 711 | public event EventGodDelete OnEventGodDelete; |
1234 | |||
1235 | public event ParcelDwellRequest OnParcelDwellRequest; | 712 | public event ParcelDwellRequest OnParcelDwellRequest; |
1236 | |||
1237 | public event UserInfoRequest OnUserInfoRequest; | 713 | public event UserInfoRequest OnUserInfoRequest; |
1238 | public event UpdateUserInfo OnUpdateUserInfo; | 714 | public event UpdateUserInfo OnUpdateUserInfo; |
1239 | |||
1240 | public event RetrieveInstantMessages OnRetrieveInstantMessages; | 715 | public event RetrieveInstantMessages OnRetrieveInstantMessages; |
1241 | |||
1242 | public event PickDelete OnPickDelete; | 716 | public event PickDelete OnPickDelete; |
1243 | public event PickGodDelete OnPickGodDelete; | 717 | public event PickGodDelete OnPickGodDelete; |
1244 | public event PickInfoUpdate OnPickInfoUpdate; | 718 | public event PickInfoUpdate OnPickInfoUpdate; |
1245 | public event AvatarNotesUpdate OnAvatarNotesUpdate; | 719 | public event AvatarNotesUpdate OnAvatarNotesUpdate; |
1246 | |||
1247 | public event MuteListRequest OnMuteListRequest; | 720 | public event MuteListRequest OnMuteListRequest; |
1248 | 721 | public event AvatarInterestUpdate OnAvatarInterestUpdate; | |
1249 | //public event AvatarInterestUpdate OnAvatarInterestUpdate; | ||
1250 | |||
1251 | public event PlacesQuery OnPlacesQuery; | 722 | public event PlacesQuery OnPlacesQuery; |
1252 | 723 | ||
724 | #endregion Events | ||
725 | |||
1253 | public void ActivateGesture(UUID assetId, UUID gestureId) | 726 | public void ActivateGesture(UUID assetId, UUID gestureId) |
1254 | { | 727 | { |
1255 | } | 728 | } |
@@ -1850,8 +1323,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1850 | public void SendStartPingCheck(byte seq) | 1323 | public void SendStartPingCheck(byte seq) |
1851 | { | 1324 | { |
1852 | StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck); | 1325 | StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck); |
1853 | pc.PingID.PingID = seq; | ||
1854 | pc.Header.Reliable = false; | 1326 | pc.Header.Reliable = false; |
1327 | |||
1328 | OutgoingPacket oldestPacket = m_udpClient.NeedAcks.GetOldest(); | ||
1329 | |||
1330 | pc.PingID.PingID = seq; | ||
1331 | pc.PingID.OldestUnacked = (oldestPacket != null) ? oldestPacket.SequenceNumber : 0; | ||
1332 | |||
1855 | OutPacket(pc, ThrottleOutPacketType.Unknown); | 1333 | OutPacket(pc, ThrottleOutPacketType.Unknown); |
1856 | } | 1334 | } |
1857 | 1335 | ||
@@ -1927,12 +1405,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1927 | descend.ItemData[i].AssetID = item.AssetID; | 1405 | descend.ItemData[i].AssetID = item.AssetID; |
1928 | descend.ItemData[i].CreatorID = item.CreatorIdAsUuid; | 1406 | descend.ItemData[i].CreatorID = item.CreatorIdAsUuid; |
1929 | descend.ItemData[i].BaseMask = item.BasePermissions; | 1407 | descend.ItemData[i].BaseMask = item.BasePermissions; |
1930 | descend.ItemData[i].Description = LLUtil.StringToPacketBytes(item.Description); | 1408 | descend.ItemData[i].Description = Util.StringToBytes256(item.Description); |
1931 | descend.ItemData[i].EveryoneMask = item.EveryOnePermissions; | 1409 | descend.ItemData[i].EveryoneMask = item.EveryOnePermissions; |
1932 | descend.ItemData[i].OwnerMask = item.CurrentPermissions; | 1410 | descend.ItemData[i].OwnerMask = item.CurrentPermissions; |
1933 | descend.ItemData[i].FolderID = item.Folder; | 1411 | descend.ItemData[i].FolderID = item.Folder; |
1934 | descend.ItemData[i].InvType = (sbyte)item.InvType; | 1412 | descend.ItemData[i].InvType = (sbyte)item.InvType; |
1935 | descend.ItemData[i].Name = LLUtil.StringToPacketBytes(item.Name); | 1413 | descend.ItemData[i].Name = Util.StringToBytes256(item.Name); |
1936 | descend.ItemData[i].NextOwnerMask = item.NextPermissions; | 1414 | descend.ItemData[i].NextOwnerMask = item.NextPermissions; |
1937 | descend.ItemData[i].OwnerID = item.Owner; | 1415 | descend.ItemData[i].OwnerID = item.Owner; |
1938 | descend.ItemData[i].Type = (sbyte)item.AssetType; | 1416 | descend.ItemData[i].Type = (sbyte)item.AssetType; |
@@ -2013,7 +1491,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2013 | { | 1491 | { |
2014 | descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); | 1492 | descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); |
2015 | descend.FolderData[i].FolderID = folder.ID; | 1493 | descend.FolderData[i].FolderID = folder.ID; |
2016 | descend.FolderData[i].Name = LLUtil.StringToPacketBytes(folder.Name); | 1494 | descend.FolderData[i].Name = Util.StringToBytes256(folder.Name); |
2017 | descend.FolderData[i].ParentID = folder.ParentID; | 1495 | descend.FolderData[i].ParentID = folder.ParentID; |
2018 | descend.FolderData[i].Type = (sbyte)folder.Type; | 1496 | descend.FolderData[i].Type = (sbyte)folder.Type; |
2019 | 1497 | ||
@@ -2128,11 +1606,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2128 | inventoryReply.InventoryData[0].BaseMask = item.BasePermissions; | 1606 | inventoryReply.InventoryData[0].BaseMask = item.BasePermissions; |
2129 | inventoryReply.InventoryData[0].CreationDate = item.CreationDate; | 1607 | inventoryReply.InventoryData[0].CreationDate = item.CreationDate; |
2130 | 1608 | ||
2131 | inventoryReply.InventoryData[0].Description = LLUtil.StringToPacketBytes(item.Description); | 1609 | inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description); |
2132 | inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions; | 1610 | inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions; |
2133 | inventoryReply.InventoryData[0].FolderID = item.Folder; | 1611 | inventoryReply.InventoryData[0].FolderID = item.Folder; |
2134 | inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType; | 1612 | inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType; |
2135 | inventoryReply.InventoryData[0].Name = LLUtil.StringToPacketBytes(item.Name); | 1613 | inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name); |
2136 | inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions; | 1614 | inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions; |
2137 | inventoryReply.InventoryData[0].OwnerID = item.Owner; | 1615 | inventoryReply.InventoryData[0].OwnerID = item.Owner; |
2138 | inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions; | 1616 | inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions; |
@@ -2257,7 +1735,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2257 | folderBlock.FolderID = folder.ID; | 1735 | folderBlock.FolderID = folder.ID; |
2258 | folderBlock.ParentID = folder.ParentID; | 1736 | folderBlock.ParentID = folder.ParentID; |
2259 | folderBlock.Type = -1; | 1737 | folderBlock.Type = -1; |
2260 | folderBlock.Name = LLUtil.StringToPacketBytes(folder.Name); | 1738 | folderBlock.Name = Util.StringToBytes256(folder.Name); |
2261 | 1739 | ||
2262 | return folderBlock; | 1740 | return folderBlock; |
2263 | } | 1741 | } |
@@ -2275,11 +1753,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2275 | itemBlock.AssetID = item.AssetID; | 1753 | itemBlock.AssetID = item.AssetID; |
2276 | itemBlock.CreatorID = item.CreatorIdAsUuid; | 1754 | itemBlock.CreatorID = item.CreatorIdAsUuid; |
2277 | itemBlock.BaseMask = item.BasePermissions; | 1755 | itemBlock.BaseMask = item.BasePermissions; |
2278 | itemBlock.Description = LLUtil.StringToPacketBytes(item.Description); | 1756 | itemBlock.Description = Util.StringToBytes256(item.Description); |
2279 | itemBlock.EveryoneMask = item.EveryOnePermissions; | 1757 | itemBlock.EveryoneMask = item.EveryOnePermissions; |
2280 | itemBlock.FolderID = item.Folder; | 1758 | itemBlock.FolderID = item.Folder; |
2281 | itemBlock.InvType = (sbyte)item.InvType; | 1759 | itemBlock.InvType = (sbyte)item.InvType; |
2282 | itemBlock.Name = LLUtil.StringToPacketBytes(item.Name); | 1760 | itemBlock.Name = Util.StringToBytes256(item.Name); |
2283 | itemBlock.NextOwnerMask = item.NextPermissions; | 1761 | itemBlock.NextOwnerMask = item.NextPermissions; |
2284 | itemBlock.OwnerID = item.Owner; | 1762 | itemBlock.OwnerID = item.Owner; |
2285 | itemBlock.OwnerMask = item.CurrentPermissions; | 1763 | itemBlock.OwnerMask = item.CurrentPermissions; |
@@ -2339,11 +1817,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2339 | bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid; | 1817 | bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid; |
2340 | bulkUpdate.ItemData[0].BaseMask = item.BasePermissions; | 1818 | bulkUpdate.ItemData[0].BaseMask = item.BasePermissions; |
2341 | bulkUpdate.ItemData[0].CreationDate = item.CreationDate; | 1819 | bulkUpdate.ItemData[0].CreationDate = item.CreationDate; |
2342 | bulkUpdate.ItemData[0].Description = LLUtil.StringToPacketBytes(item.Description); | 1820 | bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description); |
2343 | bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions; | 1821 | bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions; |
2344 | bulkUpdate.ItemData[0].FolderID = item.Folder; | 1822 | bulkUpdate.ItemData[0].FolderID = item.Folder; |
2345 | bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType; | 1823 | bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType; |
2346 | bulkUpdate.ItemData[0].Name = LLUtil.StringToPacketBytes(item.Name); | 1824 | bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name); |
2347 | bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions; | 1825 | bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions; |
2348 | bulkUpdate.ItemData[0].OwnerID = item.Owner; | 1826 | bulkUpdate.ItemData[0].OwnerID = item.Owner; |
2349 | bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions; | 1827 | bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions; |
@@ -2386,11 +1864,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2386 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; | 1864 | InventoryReply.InventoryData[0].AssetID = Item.AssetID; |
2387 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid; | 1865 | InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid; |
2388 | InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions; | 1866 | InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions; |
2389 | InventoryReply.InventoryData[0].Description = LLUtil.StringToPacketBytes(Item.Description); | 1867 | InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description); |
2390 | InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions; | 1868 | InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions; |
2391 | InventoryReply.InventoryData[0].FolderID = Item.Folder; | 1869 | InventoryReply.InventoryData[0].FolderID = Item.Folder; |
2392 | InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType; | 1870 | InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType; |
2393 | InventoryReply.InventoryData[0].Name = LLUtil.StringToPacketBytes(Item.Name); | 1871 | InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name); |
2394 | InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions; | 1872 | InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions; |
2395 | InventoryReply.InventoryData[0].OwnerID = Item.Owner; | 1873 | InventoryReply.InventoryData[0].OwnerID = Item.Owner; |
2396 | InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions; | 1874 | InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions; |
@@ -2557,7 +2035,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2557 | /// <param name="message"></param> | 2035 | /// <param name="message"></param> |
2558 | /// <param name="modal"></param> | 2036 | /// <param name="modal"></param> |
2559 | /// <returns></returns> | 2037 | /// <returns></returns> |
2560 | protected AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal) | 2038 | public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal) |
2561 | { | 2039 | { |
2562 | AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage); | 2040 | AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage); |
2563 | alertPack.AgentData.AgentID = AgentId; | 2041 | alertPack.AgentData.AgentID = AgentId; |
@@ -2768,7 +2246,953 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2768 | OutPacket(avatarReply, ThrottleOutPacketType.Task); | 2246 | OutPacket(avatarReply, ThrottleOutPacketType.Task); |
2769 | } | 2247 | } |
2770 | 2248 | ||
2771 | #endregion | 2249 | /// <summary> |
2250 | /// Send the client an Estate message blue box pop-down with a single OK button | ||
2251 | /// </summary> | ||
2252 | /// <param name="FromAvatarID"></param> | ||
2253 | /// <param name="fromSessionID"></param> | ||
2254 | /// <param name="FromAvatarName"></param> | ||
2255 | /// <param name="Message"></param> | ||
2256 | public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message) | ||
2257 | { | ||
2258 | if (!ChildAgentStatus()) | ||
2259 | SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3())); | ||
2260 | |||
2261 | //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch()); | ||
2262 | } | ||
2263 | |||
2264 | public void SendLogoutPacket() | ||
2265 | { | ||
2266 | // I know this is a bit of a hack, however there are times when you don't | ||
2267 | // want to send this, but still need to do the rest of the shutdown process | ||
2268 | // this method gets called from the packet server.. which makes it practically | ||
2269 | // impossible to do any other way. | ||
2270 | |||
2271 | if (m_SendLogoutPacketWhenClosing) | ||
2272 | { | ||
2273 | LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); | ||
2274 | // TODO: don't create new blocks if recycling an old packet | ||
2275 | logReply.AgentData.AgentID = AgentId; | ||
2276 | logReply.AgentData.SessionID = SessionId; | ||
2277 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | ||
2278 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | ||
2279 | logReply.InventoryData[0].ItemID = UUID.Zero; | ||
2280 | |||
2281 | OutPacket(logReply, ThrottleOutPacketType.Task); | ||
2282 | } | ||
2283 | } | ||
2284 | |||
2285 | public void SendHealth(float health) | ||
2286 | { | ||
2287 | HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage); | ||
2288 | healthpacket.HealthData.Health = health; | ||
2289 | OutPacket(healthpacket, ThrottleOutPacketType.Task); | ||
2290 | } | ||
2291 | |||
2292 | public void SendAgentOnline(UUID[] agentIDs) | ||
2293 | { | ||
2294 | OnlineNotificationPacket onp = new OnlineNotificationPacket(); | ||
2295 | OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length]; | ||
2296 | for (int i = 0; i < agentIDs.Length; i++) | ||
2297 | { | ||
2298 | OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock(); | ||
2299 | onpbl.AgentID = agentIDs[i]; | ||
2300 | onpb[i] = onpbl; | ||
2301 | } | ||
2302 | onp.AgentBlock = onpb; | ||
2303 | onp.Header.Reliable = true; | ||
2304 | OutPacket(onp, ThrottleOutPacketType.Task); | ||
2305 | } | ||
2306 | |||
2307 | public void SendAgentOffline(UUID[] agentIDs) | ||
2308 | { | ||
2309 | OfflineNotificationPacket offp = new OfflineNotificationPacket(); | ||
2310 | OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length]; | ||
2311 | for (int i = 0; i < agentIDs.Length; i++) | ||
2312 | { | ||
2313 | OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock(); | ||
2314 | onpbl.AgentID = agentIDs[i]; | ||
2315 | offpb[i] = onpbl; | ||
2316 | } | ||
2317 | offp.AgentBlock = offpb; | ||
2318 | offp.Header.Reliable = true; | ||
2319 | OutPacket(offp, ThrottleOutPacketType.Task); | ||
2320 | } | ||
2321 | |||
2322 | public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, | ||
2323 | Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) | ||
2324 | { | ||
2325 | AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); | ||
2326 | avatarSitResponse.SitObject.ID = TargetID; | ||
2327 | if (CameraAtOffset != Vector3.Zero) | ||
2328 | { | ||
2329 | avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset; | ||
2330 | avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset; | ||
2331 | } | ||
2332 | avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook; | ||
2333 | avatarSitResponse.SitTransform.AutoPilot = autopilot; | ||
2334 | avatarSitResponse.SitTransform.SitPosition = OffsetPos; | ||
2335 | avatarSitResponse.SitTransform.SitRotation = SitOrientation; | ||
2336 | |||
2337 | OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); | ||
2338 | } | ||
2339 | |||
2340 | public void SendAdminResponse(UUID Token, uint AdminLevel) | ||
2341 | { | ||
2342 | GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); | ||
2343 | GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock(); | ||
2344 | GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock(); | ||
2345 | |||
2346 | adb.AgentID = AgentId; | ||
2347 | adb.SessionID = SessionId; // More security | ||
2348 | gdb.GodLevel = (byte)AdminLevel; | ||
2349 | gdb.Token = Token; | ||
2350 | //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; | ||
2351 | respondPacket.GrantData = gdb; | ||
2352 | respondPacket.AgentData = adb; | ||
2353 | OutPacket(respondPacket, ThrottleOutPacketType.Task); | ||
2354 | } | ||
2355 | |||
2356 | public void SendGroupMembership(GroupMembershipData[] GroupMembership) | ||
2357 | { | ||
2358 | m_groupPowers.Clear(); | ||
2359 | |||
2360 | AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket(); | ||
2361 | AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length]; | ||
2362 | for (int i = 0; i < GroupMembership.Length; i++) | ||
2363 | { | ||
2364 | m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; | ||
2365 | |||
2366 | AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); | ||
2367 | Group.AcceptNotices = GroupMembership[i].AcceptNotices; | ||
2368 | Group.Contribution = GroupMembership[i].Contribution; | ||
2369 | Group.GroupID = GroupMembership[i].GroupID; | ||
2370 | Group.GroupInsigniaID = GroupMembership[i].GroupPicture; | ||
2371 | Group.GroupName = Utils.StringToBytes(GroupMembership[i].GroupName); | ||
2372 | Group.GroupPowers = GroupMembership[i].GroupPowers; | ||
2373 | Groups[i] = Group; | ||
2374 | |||
2375 | |||
2376 | } | ||
2377 | Groupupdate.GroupData = Groups; | ||
2378 | Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock(); | ||
2379 | Groupupdate.AgentData.AgentID = AgentId; | ||
2380 | OutPacket(Groupupdate, ThrottleOutPacketType.Task); | ||
2381 | |||
2382 | try | ||
2383 | { | ||
2384 | IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>(); | ||
2385 | if (eq != null) | ||
2386 | { | ||
2387 | eq.GroupMembership(Groupupdate, this.AgentId); | ||
2388 | } | ||
2389 | } | ||
2390 | catch (Exception ex) | ||
2391 | { | ||
2392 | m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString()); | ||
2393 | m_log.Warn("sending group membership data via UDP"); | ||
2394 | OutPacket(Groupupdate, ThrottleOutPacketType.Task); | ||
2395 | } | ||
2396 | } | ||
2397 | |||
2398 | |||
2399 | public void SendGroupNameReply(UUID groupLLUID, string GroupName) | ||
2400 | { | ||
2401 | UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket(); | ||
2402 | UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1]; | ||
2403 | UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock(); | ||
2404 | uidnamebloc.ID = groupLLUID; | ||
2405 | uidnamebloc.GroupName = Utils.StringToBytes(GroupName); | ||
2406 | uidnameblock[0] = uidnamebloc; | ||
2407 | pack.UUIDNameBlock = uidnameblock; | ||
2408 | OutPacket(pack, ThrottleOutPacketType.Task); | ||
2409 | } | ||
2410 | |||
2411 | public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) | ||
2412 | { | ||
2413 | LandStatReplyPacket lsrp = new LandStatReplyPacket(); | ||
2414 | // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock(); | ||
2415 | LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length]; | ||
2416 | //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); | ||
2417 | // lsrepdb. | ||
2418 | lsrp.RequestData.ReportType = reportType; | ||
2419 | lsrp.RequestData.RequestFlags = requestFlags; | ||
2420 | lsrp.RequestData.TotalObjectCount = resultCount; | ||
2421 | for (int i = 0; i < lsrpia.Length; i++) | ||
2422 | { | ||
2423 | LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); | ||
2424 | lsrepdb.LocationX = lsrpia[i].LocationX; | ||
2425 | lsrepdb.LocationY = lsrpia[i].LocationY; | ||
2426 | lsrepdb.LocationZ = lsrpia[i].LocationZ; | ||
2427 | lsrepdb.Score = lsrpia[i].Score; | ||
2428 | lsrepdb.TaskID = lsrpia[i].TaskID; | ||
2429 | lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID; | ||
2430 | lsrepdb.TaskName = Utils.StringToBytes(lsrpia[i].TaskName); | ||
2431 | lsrepdb.OwnerName = Utils.StringToBytes(lsrpia[i].OwnerName); | ||
2432 | lsrepdba[i] = lsrepdb; | ||
2433 | } | ||
2434 | lsrp.ReportData = lsrepdba; | ||
2435 | OutPacket(lsrp, ThrottleOutPacketType.Task); | ||
2436 | } | ||
2437 | |||
2438 | public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running) | ||
2439 | { | ||
2440 | ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket(); | ||
2441 | scriptRunningReply.Script.ObjectID = objectID; | ||
2442 | scriptRunningReply.Script.ItemID = itemID; | ||
2443 | scriptRunningReply.Script.Running = running; | ||
2444 | |||
2445 | OutPacket(scriptRunningReply, ThrottleOutPacketType.Task); | ||
2446 | } | ||
2447 | |||
2448 | public void SendAsset(AssetRequestToClient req) | ||
2449 | { | ||
2450 | //m_log.Debug("sending asset " + req.RequestAssetID); | ||
2451 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
2452 | Transfer.TransferInfo.ChannelType = 2; | ||
2453 | Transfer.TransferInfo.Status = 0; | ||
2454 | Transfer.TransferInfo.TargetType = 0; | ||
2455 | if (req.AssetRequestSource == 2) | ||
2456 | { | ||
2457 | Transfer.TransferInfo.Params = new byte[20]; | ||
2458 | Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | ||
2459 | int assType = req.AssetInf.Type; | ||
2460 | Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); | ||
2461 | } | ||
2462 | else if (req.AssetRequestSource == 3) | ||
2463 | { | ||
2464 | Transfer.TransferInfo.Params = req.Params; | ||
2465 | // Transfer.TransferInfo.Params = new byte[100]; | ||
2466 | //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | ||
2467 | //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); | ||
2468 | } | ||
2469 | Transfer.TransferInfo.Size = req.AssetInf.Data.Length; | ||
2470 | Transfer.TransferInfo.TransferID = req.TransferRequestID; | ||
2471 | Transfer.Header.Zerocoded = true; | ||
2472 | OutPacket(Transfer, ThrottleOutPacketType.Asset); | ||
2473 | |||
2474 | if (req.NumPackets == 1) | ||
2475 | { | ||
2476 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
2477 | TransferPacket.TransferData.Packet = 0; | ||
2478 | TransferPacket.TransferData.ChannelType = 2; | ||
2479 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
2480 | TransferPacket.TransferData.Data = req.AssetInf.Data; | ||
2481 | TransferPacket.TransferData.Status = 1; | ||
2482 | TransferPacket.Header.Zerocoded = true; | ||
2483 | OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | ||
2484 | } | ||
2485 | else | ||
2486 | { | ||
2487 | int processedLength = 0; | ||
2488 | int maxChunkSize = Settings.MAX_PACKET_SIZE - 100; | ||
2489 | int packetNumber = 0; | ||
2490 | |||
2491 | while (processedLength < req.AssetInf.Data.Length) | ||
2492 | { | ||
2493 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
2494 | TransferPacket.TransferData.Packet = packetNumber; | ||
2495 | TransferPacket.TransferData.ChannelType = 2; | ||
2496 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
2497 | |||
2498 | int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); | ||
2499 | byte[] chunk = new byte[chunkSize]; | ||
2500 | Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); | ||
2501 | |||
2502 | TransferPacket.TransferData.Data = chunk; | ||
2503 | |||
2504 | // 0 indicates more packets to come, 1 indicates last packet | ||
2505 | if (req.AssetInf.Data.Length - processedLength > maxChunkSize) | ||
2506 | { | ||
2507 | TransferPacket.TransferData.Status = 0; | ||
2508 | } | ||
2509 | else | ||
2510 | { | ||
2511 | TransferPacket.TransferData.Status = 1; | ||
2512 | } | ||
2513 | TransferPacket.Header.Zerocoded = true; | ||
2514 | OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | ||
2515 | |||
2516 | processedLength += chunkSize; | ||
2517 | packetNumber++; | ||
2518 | } | ||
2519 | } | ||
2520 | } | ||
2521 | |||
2522 | public void SendTexture(AssetBase TextureAsset) | ||
2523 | { | ||
2524 | |||
2525 | } | ||
2526 | |||
2527 | public void SendRegionHandle(UUID regionID, ulong handle) | ||
2528 | { | ||
2529 | RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply); | ||
2530 | reply.ReplyBlock.RegionID = regionID; | ||
2531 | reply.ReplyBlock.RegionHandle = handle; | ||
2532 | OutPacket(reply, ThrottleOutPacketType.Land); | ||
2533 | } | ||
2534 | |||
2535 | public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y) | ||
2536 | { | ||
2537 | ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply); | ||
2538 | reply.AgentData.AgentID = m_agentId; | ||
2539 | reply.Data.ParcelID = parcelID; | ||
2540 | reply.Data.OwnerID = land.OwnerID; | ||
2541 | reply.Data.Name = Utils.StringToBytes(land.Name); | ||
2542 | reply.Data.Desc = Utils.StringToBytes(land.Description); | ||
2543 | reply.Data.ActualArea = land.Area; | ||
2544 | reply.Data.BillableArea = land.Area; // TODO: what is this? | ||
2545 | |||
2546 | // Bit 0: Mature, bit 7: on sale, other bits: no idea | ||
2547 | reply.Data.Flags = (byte)( | ||
2548 | ((land.Flags & (uint)ParcelFlags.MaturePublish) != 0 ? (1 << 0) : 0) + | ||
2549 | ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0)); | ||
2550 | |||
2551 | Vector3 pos = land.UserLocation; | ||
2552 | if (pos.Equals(Vector3.Zero)) | ||
2553 | { | ||
2554 | pos = (land.AABBMax + land.AABBMin) * 0.5f; | ||
2555 | } | ||
2556 | reply.Data.GlobalX = info.RegionLocX * Constants.RegionSize + x; | ||
2557 | reply.Data.GlobalY = info.RegionLocY * Constants.RegionSize + y; | ||
2558 | reply.Data.GlobalZ = pos.Z; | ||
2559 | reply.Data.SimName = Utils.StringToBytes(info.RegionName); | ||
2560 | reply.Data.SnapshotID = land.SnapshotID; | ||
2561 | reply.Data.Dwell = land.Dwell; | ||
2562 | reply.Data.SalePrice = land.SalePrice; | ||
2563 | reply.Data.AuctionID = (int)land.AuctionID; | ||
2564 | |||
2565 | OutPacket(reply, ThrottleOutPacketType.Land); | ||
2566 | } | ||
2567 | |||
2568 | public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt) | ||
2569 | { | ||
2570 | ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest); | ||
2571 | |||
2572 | packet.Data.ObjectName = Utils.StringToBytes(objName); | ||
2573 | packet.Data.SimName = Utils.StringToBytes(simName); | ||
2574 | packet.Data.SimPosition = pos; | ||
2575 | packet.Data.LookAt = lookAt; | ||
2576 | |||
2577 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2578 | } | ||
2579 | |||
2580 | public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data) | ||
2581 | { | ||
2582 | DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply); | ||
2583 | |||
2584 | packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock(); | ||
2585 | |||
2586 | packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1]; | ||
2587 | packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock(); | ||
2588 | |||
2589 | packet.QueryReplies = | ||
2590 | new DirPlacesReplyPacket.QueryRepliesBlock[data.Length]; | ||
2591 | |||
2592 | packet.StatusData = new DirPlacesReplyPacket.StatusDataBlock[ | ||
2593 | data.Length]; | ||
2594 | |||
2595 | packet.AgentData.AgentID = AgentId; | ||
2596 | |||
2597 | packet.QueryData[0].QueryID = queryID; | ||
2598 | |||
2599 | int i = 0; | ||
2600 | foreach (DirPlacesReplyData d in data) | ||
2601 | { | ||
2602 | packet.QueryReplies[i] = | ||
2603 | new DirPlacesReplyPacket.QueryRepliesBlock(); | ||
2604 | packet.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock(); | ||
2605 | packet.QueryReplies[i].ParcelID = d.parcelID; | ||
2606 | packet.QueryReplies[i].Name = Utils.StringToBytes(d.name); | ||
2607 | packet.QueryReplies[i].ForSale = d.forSale; | ||
2608 | packet.QueryReplies[i].Auction = d.auction; | ||
2609 | packet.QueryReplies[i].Dwell = d.dwell; | ||
2610 | packet.StatusData[i].Status = d.Status; | ||
2611 | i++; | ||
2612 | } | ||
2613 | |||
2614 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2615 | } | ||
2616 | |||
2617 | public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data) | ||
2618 | { | ||
2619 | DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply); | ||
2620 | |||
2621 | packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock(); | ||
2622 | packet.AgentData.AgentID = AgentId; | ||
2623 | |||
2624 | packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock(); | ||
2625 | packet.QueryData.QueryID = queryID; | ||
2626 | |||
2627 | packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[ | ||
2628 | data.Length]; | ||
2629 | |||
2630 | int i = 0; | ||
2631 | foreach (DirPeopleReplyData d in data) | ||
2632 | { | ||
2633 | packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock(); | ||
2634 | packet.QueryReplies[i].AgentID = d.agentID; | ||
2635 | packet.QueryReplies[i].FirstName = | ||
2636 | Utils.StringToBytes(d.firstName); | ||
2637 | packet.QueryReplies[i].LastName = | ||
2638 | Utils.StringToBytes(d.lastName); | ||
2639 | packet.QueryReplies[i].Group = | ||
2640 | Utils.StringToBytes(d.group); | ||
2641 | packet.QueryReplies[i].Online = d.online; | ||
2642 | packet.QueryReplies[i].Reputation = d.reputation; | ||
2643 | i++; | ||
2644 | } | ||
2645 | |||
2646 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2647 | } | ||
2648 | |||
2649 | public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data) | ||
2650 | { | ||
2651 | DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply); | ||
2652 | |||
2653 | packet.AgentData = new DirEventsReplyPacket.AgentDataBlock(); | ||
2654 | packet.AgentData.AgentID = AgentId; | ||
2655 | |||
2656 | packet.QueryData = new DirEventsReplyPacket.QueryDataBlock(); | ||
2657 | packet.QueryData.QueryID = queryID; | ||
2658 | |||
2659 | packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[ | ||
2660 | data.Length]; | ||
2661 | |||
2662 | packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[ | ||
2663 | data.Length]; | ||
2664 | |||
2665 | int i = 0; | ||
2666 | foreach (DirEventsReplyData d in data) | ||
2667 | { | ||
2668 | packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock(); | ||
2669 | packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock(); | ||
2670 | packet.QueryReplies[i].OwnerID = d.ownerID; | ||
2671 | packet.QueryReplies[i].Name = | ||
2672 | Utils.StringToBytes(d.name); | ||
2673 | packet.QueryReplies[i].EventID = d.eventID; | ||
2674 | packet.QueryReplies[i].Date = | ||
2675 | Utils.StringToBytes(d.date); | ||
2676 | packet.QueryReplies[i].UnixTime = d.unixTime; | ||
2677 | packet.QueryReplies[i].EventFlags = d.eventFlags; | ||
2678 | packet.StatusData[i].Status = d.Status; | ||
2679 | i++; | ||
2680 | } | ||
2681 | |||
2682 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2683 | } | ||
2684 | |||
2685 | public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data) | ||
2686 | { | ||
2687 | DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply); | ||
2688 | |||
2689 | packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock(); | ||
2690 | packet.AgentData.AgentID = AgentId; | ||
2691 | |||
2692 | packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock(); | ||
2693 | packet.QueryData.QueryID = queryID; | ||
2694 | |||
2695 | packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[ | ||
2696 | data.Length]; | ||
2697 | |||
2698 | int i = 0; | ||
2699 | foreach (DirGroupsReplyData d in data) | ||
2700 | { | ||
2701 | packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock(); | ||
2702 | packet.QueryReplies[i].GroupID = d.groupID; | ||
2703 | packet.QueryReplies[i].GroupName = | ||
2704 | Utils.StringToBytes(d.groupName); | ||
2705 | packet.QueryReplies[i].Members = d.members; | ||
2706 | packet.QueryReplies[i].SearchOrder = d.searchOrder; | ||
2707 | i++; | ||
2708 | } | ||
2709 | |||
2710 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2711 | } | ||
2712 | |||
2713 | public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data) | ||
2714 | { | ||
2715 | DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply); | ||
2716 | |||
2717 | packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock(); | ||
2718 | packet.AgentData.AgentID = AgentId; | ||
2719 | |||
2720 | packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock(); | ||
2721 | packet.QueryData.QueryID = queryID; | ||
2722 | |||
2723 | packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[ | ||
2724 | data.Length]; | ||
2725 | packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[ | ||
2726 | data.Length]; | ||
2727 | |||
2728 | int i = 0; | ||
2729 | foreach (DirClassifiedReplyData d in data) | ||
2730 | { | ||
2731 | packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock(); | ||
2732 | packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock(); | ||
2733 | packet.QueryReplies[i].ClassifiedID = d.classifiedID; | ||
2734 | packet.QueryReplies[i].Name = | ||
2735 | Utils.StringToBytes(d.name); | ||
2736 | packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags; | ||
2737 | packet.QueryReplies[i].CreationDate = d.creationDate; | ||
2738 | packet.QueryReplies[i].ExpirationDate = d.expirationDate; | ||
2739 | packet.QueryReplies[i].PriceForListing = d.price; | ||
2740 | packet.StatusData[i].Status = d.Status; | ||
2741 | i++; | ||
2742 | } | ||
2743 | |||
2744 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2745 | } | ||
2746 | |||
2747 | public void SendDirLandReply(UUID queryID, DirLandReplyData[] data) | ||
2748 | { | ||
2749 | DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply); | ||
2750 | |||
2751 | packet.AgentData = new DirLandReplyPacket.AgentDataBlock(); | ||
2752 | packet.AgentData.AgentID = AgentId; | ||
2753 | |||
2754 | packet.QueryData = new DirLandReplyPacket.QueryDataBlock(); | ||
2755 | packet.QueryData.QueryID = queryID; | ||
2756 | |||
2757 | packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[ | ||
2758 | data.Length]; | ||
2759 | |||
2760 | int i = 0; | ||
2761 | foreach (DirLandReplyData d in data) | ||
2762 | { | ||
2763 | packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock(); | ||
2764 | packet.QueryReplies[i].ParcelID = d.parcelID; | ||
2765 | packet.QueryReplies[i].Name = | ||
2766 | Utils.StringToBytes(d.name); | ||
2767 | packet.QueryReplies[i].Auction = d.auction; | ||
2768 | packet.QueryReplies[i].ForSale = d.forSale; | ||
2769 | packet.QueryReplies[i].SalePrice = d.salePrice; | ||
2770 | packet.QueryReplies[i].ActualArea = d.actualArea; | ||
2771 | i++; | ||
2772 | } | ||
2773 | |||
2774 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2775 | } | ||
2776 | |||
2777 | public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data) | ||
2778 | { | ||
2779 | DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply); | ||
2780 | |||
2781 | packet.AgentData = new DirPopularReplyPacket.AgentDataBlock(); | ||
2782 | packet.AgentData.AgentID = AgentId; | ||
2783 | |||
2784 | packet.QueryData = new DirPopularReplyPacket.QueryDataBlock(); | ||
2785 | packet.QueryData.QueryID = queryID; | ||
2786 | |||
2787 | packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[ | ||
2788 | data.Length]; | ||
2789 | |||
2790 | int i = 0; | ||
2791 | foreach (DirPopularReplyData d in data) | ||
2792 | { | ||
2793 | packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock(); | ||
2794 | packet.QueryReplies[i].ParcelID = d.parcelID; | ||
2795 | packet.QueryReplies[i].Name = | ||
2796 | Utils.StringToBytes(d.name); | ||
2797 | packet.QueryReplies[i].Dwell = d.dwell; | ||
2798 | i++; | ||
2799 | } | ||
2800 | |||
2801 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2802 | } | ||
2803 | |||
2804 | public void SendEventInfoReply(EventData data) | ||
2805 | { | ||
2806 | EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply); | ||
2807 | |||
2808 | packet.AgentData = new EventInfoReplyPacket.AgentDataBlock(); | ||
2809 | packet.AgentData.AgentID = AgentId; | ||
2810 | |||
2811 | packet.EventData = new EventInfoReplyPacket.EventDataBlock(); | ||
2812 | packet.EventData.EventID = data.eventID; | ||
2813 | packet.EventData.Creator = Utils.StringToBytes(data.creator); | ||
2814 | packet.EventData.Name = Utils.StringToBytes(data.name); | ||
2815 | packet.EventData.Category = Utils.StringToBytes(data.category); | ||
2816 | packet.EventData.Desc = Utils.StringToBytes(data.description); | ||
2817 | packet.EventData.Date = Utils.StringToBytes(data.date); | ||
2818 | packet.EventData.DateUTC = data.dateUTC; | ||
2819 | packet.EventData.Duration = data.duration; | ||
2820 | packet.EventData.Cover = data.cover; | ||
2821 | packet.EventData.Amount = data.amount; | ||
2822 | packet.EventData.SimName = Utils.StringToBytes(data.simName); | ||
2823 | packet.EventData.GlobalPos = new Vector3d(data.globalPos); | ||
2824 | packet.EventData.EventFlags = data.eventFlags; | ||
2825 | |||
2826 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
2827 | } | ||
2828 | |||
2829 | public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) | ||
2830 | { | ||
2831 | MapItemReplyPacket mirplk = new MapItemReplyPacket(); | ||
2832 | mirplk.AgentData.AgentID = AgentId; | ||
2833 | mirplk.RequestData.ItemType = mapitemtype; | ||
2834 | mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length]; | ||
2835 | for (int i = 0; i < replies.Length; i++) | ||
2836 | { | ||
2837 | MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock(); | ||
2838 | mrdata.X = replies[i].x; | ||
2839 | mrdata.Y = replies[i].y; | ||
2840 | mrdata.ID = replies[i].id; | ||
2841 | mrdata.Extra = replies[i].Extra; | ||
2842 | mrdata.Extra2 = replies[i].Extra2; | ||
2843 | mrdata.Name = Utils.StringToBytes(replies[i].name); | ||
2844 | mirplk.Data[i] = mrdata; | ||
2845 | } | ||
2846 | //m_log.Debug(mirplk.ToString()); | ||
2847 | OutPacket(mirplk, ThrottleOutPacketType.Task); | ||
2848 | |||
2849 | } | ||
2850 | |||
2851 | public void SendOfferCallingCard(UUID srcID, UUID transactionID) | ||
2852 | { | ||
2853 | // a bit special, as this uses AgentID to store the source instead | ||
2854 | // of the destination. The destination (the receiver) goes into destID | ||
2855 | OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard); | ||
2856 | p.AgentData.AgentID = srcID; | ||
2857 | p.AgentData.SessionID = UUID.Zero; | ||
2858 | p.AgentBlock.DestID = AgentId; | ||
2859 | p.AgentBlock.TransactionID = transactionID; | ||
2860 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2861 | } | ||
2862 | |||
2863 | public void SendAcceptCallingCard(UUID transactionID) | ||
2864 | { | ||
2865 | AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard); | ||
2866 | p.AgentData.AgentID = AgentId; | ||
2867 | p.AgentData.SessionID = UUID.Zero; | ||
2868 | p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1]; | ||
2869 | p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock(); | ||
2870 | p.FolderData[0].FolderID = UUID.Zero; | ||
2871 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2872 | } | ||
2873 | |||
2874 | public void SendDeclineCallingCard(UUID transactionID) | ||
2875 | { | ||
2876 | DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard); | ||
2877 | p.AgentData.AgentID = AgentId; | ||
2878 | p.AgentData.SessionID = UUID.Zero; | ||
2879 | p.TransactionBlock.TransactionID = transactionID; | ||
2880 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2881 | } | ||
2882 | |||
2883 | public void SendTerminateFriend(UUID exFriendID) | ||
2884 | { | ||
2885 | TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship); | ||
2886 | p.AgentData.AgentID = AgentId; | ||
2887 | p.AgentData.SessionID = SessionId; | ||
2888 | p.ExBlock.OtherID = exFriendID; | ||
2889 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2890 | } | ||
2891 | |||
2892 | public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) | ||
2893 | { | ||
2894 | AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); | ||
2895 | |||
2896 | p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); | ||
2897 | p.AgentData.AgentID = AgentId; | ||
2898 | p.AgentData.AvatarID = avatarID; | ||
2899 | |||
2900 | p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; | ||
2901 | int i = 0; | ||
2902 | foreach (GroupMembershipData m in data) | ||
2903 | { | ||
2904 | p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); | ||
2905 | p.GroupData[i].GroupPowers = m.GroupPowers; | ||
2906 | p.GroupData[i].AcceptNotices = m.AcceptNotices; | ||
2907 | p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); | ||
2908 | p.GroupData[i].GroupID = m.GroupID; | ||
2909 | p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); | ||
2910 | p.GroupData[i].GroupInsigniaID = m.GroupPicture; | ||
2911 | i++; | ||
2912 | } | ||
2913 | |||
2914 | p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); | ||
2915 | p.NewGroupData.ListInProfile = true; | ||
2916 | |||
2917 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2918 | } | ||
2919 | |||
2920 | public void SendJoinGroupReply(UUID groupID, bool success) | ||
2921 | { | ||
2922 | JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply); | ||
2923 | |||
2924 | p.AgentData = new JoinGroupReplyPacket.AgentDataBlock(); | ||
2925 | p.AgentData.AgentID = AgentId; | ||
2926 | |||
2927 | p.GroupData = new JoinGroupReplyPacket.GroupDataBlock(); | ||
2928 | p.GroupData.GroupID = groupID; | ||
2929 | p.GroupData.Success = success; | ||
2930 | |||
2931 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2932 | } | ||
2933 | |||
2934 | public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) | ||
2935 | { | ||
2936 | EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply); | ||
2937 | |||
2938 | p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock(); | ||
2939 | p.AgentData.AgentID = agentID; | ||
2940 | |||
2941 | p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock(); | ||
2942 | p.GroupData.GroupID = groupID; | ||
2943 | |||
2944 | p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock(); | ||
2945 | p.EjectData.Success = success; | ||
2946 | |||
2947 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2948 | } | ||
2949 | |||
2950 | public void SendLeaveGroupReply(UUID groupID, bool success) | ||
2951 | { | ||
2952 | LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply); | ||
2953 | |||
2954 | p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock(); | ||
2955 | p.AgentData.AgentID = AgentId; | ||
2956 | |||
2957 | p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock(); | ||
2958 | p.GroupData.GroupID = groupID; | ||
2959 | p.GroupData.Success = success; | ||
2960 | |||
2961 | OutPacket(p, ThrottleOutPacketType.Task); | ||
2962 | } | ||
2963 | |||
2964 | public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) | ||
2965 | { | ||
2966 | if (classifiedID.Length != name.Length) | ||
2967 | return; | ||
2968 | |||
2969 | AvatarClassifiedReplyPacket ac = | ||
2970 | (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( | ||
2971 | PacketType.AvatarClassifiedReply); | ||
2972 | |||
2973 | ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); | ||
2974 | ac.AgentData.AgentID = AgentId; | ||
2975 | ac.AgentData.TargetID = targetID; | ||
2976 | |||
2977 | ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length]; | ||
2978 | int i; | ||
2979 | for (i = 0; i < classifiedID.Length; i++) | ||
2980 | { | ||
2981 | ac.Data[i].ClassifiedID = classifiedID[i]; | ||
2982 | ac.Data[i].Name = Utils.StringToBytes(name[i]); | ||
2983 | } | ||
2984 | |||
2985 | OutPacket(ac, ThrottleOutPacketType.Task); | ||
2986 | } | ||
2987 | |||
2988 | public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price) | ||
2989 | { | ||
2990 | ClassifiedInfoReplyPacket cr = | ||
2991 | (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket( | ||
2992 | PacketType.ClassifiedInfoReply); | ||
2993 | |||
2994 | cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock(); | ||
2995 | cr.AgentData.AgentID = AgentId; | ||
2996 | |||
2997 | cr.Data = new ClassifiedInfoReplyPacket.DataBlock(); | ||
2998 | cr.Data.ClassifiedID = classifiedID; | ||
2999 | cr.Data.CreatorID = creatorID; | ||
3000 | cr.Data.CreationDate = creationDate; | ||
3001 | cr.Data.ExpirationDate = expirationDate; | ||
3002 | cr.Data.Category = category; | ||
3003 | cr.Data.Name = Utils.StringToBytes(name); | ||
3004 | cr.Data.Desc = Utils.StringToBytes(description); | ||
3005 | cr.Data.ParcelID = parcelID; | ||
3006 | cr.Data.ParentEstate = parentEstate; | ||
3007 | cr.Data.SnapshotID = snapshotID; | ||
3008 | cr.Data.SimName = Utils.StringToBytes(simName); | ||
3009 | cr.Data.PosGlobal = new Vector3d(globalPos); | ||
3010 | cr.Data.ParcelName = Utils.StringToBytes(parcelName); | ||
3011 | cr.Data.ClassifiedFlags = classifiedFlags; | ||
3012 | cr.Data.PriceForListing = price; | ||
3013 | |||
3014 | OutPacket(cr, ThrottleOutPacketType.Task); | ||
3015 | } | ||
3016 | |||
3017 | public void SendAgentDropGroup(UUID groupID) | ||
3018 | { | ||
3019 | AgentDropGroupPacket dg = | ||
3020 | (AgentDropGroupPacket)PacketPool.Instance.GetPacket( | ||
3021 | PacketType.AgentDropGroup); | ||
3022 | |||
3023 | dg.AgentData = new AgentDropGroupPacket.AgentDataBlock(); | ||
3024 | dg.AgentData.AgentID = AgentId; | ||
3025 | dg.AgentData.GroupID = groupID; | ||
3026 | |||
3027 | OutPacket(dg, ThrottleOutPacketType.Task); | ||
3028 | } | ||
3029 | |||
3030 | public void SendAvatarNotesReply(UUID targetID, string text) | ||
3031 | { | ||
3032 | AvatarNotesReplyPacket an = | ||
3033 | (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket( | ||
3034 | PacketType.AvatarNotesReply); | ||
3035 | |||
3036 | an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock(); | ||
3037 | an.AgentData.AgentID = AgentId; | ||
3038 | |||
3039 | an.Data = new AvatarNotesReplyPacket.DataBlock(); | ||
3040 | an.Data.TargetID = targetID; | ||
3041 | an.Data.Notes = Utils.StringToBytes(text); | ||
3042 | |||
3043 | OutPacket(an, ThrottleOutPacketType.Task); | ||
3044 | } | ||
3045 | |||
3046 | public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks) | ||
3047 | { | ||
3048 | AvatarPicksReplyPacket ap = | ||
3049 | (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket( | ||
3050 | PacketType.AvatarPicksReply); | ||
3051 | |||
3052 | ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock(); | ||
3053 | ap.AgentData.AgentID = AgentId; | ||
3054 | ap.AgentData.TargetID = targetID; | ||
3055 | |||
3056 | ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count]; | ||
3057 | |||
3058 | int i = 0; | ||
3059 | foreach (KeyValuePair<UUID, string> pick in picks) | ||
3060 | { | ||
3061 | ap.Data[i] = new AvatarPicksReplyPacket.DataBlock(); | ||
3062 | ap.Data[i].PickID = pick.Key; | ||
3063 | ap.Data[i].PickName = Utils.StringToBytes(pick.Value); | ||
3064 | i++; | ||
3065 | } | ||
3066 | |||
3067 | OutPacket(ap, ThrottleOutPacketType.Task); | ||
3068 | } | ||
3069 | |||
3070 | public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds) | ||
3071 | { | ||
3072 | AvatarClassifiedReplyPacket ac = | ||
3073 | (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( | ||
3074 | PacketType.AvatarClassifiedReply); | ||
3075 | |||
3076 | ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); | ||
3077 | ac.AgentData.AgentID = AgentId; | ||
3078 | ac.AgentData.TargetID = targetID; | ||
3079 | |||
3080 | ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count]; | ||
3081 | |||
3082 | int i = 0; | ||
3083 | foreach (KeyValuePair<UUID, string> classified in classifieds) | ||
3084 | { | ||
3085 | ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock(); | ||
3086 | ac.Data[i].ClassifiedID = classified.Key; | ||
3087 | ac.Data[i].Name = Utils.StringToBytes(classified.Value); | ||
3088 | i++; | ||
3089 | } | ||
3090 | |||
3091 | OutPacket(ac, ThrottleOutPacketType.Task); | ||
3092 | } | ||
3093 | |||
3094 | public void SendParcelDwellReply(int localID, UUID parcelID, float dwell) | ||
3095 | { | ||
3096 | ParcelDwellReplyPacket pd = | ||
3097 | (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket( | ||
3098 | PacketType.ParcelDwellReply); | ||
3099 | |||
3100 | pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock(); | ||
3101 | pd.AgentData.AgentID = AgentId; | ||
3102 | |||
3103 | pd.Data = new ParcelDwellReplyPacket.DataBlock(); | ||
3104 | pd.Data.LocalID = localID; | ||
3105 | pd.Data.ParcelID = parcelID; | ||
3106 | pd.Data.Dwell = dwell; | ||
3107 | |||
3108 | OutPacket(pd, ThrottleOutPacketType.Land); | ||
3109 | } | ||
3110 | |||
3111 | public void SendUserInfoReply(bool imViaEmail, bool visible, string email) | ||
3112 | { | ||
3113 | UserInfoReplyPacket ur = | ||
3114 | (UserInfoReplyPacket)PacketPool.Instance.GetPacket( | ||
3115 | PacketType.UserInfoReply); | ||
3116 | |||
3117 | string Visible = "hidden"; | ||
3118 | if (visible) | ||
3119 | Visible = "default"; | ||
3120 | |||
3121 | ur.AgentData = new UserInfoReplyPacket.AgentDataBlock(); | ||
3122 | ur.AgentData.AgentID = AgentId; | ||
3123 | |||
3124 | ur.UserData = new UserInfoReplyPacket.UserDataBlock(); | ||
3125 | ur.UserData.IMViaEMail = imViaEmail; | ||
3126 | ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible); | ||
3127 | ur.UserData.EMail = Utils.StringToBytes(email); | ||
3128 | |||
3129 | OutPacket(ur, ThrottleOutPacketType.Task); | ||
3130 | } | ||
3131 | |||
3132 | public void SendCreateGroupReply(UUID groupID, bool success, string message) | ||
3133 | { | ||
3134 | CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply); | ||
3135 | |||
3136 | createGroupReply.AgentData = | ||
3137 | new CreateGroupReplyPacket.AgentDataBlock(); | ||
3138 | createGroupReply.ReplyData = | ||
3139 | new CreateGroupReplyPacket.ReplyDataBlock(); | ||
3140 | |||
3141 | createGroupReply.AgentData.AgentID = AgentId; | ||
3142 | createGroupReply.ReplyData.GroupID = groupID; | ||
3143 | |||
3144 | createGroupReply.ReplyData.Success = success; | ||
3145 | createGroupReply.ReplyData.Message = Utils.StringToBytes(message); | ||
3146 | OutPacket(createGroupReply, ThrottleOutPacketType.Task); | ||
3147 | } | ||
3148 | |||
3149 | public void SendUseCachedMuteList() | ||
3150 | { | ||
3151 | UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList); | ||
3152 | |||
3153 | useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock(); | ||
3154 | useCachedMuteList.AgentData.AgentID = AgentId; | ||
3155 | |||
3156 | OutPacket(useCachedMuteList, ThrottleOutPacketType.Task); | ||
3157 | } | ||
3158 | |||
3159 | public void SendMuteListUpdate(string filename) | ||
3160 | { | ||
3161 | MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate); | ||
3162 | |||
3163 | muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock(); | ||
3164 | muteListUpdate.MuteData.AgentID = AgentId; | ||
3165 | muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename); | ||
3166 | |||
3167 | OutPacket(muteListUpdate, ThrottleOutPacketType.Task); | ||
3168 | } | ||
3169 | |||
3170 | public void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) | ||
3171 | { | ||
3172 | PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply); | ||
3173 | |||
3174 | pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock(); | ||
3175 | pickInfoReply.AgentData.AgentID = AgentId; | ||
3176 | |||
3177 | pickInfoReply.Data = new PickInfoReplyPacket.DataBlock(); | ||
3178 | pickInfoReply.Data.PickID = pickID; | ||
3179 | pickInfoReply.Data.CreatorID = creatorID; | ||
3180 | pickInfoReply.Data.TopPick = topPick; | ||
3181 | pickInfoReply.Data.ParcelID = parcelID; | ||
3182 | pickInfoReply.Data.Name = Utils.StringToBytes(name); | ||
3183 | pickInfoReply.Data.Desc = Utils.StringToBytes(desc); | ||
3184 | pickInfoReply.Data.SnapshotID = snapshotID; | ||
3185 | pickInfoReply.Data.User = Utils.StringToBytes(user); | ||
3186 | pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName); | ||
3187 | pickInfoReply.Data.SimName = Utils.StringToBytes(simName); | ||
3188 | pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal); | ||
3189 | pickInfoReply.Data.SortOrder = sortOrder; | ||
3190 | pickInfoReply.Data.Enabled = enabled; | ||
3191 | |||
3192 | OutPacket(pickInfoReply, ThrottleOutPacketType.Task); | ||
3193 | } | ||
3194 | |||
3195 | #endregion Scene/Avatar to Client | ||
2772 | 3196 | ||
2773 | // Gesture | 3197 | // Gesture |
2774 | 3198 | ||
@@ -3064,7 +3488,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3064 | objectData.FullID = objectID; | 3488 | objectData.FullID = objectID; |
3065 | objectData.OwnerID = ownerID; | 3489 | objectData.OwnerID = ownerID; |
3066 | 3490 | ||
3067 | objectData.Text = LLUtil.StringToPacketBytes(text); | 3491 | objectData.Text = Util.StringToBytes256(text); |
3068 | objectData.TextColor[0] = color[0]; | 3492 | objectData.TextColor[0] = color[0]; |
3069 | objectData.TextColor[1] = color[1]; | 3493 | objectData.TextColor[1] = color[1]; |
3070 | objectData.TextColor[2] = color[2]; | 3494 | objectData.TextColor[2] = color[2]; |
@@ -3201,7 +3625,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3201 | } | 3625 | } |
3202 | 3626 | ||
3203 | outPacket.Header.Zerocoded = true; | 3627 | outPacket.Header.Zerocoded = true; |
3204 | OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); | 3628 | OutPacket(outPacket, ThrottleOutPacketType.Task); |
3205 | 3629 | ||
3206 | if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) | 3630 | if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) |
3207 | lock (m_primFullUpdateTimer) | 3631 | lock (m_primFullUpdateTimer) |
@@ -3291,7 +3715,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3291 | 3715 | ||
3292 | outPacket.Header.Reliable = false; | 3716 | outPacket.Header.Reliable = false; |
3293 | outPacket.Header.Zerocoded = true; | 3717 | outPacket.Header.Zerocoded = true; |
3294 | OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); | 3718 | OutPacket(outPacket, ThrottleOutPacketType.Task); |
3295 | 3719 | ||
3296 | if (m_primTerseUpdates.Count == 0) | 3720 | if (m_primTerseUpdates.Count == 0) |
3297 | lock (m_primTerseUpdateTimer) | 3721 | lock (m_primTerseUpdateTimer) |
@@ -3442,8 +3866,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3442 | objPropDB.SalePrice = SalePrice; | 3866 | objPropDB.SalePrice = SalePrice; |
3443 | objPropDB.Category = Category; | 3867 | objPropDB.Category = Category; |
3444 | objPropDB.LastOwnerID = LastOwnerID; | 3868 | objPropDB.LastOwnerID = LastOwnerID; |
3445 | objPropDB.Name = LLUtil.StringToPacketBytes(ObjectName); | 3869 | objPropDB.Name = Util.StringToBytes256(ObjectName); |
3446 | objPropDB.Description = LLUtil.StringToPacketBytes(Description); | 3870 | objPropDB.Description = Util.StringToBytes256(Description); |
3447 | objPropFamilyPack.ObjectData = objPropDB; | 3871 | objPropFamilyPack.ObjectData = objPropDB; |
3448 | objPropFamilyPack.Header.Zerocoded = true; | 3872 | objPropFamilyPack.Header.Zerocoded = true; |
3449 | OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task); | 3873 | OutPacket(objPropFamilyPack, ThrottleOutPacketType.Task); |
@@ -3477,11 +3901,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3477 | proper.ObjectData[0].OwnerID = UUID.Zero; | 3901 | proper.ObjectData[0].OwnerID = UUID.Zero; |
3478 | else | 3902 | else |
3479 | proper.ObjectData[0].OwnerID = OwnerUUID; | 3903 | proper.ObjectData[0].OwnerID = OwnerUUID; |
3480 | proper.ObjectData[0].TouchName = LLUtil.StringToPacketBytes(TouchTitle); | 3904 | proper.ObjectData[0].TouchName = Util.StringToBytes256(TouchTitle); |
3481 | proper.ObjectData[0].TextureID = TextureID; | 3905 | proper.ObjectData[0].TextureID = TextureID; |
3482 | proper.ObjectData[0].SitName = LLUtil.StringToPacketBytes(SitTitle); | 3906 | proper.ObjectData[0].SitName = Util.StringToBytes256(SitTitle); |
3483 | proper.ObjectData[0].Name = LLUtil.StringToPacketBytes(ItemName); | 3907 | proper.ObjectData[0].Name = Util.StringToBytes256(ItemName); |
3484 | proper.ObjectData[0].Description = LLUtil.StringToPacketBytes(ItemDescription); | 3908 | proper.ObjectData[0].Description = Util.StringToBytes256(ItemDescription); |
3485 | proper.ObjectData[0].OwnerMask = OwnerMask; | 3909 | proper.ObjectData[0].OwnerMask = OwnerMask; |
3486 | proper.ObjectData[0].NextOwnerMask = NextOwnerMask; | 3910 | proper.ObjectData[0].NextOwnerMask = NextOwnerMask; |
3487 | proper.ObjectData[0].GroupMask = GroupMask; | 3911 | proper.ObjectData[0].GroupMask = GroupMask; |
@@ -3722,11 +4146,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3722 | 4146 | ||
3723 | updatePacket.ParcelData.MediaAutoScale = landData.MediaAutoScale; | 4147 | updatePacket.ParcelData.MediaAutoScale = landData.MediaAutoScale; |
3724 | updatePacket.ParcelData.MediaID = landData.MediaID; | 4148 | updatePacket.ParcelData.MediaID = landData.MediaID; |
3725 | updatePacket.ParcelData.MediaURL = LLUtil.StringToPacketBytes(landData.MediaURL); | 4149 | updatePacket.ParcelData.MediaURL = Util.StringToBytes256(landData.MediaURL); |
3726 | updatePacket.ParcelData.MusicURL = LLUtil.StringToPacketBytes(landData.MusicURL); | 4150 | updatePacket.ParcelData.MusicURL = Util.StringToBytes256(landData.MusicURL); |
3727 | updatePacket.ParcelData.Name = Utils.StringToBytes(landData.Name); | 4151 | updatePacket.ParcelData.Name = Util.StringToBytes256(landData.Name); |
3728 | updatePacket.ParcelData.OtherCleanTime = landData.OtherCleanTime; | 4152 | updatePacket.ParcelData.OtherCleanTime = landData.OtherCleanTime; |
3729 | updatePacket.ParcelData.OtherCount = 0; //unemplemented | 4153 | updatePacket.ParcelData.OtherCount = 0; //TODO: Unimplemented |
3730 | updatePacket.ParcelData.OtherPrims = landData.OtherPrims; | 4154 | updatePacket.ParcelData.OtherPrims = landData.OtherPrims; |
3731 | updatePacket.ParcelData.OwnerID = landData.OwnerID; | 4155 | updatePacket.ParcelData.OwnerID = landData.OwnerID; |
3732 | updatePacket.ParcelData.OwnerPrims = landData.OwnerPrims; | 4156 | updatePacket.ParcelData.OwnerPrims = landData.OwnerPrims; |
@@ -3734,22 +4158,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3734 | updatePacket.ParcelData.ParcelPrimBonus = simObjectBonusFactor; | 4158 | updatePacket.ParcelData.ParcelPrimBonus = simObjectBonusFactor; |
3735 | updatePacket.ParcelData.PassHours = landData.PassHours; | 4159 | updatePacket.ParcelData.PassHours = landData.PassHours; |
3736 | updatePacket.ParcelData.PassPrice = landData.PassPrice; | 4160 | updatePacket.ParcelData.PassPrice = landData.PassPrice; |
3737 | updatePacket.ParcelData.PublicCount = 0; //unemplemented | 4161 | updatePacket.ParcelData.PublicCount = 0; //TODO: Unimplemented |
3738 | 4162 | ||
3739 | updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint)RegionFlags.DenyAnonymous) > | 4163 | updatePacket.ParcelData.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0; |
3740 | 0); | 4164 | updatePacket.ParcelData.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0; |
3741 | updatePacket.ParcelData.RegionDenyIdentified = ((regionFlags & (uint)RegionFlags.DenyIdentified) > | 4165 | updatePacket.ParcelData.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0; |
3742 | 0); | 4166 | updatePacket.ParcelData.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0; |
3743 | updatePacket.ParcelData.RegionDenyTransacted = ((regionFlags & (uint)RegionFlags.DenyTransacted) > | ||
3744 | 0); | ||
3745 | updatePacket.ParcelData.RegionPushOverride = ((regionFlags & (uint)RegionFlags.RestrictPushObject) > | ||
3746 | 0); | ||
3747 | 4167 | ||
3748 | updatePacket.ParcelData.RentPrice = 0; | 4168 | updatePacket.ParcelData.RentPrice = 0; |
3749 | updatePacket.ParcelData.RequestResult = request_result; | 4169 | updatePacket.ParcelData.RequestResult = request_result; |
3750 | updatePacket.ParcelData.SalePrice = landData.SalePrice; | 4170 | updatePacket.ParcelData.SalePrice = landData.SalePrice; |
3751 | updatePacket.ParcelData.SelectedPrims = landData.SelectedPrims; | 4171 | updatePacket.ParcelData.SelectedPrims = landData.SelectedPrims; |
3752 | updatePacket.ParcelData.SelfCount = 0; //unemplemented | 4172 | updatePacket.ParcelData.SelfCount = 0; //TODO: Unimplemented |
3753 | updatePacket.ParcelData.SequenceID = sequence_id; | 4173 | updatePacket.ParcelData.SequenceID = sequence_id; |
3754 | if (landData.SimwideArea > 0) | 4174 | if (landData.SimwideArea > 0) |
3755 | { | 4175 | { |
@@ -4242,6 +4662,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4242 | OutPacket(packet, ThrottleOutPacketType.Task); | 4662 | OutPacket(packet, ThrottleOutPacketType.Task); |
4243 | } | 4663 | } |
4244 | 4664 | ||
4665 | public ulong GetGroupPowers(UUID groupID) | ||
4666 | { | ||
4667 | if (groupID == m_activeGroupID) | ||
4668 | return m_activeGroupPowers; | ||
4669 | |||
4670 | if (m_groupPowers.ContainsKey(groupID)) | ||
4671 | return m_groupPowers[groupID]; | ||
4672 | |||
4673 | return 0; | ||
4674 | } | ||
4675 | |||
4676 | /// <summary> | ||
4677 | /// This is a utility method used by single states to not duplicate kicks and blue card of death messages. | ||
4678 | /// </summary> | ||
4679 | public bool ChildAgentStatus() | ||
4680 | { | ||
4681 | return m_scene.PresenceChildStatus(AgentId); | ||
4682 | } | ||
4683 | |||
4245 | #endregion | 4684 | #endregion |
4246 | 4685 | ||
4247 | /// <summary> | 4686 | /// <summary> |
@@ -4260,6 +4699,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4260 | AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); | 4699 | AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); |
4261 | } | 4700 | } |
4262 | 4701 | ||
4702 | #region Packet Handlers | ||
4703 | |||
4263 | private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) | 4704 | private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) |
4264 | { | 4705 | { |
4265 | MoneyTransferRequestPacket money = (MoneyTransferRequestPacket) Pack; | 4706 | MoneyTransferRequestPacket money = (MoneyTransferRequestPacket) Pack; |
@@ -4267,7 +4708,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4267 | if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId && | 4708 | if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId && |
4268 | money.AgentData.SessionID == sender.SessionId) | 4709 | money.AgentData.SessionID == sender.SessionId) |
4269 | { | 4710 | { |
4270 | handlerMoneyTransferRequest = OnMoneyTransferRequest; | 4711 | MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest; |
4271 | if (handlerMoneyTransferRequest != null) | 4712 | if (handlerMoneyTransferRequest != null) |
4272 | { | 4713 | { |
4273 | handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID, | 4714 | handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID, |
@@ -4286,7 +4727,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4286 | ParcelBuyPacket parcel = (ParcelBuyPacket) Pack; | 4727 | ParcelBuyPacket parcel = (ParcelBuyPacket) Pack; |
4287 | if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId) | 4728 | if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId) |
4288 | { | 4729 | { |
4289 | handlerParcelBuy = OnParcelBuy; | 4730 | ParcelBuy handlerParcelBuy = OnParcelBuy; |
4290 | if (handlerParcelBuy != null) | 4731 | if (handlerParcelBuy != null) |
4291 | { | 4732 | { |
4292 | handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final, | 4733 | handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final, |
@@ -4307,7 +4748,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4307 | 4748 | ||
4308 | for (int i = 0; i < upack.UUIDNameBlock.Length; i++) | 4749 | for (int i = 0; i < upack.UUIDNameBlock.Length; i++) |
4309 | { | 4750 | { |
4310 | handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest; | 4751 | UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest; |
4311 | if (handlerUUIDGroupNameRequest != null) | 4752 | if (handlerUUIDGroupNameRequest != null) |
4312 | { | 4753 | { |
4313 | handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this); | 4754 | handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this); |
@@ -4323,7 +4764,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4323 | if (m_genericPacketHandlers.Count == 0) return false; | 4764 | if (m_genericPacketHandlers.Count == 0) return false; |
4324 | if (gmpack.AgentData.SessionID != SessionId) return false; | 4765 | if (gmpack.AgentData.SessionID != SessionId) return false; |
4325 | 4766 | ||
4326 | handlerGenericMessage = null; | 4767 | GenericMessage handlerGenericMessage = null; |
4327 | 4768 | ||
4328 | string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim(); | 4769 | string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim(); |
4329 | 4770 | ||
@@ -4364,7 +4805,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4364 | ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack; | 4805 | ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack; |
4365 | if (ogpack.AgentData.SessionID != SessionId) return false; | 4806 | if (ogpack.AgentData.SessionID != SessionId) return false; |
4366 | 4807 | ||
4367 | handlerObjectGroupRequest = OnObjectGroupRequest; | 4808 | RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest; |
4368 | if (handlerObjectGroupRequest != null) | 4809 | if (handlerObjectGroupRequest != null) |
4369 | { | 4810 | { |
4370 | for (int i = 0; i < ogpack.ObjectData.Length; i++) | 4811 | for (int i = 0; i < ogpack.ObjectData.Length; i++) |
@@ -4379,7 +4820,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4379 | { | 4820 | { |
4380 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; | 4821 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; |
4381 | if (viewer.AgentData.SessionID != SessionId) return false; | 4822 | if (viewer.AgentData.SessionID != SessionId) return false; |
4382 | handlerViewerEffect = OnViewerEffect; | 4823 | ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect; |
4383 | if (handlerViewerEffect != null) | 4824 | if (handlerViewerEffect != null) |
4384 | { | 4825 | { |
4385 | int length = viewer.Effect.Length; | 4826 | int length = viewer.Effect.Length; |
@@ -4403,6 +4844,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4403 | return true; | 4844 | return true; |
4404 | } | 4845 | } |
4405 | 4846 | ||
4847 | #endregion Packet Handlers | ||
4848 | |||
4406 | public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question) | 4849 | public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question) |
4407 | { | 4850 | { |
4408 | ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion); | 4851 | ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion); |
@@ -4468,7 +4911,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4468 | { | 4911 | { |
4469 | m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName); | 4912 | m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName); |
4470 | 4913 | ||
4471 | handlerLogout = OnLogout; | 4914 | Action<IClientAPI> handlerLogout = OnLogout; |
4472 | 4915 | ||
4473 | if (handlerLogout != null) | 4916 | if (handlerLogout != null) |
4474 | { | 4917 | { |
@@ -4550,7 +4993,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4550 | case 1: | 4993 | case 1: |
4551 | Vector3 pos1 = new Vector3(block.Data, 0); | 4994 | Vector3 pos1 = new Vector3(block.Data, 0); |
4552 | 4995 | ||
4553 | handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; | 4996 | UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; |
4554 | if (handlerUpdatePrimSinglePosition != null) | 4997 | if (handlerUpdatePrimSinglePosition != null) |
4555 | { | 4998 | { |
4556 | // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); | 4999 | // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); |
@@ -4560,7 +5003,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4560 | case 2: | 5003 | case 2: |
4561 | Quaternion rot1 = new Quaternion(block.Data, 0, true); | 5004 | Quaternion rot1 = new Quaternion(block.Data, 0, true); |
4562 | 5005 | ||
4563 | handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; | 5006 | UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; |
4564 | if (handlerUpdatePrimSingleRotation != null) | 5007 | if (handlerUpdatePrimSingleRotation != null) |
4565 | { | 5008 | { |
4566 | // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W); | 5009 | // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W); |
@@ -4571,7 +5014,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4571 | Vector3 rotPos = new Vector3(block.Data, 0); | 5014 | Vector3 rotPos = new Vector3(block.Data, 0); |
4572 | Quaternion rot2 = new Quaternion(block.Data, 12, true); | 5015 | Quaternion rot2 = new Quaternion(block.Data, 12, true); |
4573 | 5016 | ||
4574 | handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition; | 5017 | UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition; |
4575 | if (handlerUpdatePrimSingleRotationPosition != null) | 5018 | if (handlerUpdatePrimSingleRotationPosition != null) |
4576 | { | 5019 | { |
4577 | // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z); | 5020 | // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z); |
@@ -4583,7 +5026,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4583 | case 20: | 5026 | case 20: |
4584 | Vector3 scale4 = new Vector3(block.Data, 0); | 5027 | Vector3 scale4 = new Vector3(block.Data, 0); |
4585 | 5028 | ||
4586 | handlerUpdatePrimScale = OnUpdatePrimScale; | 5029 | UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale; |
4587 | if (handlerUpdatePrimScale != null) | 5030 | if (handlerUpdatePrimScale != null) |
4588 | { | 5031 | { |
4589 | // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z); | 5032 | // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z); |
@@ -4611,7 +5054,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4611 | case 9: | 5054 | case 9: |
4612 | Vector3 pos2 = new Vector3(block.Data, 0); | 5055 | Vector3 pos2 = new Vector3(block.Data, 0); |
4613 | 5056 | ||
4614 | handlerUpdateVector = OnUpdatePrimGroupPosition; | 5057 | UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition; |
4615 | 5058 | ||
4616 | if (handlerUpdateVector != null) | 5059 | if (handlerUpdateVector != null) |
4617 | { | 5060 | { |
@@ -4622,7 +5065,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4622 | case 10: | 5065 | case 10: |
4623 | Quaternion rot3 = new Quaternion(block.Data, 0, true); | 5066 | Quaternion rot3 = new Quaternion(block.Data, 0, true); |
4624 | 5067 | ||
4625 | handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; | 5068 | UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; |
4626 | if (handlerUpdatePrimRotation != null) | 5069 | if (handlerUpdatePrimRotation != null) |
4627 | { | 5070 | { |
4628 | // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W); | 5071 | // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W); |
@@ -4645,7 +5088,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4645 | case 28: | 5088 | case 28: |
4646 | Vector3 scale7 = new Vector3(block.Data, 0); | 5089 | Vector3 scale7 = new Vector3(block.Data, 0); |
4647 | 5090 | ||
4648 | handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; | 5091 | UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; |
4649 | if (handlerUpdatePrimGroupScale != null) | 5092 | if (handlerUpdatePrimGroupScale != null) |
4650 | { | 5093 | { |
4651 | // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z); | 5094 | // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z); |
@@ -4765,45 +5208,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4765 | } | 5208 | } |
4766 | 5209 | ||
4767 | /// <summary> | 5210 | /// <summary> |
4768 | /// returns a byte array of the client set throttles Gets multiplied by the multiplier | 5211 | /// Sets the throttles from values supplied by the client |
4769 | /// | ||
4770 | /// </summary> | 5212 | /// </summary> |
4771 | /// <param name="multiplier">non 1 multiplier for subdividing the throttles between individual regions</param> | 5213 | /// <param name="throttles"></param> |
4772 | /// <returns></returns> | 5214 | public void SetChildAgentThrottle(byte[] throttles) |
4773 | public byte[] GetThrottlesPacked(float multiplier) | ||
4774 | { | 5215 | { |
4775 | return m_PacketHandler.PacketQueue.GetThrottlesPacked(multiplier); | 5216 | m_udpClient.SetThrottles(throttles); |
4776 | } | 5217 | } |
5218 | |||
4777 | /// <summary> | 5219 | /// <summary> |
4778 | /// sets the throttles from values supplied by the client | 5220 | /// Get the current throttles for this client as a packed byte array |
4779 | /// </summary> | 5221 | /// </summary> |
4780 | /// <param name="throttles"></param> | 5222 | /// <param name="multiplier">Unused</param> |
4781 | public void SetChildAgentThrottle(byte[] throttles) | 5223 | /// <returns></returns> |
5224 | public byte[] GetThrottlesPacked(float multiplier) | ||
4782 | { | 5225 | { |
4783 | m_PacketHandler.PacketQueue.SetThrottleFromClient(throttles); | 5226 | return m_udpClient.GetThrottlesPacked(); |
4784 | } | 5227 | } |
4785 | 5228 | ||
4786 | /// <summary> | 5229 | /// <summary> |
4787 | /// Method gets called when a new packet has arrived from the UDP | 5230 | /// Cruft? |
4788 | /// server. This happens after it's been decoded into a libsl object. | ||
4789 | /// </summary> | 5231 | /// </summary> |
4790 | /// <param name="NewPack">object containing the packet.</param> | ||
4791 | public virtual void InPacket(object NewPack) | 5232 | public virtual void InPacket(object NewPack) |
4792 | { | 5233 | { |
4793 | // Cast NewPack to Packet. | 5234 | throw new NotImplementedException(); |
4794 | m_PacketHandler.InPacket((Packet) NewPack); | ||
4795 | } | 5235 | } |
4796 | 5236 | ||
4797 | /// <summary> | 5237 | /// <summary> |
4798 | /// This is the starting point for sending a simulator packet out to the client. | 5238 | /// This is the starting point for sending a simulator packet out to the client |
4799 | /// | ||
4800 | /// Please do not call this from outside the LindenUDP client stack. | ||
4801 | /// </summary> | 5239 | /// </summary> |
4802 | /// <param name="NewPack"></param> | 5240 | /// <param name="packet">Packet to send</param> |
4803 | /// <param name="throttlePacketType">Corresponds to the type of data that is going out. Enum</param> | 5241 | /// <param name="throttlePacketType">Throttling category for the packet</param> |
4804 | public void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType) | 5242 | private void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) |
4805 | { | 5243 | { |
4806 | m_PacketHandler.OutPacket(NewPack, throttlePacketType); | 5244 | m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); |
4807 | } | 5245 | } |
4808 | 5246 | ||
4809 | public bool AddMoney(int debit) | 5247 | public bool AddMoney(int debit) |
@@ -4847,7 +5285,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4847 | return; | 5285 | return; |
4848 | } | 5286 | } |
4849 | 5287 | ||
4850 | handlerAutoPilotGo = OnAutoPilotGo; | 5288 | UpdateVector handlerAutoPilotGo = OnAutoPilotGo; |
4851 | if (handlerAutoPilotGo != null) | 5289 | if (handlerAutoPilotGo != null) |
4852 | { | 5290 | { |
4853 | handlerAutoPilotGo(0, new Vector3(locx, locy, locz), this); | 5291 | handlerAutoPilotGo(0, new Vector3(locx, locy, locz), this); |
@@ -4899,7 +5337,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4899 | } | 5337 | } |
4900 | #endregion | 5338 | #endregion |
4901 | 5339 | ||
4902 | handlerRequestAvatarProperties = OnRequestAvatarProperties; | 5340 | RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties; |
4903 | if (handlerRequestAvatarProperties != null) | 5341 | if (handlerRequestAvatarProperties != null) |
4904 | { | 5342 | { |
4905 | handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); | 5343 | handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); |
@@ -4940,7 +5378,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4940 | args.Sender = this; | 5378 | args.Sender = this; |
4941 | args.SenderUUID = this.AgentId; | 5379 | args.SenderUUID = this.AgentId; |
4942 | 5380 | ||
4943 | handlerChatFromClient = OnChatFromClient; | 5381 | ChatMessage handlerChatFromClient = OnChatFromClient; |
4944 | if (handlerChatFromClient != null) | 5382 | if (handlerChatFromClient != null) |
4945 | handlerChatFromClient(this, args); | 5383 | handlerChatFromClient(this, args); |
4946 | } | 5384 | } |
@@ -4958,7 +5396,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4958 | } | 5396 | } |
4959 | #endregion | 5397 | #endregion |
4960 | 5398 | ||
4961 | handlerUpdateAvatarProperties = OnUpdateAvatarProperties; | 5399 | UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties; |
4962 | if (handlerUpdateAvatarProperties != null) | 5400 | if (handlerUpdateAvatarProperties != null) |
4963 | { | 5401 | { |
4964 | AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData; | 5402 | AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData; |
@@ -4998,7 +5436,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4998 | args.Position = new Vector3(); | 5436 | args.Position = new Vector3(); |
4999 | args.Scene = Scene; | 5437 | args.Scene = Scene; |
5000 | args.Sender = this; | 5438 | args.Sender = this; |
5001 | handlerChatFromClient2 = OnChatFromClient; | 5439 | ChatMessage handlerChatFromClient2 = OnChatFromClient; |
5002 | if (handlerChatFromClient2 != null) | 5440 | if (handlerChatFromClient2 != null) |
5003 | handlerChatFromClient2(this, args); | 5441 | handlerChatFromClient2(this, args); |
5004 | } | 5442 | } |
@@ -5019,7 +5457,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5019 | 5457 | ||
5020 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); | 5458 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); |
5021 | string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message); | 5459 | string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message); |
5022 | handlerInstantMessage = OnInstantMessage; | 5460 | ImprovedInstantMessage handlerInstantMessage = OnInstantMessage; |
5023 | 5461 | ||
5024 | if (handlerInstantMessage != null) | 5462 | if (handlerInstantMessage != null) |
5025 | { | 5463 | { |
@@ -5062,7 +5500,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5062 | callingCardFolders.Add(afriendpack.FolderData[fi].FolderID); | 5500 | callingCardFolders.Add(afriendpack.FolderData[fi].FolderID); |
5063 | } | 5501 | } |
5064 | 5502 | ||
5065 | handlerApproveFriendRequest = OnApproveFriendRequest; | 5503 | FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest; |
5066 | if (handlerApproveFriendRequest != null) | 5504 | if (handlerApproveFriendRequest != null) |
5067 | { | 5505 | { |
5068 | handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders); | 5506 | handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders); |
@@ -5105,7 +5543,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5105 | UUID listOwnerAgentID = tfriendpack.AgentData.AgentID; | 5543 | UUID listOwnerAgentID = tfriendpack.AgentData.AgentID; |
5106 | UUID exFriendID = tfriendpack.ExBlock.OtherID; | 5544 | UUID exFriendID = tfriendpack.ExBlock.OtherID; |
5107 | 5545 | ||
5108 | handlerTerminateFriendship = OnTerminateFriendship; | 5546 | FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship; |
5109 | if (handlerTerminateFriendship != null) | 5547 | if (handlerTerminateFriendship != null) |
5110 | { | 5548 | { |
5111 | handlerTerminateFriendship(this, listOwnerAgentID, exFriendID); | 5549 | handlerTerminateFriendship(this, listOwnerAgentID, exFriendID); |
@@ -5124,7 +5562,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5124 | } | 5562 | } |
5125 | #endregion | 5563 | #endregion |
5126 | 5564 | ||
5127 | handlerRezObject = OnRezObject; | 5565 | RezObject handlerRezObject = OnRezObject; |
5128 | if (handlerRezObject != null) | 5566 | if (handlerRezObject != null) |
5129 | { | 5567 | { |
5130 | handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd, | 5568 | handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd, |
@@ -5147,7 +5585,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5147 | } | 5585 | } |
5148 | #endregion | 5586 | #endregion |
5149 | 5587 | ||
5150 | handlerDeRezObject = OnDeRezObject; | 5588 | DeRezObject handlerDeRezObject = OnDeRezObject; |
5151 | if (handlerDeRezObject != null) | 5589 | if (handlerDeRezObject != null) |
5152 | { | 5590 | { |
5153 | List<uint> deRezIDs = new List<uint>(); | 5591 | List<uint> deRezIDs = new List<uint>(); |
@@ -5186,7 +5624,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5186 | { | 5624 | { |
5187 | for (int i = 0; i < modify.ParcelData.Length; i++) | 5625 | for (int i = 0; i < modify.ParcelData.Length; i++) |
5188 | { | 5626 | { |
5189 | handlerModifyTerrain = OnModifyTerrain; | 5627 | ModifyTerrain handlerModifyTerrain = OnModifyTerrain; |
5190 | if (handlerModifyTerrain != null) | 5628 | if (handlerModifyTerrain != null) |
5191 | { | 5629 | { |
5192 | handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, | 5630 | handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, |
@@ -5203,7 +5641,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5203 | 5641 | ||
5204 | case PacketType.RegionHandshakeReply: | 5642 | case PacketType.RegionHandshakeReply: |
5205 | 5643 | ||
5206 | handlerRegionHandShakeReply = OnRegionHandShakeReply; | 5644 | Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply; |
5207 | if (handlerRegionHandShakeReply != null) | 5645 | if (handlerRegionHandShakeReply != null) |
5208 | { | 5646 | { |
5209 | handlerRegionHandShakeReply(this); | 5647 | handlerRegionHandShakeReply(this); |
@@ -5212,14 +5650,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5212 | break; | 5650 | break; |
5213 | 5651 | ||
5214 | case PacketType.AgentWearablesRequest: | 5652 | case PacketType.AgentWearablesRequest: |
5215 | handlerRequestWearables = OnRequestWearables; | 5653 | GenericCall2 handlerRequestWearables = OnRequestWearables; |
5216 | 5654 | ||
5217 | if (handlerRequestWearables != null) | 5655 | if (handlerRequestWearables != null) |
5218 | { | 5656 | { |
5219 | handlerRequestWearables(); | 5657 | handlerRequestWearables(); |
5220 | } | 5658 | } |
5221 | 5659 | ||
5222 | handlerRequestAvatarsData = OnRequestAvatarsData; | 5660 | Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData; |
5223 | 5661 | ||
5224 | if (handlerRequestAvatarsData != null) | 5662 | if (handlerRequestAvatarsData != null) |
5225 | { | 5663 | { |
@@ -5240,7 +5678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5240 | } | 5678 | } |
5241 | #endregion | 5679 | #endregion |
5242 | 5680 | ||
5243 | handlerSetAppearance = OnSetAppearance; | 5681 | SetAppearance handlerSetAppearance = OnSetAppearance; |
5244 | if (handlerSetAppearance != null) | 5682 | if (handlerSetAppearance != null) |
5245 | { | 5683 | { |
5246 | // Temporarily protect ourselves from the mantis #951 failure. | 5684 | // Temporarily protect ourselves from the mantis #951 failure. |
@@ -5291,7 +5729,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5291 | wearingArgs.NowWearing.Add(wearable); | 5729 | wearingArgs.NowWearing.Add(wearable); |
5292 | } | 5730 | } |
5293 | 5731 | ||
5294 | handlerAvatarNowWearing = OnAvatarNowWearing; | 5732 | AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing; |
5295 | if (handlerAvatarNowWearing != null) | 5733 | if (handlerAvatarNowWearing != null) |
5296 | { | 5734 | { |
5297 | handlerAvatarNowWearing(this, wearingArgs); | 5735 | handlerAvatarNowWearing(this, wearingArgs); |
@@ -5300,7 +5738,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5300 | break; | 5738 | break; |
5301 | 5739 | ||
5302 | case PacketType.RezSingleAttachmentFromInv: | 5740 | case PacketType.RezSingleAttachmentFromInv: |
5303 | handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; | 5741 | RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; |
5304 | if (handlerRezSingleAttachment != null) | 5742 | if (handlerRezSingleAttachment != null) |
5305 | { | 5743 | { |
5306 | RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; | 5744 | RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; |
@@ -5321,7 +5759,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5321 | break; | 5759 | break; |
5322 | 5760 | ||
5323 | case PacketType.RezMultipleAttachmentsFromInv: | 5761 | case PacketType.RezMultipleAttachmentsFromInv: |
5324 | handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; | 5762 | RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; |
5325 | if (handlerRezMultipleAttachments != null) | 5763 | if (handlerRezMultipleAttachments != null) |
5326 | { | 5764 | { |
5327 | RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; | 5765 | RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; |
@@ -5332,7 +5770,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5332 | break; | 5770 | break; |
5333 | 5771 | ||
5334 | case PacketType.DetachAttachmentIntoInv: | 5772 | case PacketType.DetachAttachmentIntoInv: |
5335 | handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; | 5773 | UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; |
5336 | if (handlerDetachAttachmentIntoInv != null) | 5774 | if (handlerDetachAttachmentIntoInv != null) |
5337 | { | 5775 | { |
5338 | DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; | 5776 | DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; |
@@ -5362,7 +5800,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5362 | } | 5800 | } |
5363 | #endregion | 5801 | #endregion |
5364 | 5802 | ||
5365 | handlerObjectAttach = OnObjectAttach; | 5803 | ObjectAttach handlerObjectAttach = OnObjectAttach; |
5366 | 5804 | ||
5367 | if (handlerObjectAttach != null) | 5805 | if (handlerObjectAttach != null) |
5368 | { | 5806 | { |
@@ -5389,7 +5827,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5389 | for (int j = 0; j < dett.ObjectData.Length; j++) | 5827 | for (int j = 0; j < dett.ObjectData.Length; j++) |
5390 | { | 5828 | { |
5391 | uint obj = dett.ObjectData[j].ObjectLocalID; | 5829 | uint obj = dett.ObjectData[j].ObjectLocalID; |
5392 | handlerObjectDetach = OnObjectDetach; | 5830 | ObjectDeselect handlerObjectDetach = OnObjectDetach; |
5393 | if (handlerObjectDetach != null) | 5831 | if (handlerObjectDetach != null) |
5394 | { | 5832 | { |
5395 | handlerObjectDetach(obj, this); | 5833 | handlerObjectDetach(obj, this); |
@@ -5413,7 +5851,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5413 | for (int j = 0; j < dropp.ObjectData.Length; j++) | 5851 | for (int j = 0; j < dropp.ObjectData.Length; j++) |
5414 | { | 5852 | { |
5415 | uint obj = dropp.ObjectData[j].ObjectLocalID; | 5853 | uint obj = dropp.ObjectData[j].ObjectLocalID; |
5416 | handlerObjectDrop = OnObjectDrop; | 5854 | ObjectDrop handlerObjectDrop = OnObjectDrop; |
5417 | if (handlerObjectDrop != null) | 5855 | if (handlerObjectDrop != null) |
5418 | { | 5856 | { |
5419 | handlerObjectDrop(obj, this); | 5857 | handlerObjectDrop(obj, this); |
@@ -5433,14 +5871,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5433 | } | 5871 | } |
5434 | #endregion | 5872 | #endregion |
5435 | 5873 | ||
5436 | handlerSetAlwaysRun = OnSetAlwaysRun; | 5874 | SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun; |
5437 | if (handlerSetAlwaysRun != null) | 5875 | if (handlerSetAlwaysRun != null) |
5438 | handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); | 5876 | handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); |
5439 | 5877 | ||
5440 | break; | 5878 | break; |
5441 | 5879 | ||
5442 | case PacketType.CompleteAgentMovement: | 5880 | case PacketType.CompleteAgentMovement: |
5443 | handlerCompleteMovementToRegion = OnCompleteMovementToRegion; | 5881 | GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; |
5444 | if (handlerCompleteMovementToRegion != null) | 5882 | if (handlerCompleteMovementToRegion != null) |
5445 | { | 5883 | { |
5446 | handlerCompleteMovementToRegion(); | 5884 | handlerCompleteMovementToRegion(); |
@@ -5509,7 +5947,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5509 | arg.HeadRotation = x.HeadRotation; | 5947 | arg.HeadRotation = x.HeadRotation; |
5510 | arg.SessionID = x.SessionID; | 5948 | arg.SessionID = x.SessionID; |
5511 | arg.State = x.State; | 5949 | arg.State = x.State; |
5512 | handlerAgentUpdate = OnAgentUpdate; | 5950 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; |
5513 | lastarg = arg; // save this set of arguments for nexttime | 5951 | lastarg = arg; // save this set of arguments for nexttime |
5514 | if (handlerAgentUpdate != null) | 5952 | if (handlerAgentUpdate != null) |
5515 | OnAgentUpdate(this, arg); | 5953 | OnAgentUpdate(this, arg); |
@@ -5532,8 +5970,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5532 | } | 5970 | } |
5533 | #endregion | 5971 | #endregion |
5534 | 5972 | ||
5535 | handlerStartAnim = null; | 5973 | StartAnim handlerStartAnim = null; |
5536 | handlerStopAnim = null; | 5974 | StopAnim handlerStopAnim = null; |
5537 | 5975 | ||
5538 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | 5976 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) |
5539 | { | 5977 | { |
@@ -5570,7 +6008,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5570 | } | 6008 | } |
5571 | #endregion | 6009 | #endregion |
5572 | 6010 | ||
5573 | handlerAgentRequestSit = OnAgentRequestSit; | 6011 | AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; |
5574 | if (handlerAgentRequestSit != null) | 6012 | if (handlerAgentRequestSit != null) |
5575 | handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, | 6013 | handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, |
5576 | agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); | 6014 | agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); |
@@ -5591,7 +6029,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5591 | } | 6029 | } |
5592 | #endregion | 6030 | #endregion |
5593 | 6031 | ||
5594 | handlerAgentSit = OnAgentSit; | 6032 | AgentSit handlerAgentSit = OnAgentSit; |
5595 | if (handlerAgentSit != null) | 6033 | if (handlerAgentSit != null) |
5596 | { | 6034 | { |
5597 | OnAgentSit(this, agentSit.AgentData.AgentID); | 6035 | OnAgentSit(this, agentSit.AgentData.AgentID); |
@@ -5609,7 +6047,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5609 | } | 6047 | } |
5610 | #endregion | 6048 | #endregion |
5611 | 6049 | ||
5612 | handlerSoundTrigger = OnSoundTrigger; | 6050 | SoundTrigger handlerSoundTrigger = OnSoundTrigger; |
5613 | if (handlerSoundTrigger != null) | 6051 | if (handlerSoundTrigger != null) |
5614 | { | 6052 | { |
5615 | handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, | 6053 | handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, |
@@ -5636,7 +6074,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5636 | AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; | 6074 | AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; |
5637 | //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name)); | 6075 | //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name)); |
5638 | 6076 | ||
5639 | handlerAvatarPickerRequest = OnAvatarPickerRequest; | 6077 | AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest; |
5640 | if (handlerAvatarPickerRequest != null) | 6078 | if (handlerAvatarPickerRequest != null) |
5641 | { | 6079 | { |
5642 | handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, | 6080 | handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, |
@@ -5656,7 +6094,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5656 | } | 6094 | } |
5657 | #endregion | 6095 | #endregion |
5658 | 6096 | ||
5659 | handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; | 6097 | FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; |
5660 | 6098 | ||
5661 | if (handlerAgentDataUpdateRequest != null) | 6099 | if (handlerAgentDataUpdateRequest != null) |
5662 | { | 6100 | { |
@@ -5666,7 +6104,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5666 | break; | 6104 | break; |
5667 | 6105 | ||
5668 | case PacketType.UserInfoRequest: | 6106 | case PacketType.UserInfoRequest: |
5669 | handlerUserInfoRequest = OnUserInfoRequest; | 6107 | UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest; |
5670 | if (handlerUserInfoRequest != null) | 6108 | if (handlerUserInfoRequest != null) |
5671 | { | 6109 | { |
5672 | handlerUserInfoRequest(this); | 6110 | handlerUserInfoRequest(this); |
@@ -5689,7 +6127,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5689 | } | 6127 | } |
5690 | #endregion | 6128 | #endregion |
5691 | 6129 | ||
5692 | handlerUpdateUserInfo = OnUpdateUserInfo; | 6130 | UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo; |
5693 | if (handlerUpdateUserInfo != null) | 6131 | if (handlerUpdateUserInfo != null) |
5694 | { | 6132 | { |
5695 | bool visible = true; | 6133 | bool visible = true; |
@@ -5718,7 +6156,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5718 | 6156 | ||
5719 | if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) | 6157 | if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) |
5720 | { | 6158 | { |
5721 | handlerSetStartLocationRequest = OnSetStartLocationRequest; | 6159 | TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest; |
5722 | if (handlerSetStartLocationRequest != null) | 6160 | if (handlerSetStartLocationRequest != null) |
5723 | { | 6161 | { |
5724 | handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, | 6162 | handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, |
@@ -5740,23 +6178,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5740 | } | 6178 | } |
5741 | #endregion | 6179 | #endregion |
5742 | 6180 | ||
5743 | m_PacketHandler.PacketQueue.SetThrottleFromClient(atpack.Throttle.Throttles); | 6181 | m_udpClient.SetThrottles(atpack.Throttle.Throttles); |
5744 | break; | 6182 | break; |
5745 | 6183 | ||
5746 | case PacketType.AgentPause: | 6184 | case PacketType.AgentPause: |
5747 | m_probesWithNoIngressPackets = 0; | 6185 | m_udpClient.IsPaused = true; |
5748 | m_clientBlocked = true; | ||
5749 | break; | 6186 | break; |
5750 | 6187 | ||
5751 | case PacketType.AgentResume: | 6188 | case PacketType.AgentResume: |
5752 | m_probesWithNoIngressPackets = 0; | 6189 | m_udpClient.IsPaused = false; |
5753 | m_clientBlocked = false; | 6190 | SendStartPingCheck(m_udpClient.CurrentPingSequence++); |
5754 | SendStartPingCheck(0); | ||
5755 | 6191 | ||
5756 | break; | 6192 | break; |
5757 | 6193 | ||
5758 | case PacketType.ForceScriptControlRelease: | 6194 | case PacketType.ForceScriptControlRelease: |
5759 | handlerForceReleaseControls = OnForceReleaseControls; | 6195 | ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls; |
5760 | if (handlerForceReleaseControls != null) | 6196 | if (handlerForceReleaseControls != null) |
5761 | { | 6197 | { |
5762 | handlerForceReleaseControls(this, AgentId); | 6198 | handlerForceReleaseControls(this, AgentId); |
@@ -5790,7 +6226,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5790 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); | 6226 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); |
5791 | } | 6227 | } |
5792 | } | 6228 | } |
5793 | handlerLinkObjects = OnLinkObjects; | 6229 | LinkObjects handlerLinkObjects = OnLinkObjects; |
5794 | if (handlerLinkObjects != null) | 6230 | if (handlerLinkObjects != null) |
5795 | { | 6231 | { |
5796 | handlerLinkObjects(this, parentprimid, childrenprims); | 6232 | handlerLinkObjects(this, parentprimid, childrenprims); |
@@ -5818,7 +6254,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5818 | { | 6254 | { |
5819 | prims.Add(delink.ObjectData[i].ObjectLocalID); | 6255 | prims.Add(delink.ObjectData[i].ObjectLocalID); |
5820 | } | 6256 | } |
5821 | handlerDelinkObjects = OnDelinkObjects; | 6257 | DelinkObjects handlerDelinkObjects = OnDelinkObjects; |
5822 | if (handlerDelinkObjects != null) | 6258 | if (handlerDelinkObjects != null) |
5823 | { | 6259 | { |
5824 | handlerDelinkObjects(prims); | 6260 | handlerDelinkObjects(prims); |
@@ -5850,7 +6286,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5850 | //Check to see if adding the prim is allowed; useful for any module wanting to restrict the | 6286 | //Check to see if adding the prim is allowed; useful for any module wanting to restrict the |
5851 | //object from rezing initially | 6287 | //object from rezing initially |
5852 | 6288 | ||
5853 | handlerAddPrim = OnAddPrim; | 6289 | AddNewPrim handlerAddPrim = OnAddPrim; |
5854 | if (handlerAddPrim != null) | 6290 | if (handlerAddPrim != null) |
5855 | handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); | 6291 | handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); |
5856 | } | 6292 | } |
@@ -5868,7 +6304,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5868 | } | 6304 | } |
5869 | #endregion | 6305 | #endregion |
5870 | 6306 | ||
5871 | handlerUpdatePrimShape = null; | 6307 | UpdateShape handlerUpdatePrimShape = null; |
5872 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) | 6308 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) |
5873 | { | 6309 | { |
5874 | handlerUpdatePrimShape = OnUpdatePrimShape; | 6310 | handlerUpdatePrimShape = OnUpdatePrimShape; |
@@ -5913,7 +6349,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5913 | } | 6349 | } |
5914 | #endregion | 6350 | #endregion |
5915 | 6351 | ||
5916 | handlerUpdateExtraParams = OnUpdateExtraParams; | 6352 | ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams; |
5917 | if (handlerUpdateExtraParams != null) | 6353 | if (handlerUpdateExtraParams != null) |
5918 | { | 6354 | { |
5919 | for (int i = 0 ; i < extraPar.ObjectData.Length ; i++) | 6355 | for (int i = 0 ; i < extraPar.ObjectData.Length ; i++) |
@@ -5938,7 +6374,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5938 | 6374 | ||
5939 | ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; | 6375 | ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; |
5940 | 6376 | ||
5941 | handlerObjectDuplicate = null; | 6377 | ObjectDuplicate handlerObjectDuplicate = null; |
5942 | 6378 | ||
5943 | for (int i = 0; i < dupe.ObjectData.Length; i++) | 6379 | for (int i = 0; i < dupe.ObjectData.Length; i++) |
5944 | { | 6380 | { |
@@ -5965,7 +6401,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5965 | } | 6401 | } |
5966 | #endregion | 6402 | #endregion |
5967 | 6403 | ||
5968 | handlerObjectRequest = null; | 6404 | ObjectRequest handlerObjectRequest = null; |
5969 | 6405 | ||
5970 | for (int i = 0; i < incomingRequest.ObjectData.Length; i++) | 6406 | for (int i = 0; i < incomingRequest.ObjectData.Length; i++) |
5971 | { | 6407 | { |
@@ -5988,7 +6424,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5988 | } | 6424 | } |
5989 | #endregion | 6425 | #endregion |
5990 | 6426 | ||
5991 | handlerObjectSelect = null; | 6427 | ObjectSelect handlerObjectSelect = null; |
5992 | 6428 | ||
5993 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | 6429 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) |
5994 | { | 6430 | { |
@@ -6011,7 +6447,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6011 | } | 6447 | } |
6012 | #endregion | 6448 | #endregion |
6013 | 6449 | ||
6014 | handlerObjectDeselect = null; | 6450 | ObjectDeselect handlerObjectDeselect = null; |
6015 | 6451 | ||
6016 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) | 6452 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) |
6017 | { | 6453 | { |
@@ -6038,7 +6474,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6038 | 6474 | ||
6039 | for (int i = 0; i < position.ObjectData.Length; i++) | 6475 | for (int i = 0; i < position.ObjectData.Length; i++) |
6040 | { | 6476 | { |
6041 | handlerUpdateVector = OnUpdatePrimGroupPosition; | 6477 | UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition; |
6042 | if (handlerUpdateVector != null) | 6478 | if (handlerUpdateVector != null) |
6043 | handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this); | 6479 | handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this); |
6044 | } | 6480 | } |
@@ -6059,7 +6495,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6059 | 6495 | ||
6060 | for (int i = 0; i < scale.ObjectData.Length; i++) | 6496 | for (int i = 0; i < scale.ObjectData.Length; i++) |
6061 | { | 6497 | { |
6062 | handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; | 6498 | UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; |
6063 | if (handlerUpdatePrimGroupScale != null) | 6499 | if (handlerUpdatePrimGroupScale != null) |
6064 | handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this); | 6500 | handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this); |
6065 | } | 6501 | } |
@@ -6080,7 +6516,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6080 | 6516 | ||
6081 | for (int i = 0; i < rotation.ObjectData.Length; i++) | 6517 | for (int i = 0; i < rotation.ObjectData.Length; i++) |
6082 | { | 6518 | { |
6083 | handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; | 6519 | UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; |
6084 | if (handlerUpdatePrimRotation != null) | 6520 | if (handlerUpdatePrimRotation != null) |
6085 | handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this); | 6521 | handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this); |
6086 | } | 6522 | } |
@@ -6098,7 +6534,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6098 | } | 6534 | } |
6099 | #endregion | 6535 | #endregion |
6100 | 6536 | ||
6101 | handlerUpdatePrimFlags = OnUpdatePrimFlags; | 6537 | UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags; |
6102 | 6538 | ||
6103 | if (handlerUpdatePrimFlags != null) | 6539 | if (handlerUpdatePrimFlags != null) |
6104 | { | 6540 | { |
@@ -6115,7 +6551,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6115 | case PacketType.ObjectImage: | 6551 | case PacketType.ObjectImage: |
6116 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; | 6552 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; |
6117 | 6553 | ||
6118 | handlerUpdatePrimTexture = null; | 6554 | UpdatePrimTexture handlerUpdatePrimTexture = null; |
6119 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | 6555 | for (int i = 0; i < imagePack.ObjectData.Length; i++) |
6120 | { | 6556 | { |
6121 | handlerUpdatePrimTexture = OnUpdatePrimTexture; | 6557 | handlerUpdatePrimTexture = OnUpdatePrimTexture; |
@@ -6138,7 +6574,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6138 | } | 6574 | } |
6139 | #endregion | 6575 | #endregion |
6140 | 6576 | ||
6141 | handlerGrabObject = OnGrabObject; | 6577 | GrabObject handlerGrabObject = OnGrabObject; |
6142 | 6578 | ||
6143 | if (handlerGrabObject != null) | 6579 | if (handlerGrabObject != null) |
6144 | { | 6580 | { |
@@ -6172,7 +6608,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6172 | } | 6608 | } |
6173 | #endregion | 6609 | #endregion |
6174 | 6610 | ||
6175 | handlerGrabUpdate = OnGrabUpdate; | 6611 | MoveObject handlerGrabUpdate = OnGrabUpdate; |
6176 | 6612 | ||
6177 | if (handlerGrabUpdate != null) | 6613 | if (handlerGrabUpdate != null) |
6178 | { | 6614 | { |
@@ -6207,7 +6643,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6207 | } | 6643 | } |
6208 | #endregion | 6644 | #endregion |
6209 | 6645 | ||
6210 | handlerDeGrabObject = OnDeGrabObject; | 6646 | DeGrabObject handlerDeGrabObject = OnDeGrabObject; |
6211 | if (handlerDeGrabObject != null) | 6647 | if (handlerDeGrabObject != null) |
6212 | { | 6648 | { |
6213 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); | 6649 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); |
@@ -6241,7 +6677,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6241 | } | 6677 | } |
6242 | #endregion | 6678 | #endregion |
6243 | 6679 | ||
6244 | handlerSpinStart = OnSpinStart; | 6680 | SpinStart handlerSpinStart = OnSpinStart; |
6245 | if (handlerSpinStart != null) | 6681 | if (handlerSpinStart != null) |
6246 | { | 6682 | { |
6247 | handlerSpinStart(spinStart.ObjectData.ObjectID, this); | 6683 | handlerSpinStart(spinStart.ObjectData.ObjectID, this); |
@@ -6265,7 +6701,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6265 | spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle); | 6701 | spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle); |
6266 | //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle); | 6702 | //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle); |
6267 | 6703 | ||
6268 | handlerSpinUpdate = OnSpinUpdate; | 6704 | SpinObject handlerSpinUpdate = OnSpinUpdate; |
6269 | if (handlerSpinUpdate != null) | 6705 | if (handlerSpinUpdate != null) |
6270 | { | 6706 | { |
6271 | handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); | 6707 | handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); |
@@ -6284,7 +6720,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6284 | } | 6720 | } |
6285 | #endregion | 6721 | #endregion |
6286 | 6722 | ||
6287 | handlerSpinStop = OnSpinStop; | 6723 | SpinStop handlerSpinStop = OnSpinStop; |
6288 | if (handlerSpinStop != null) | 6724 | if (handlerSpinStop != null) |
6289 | { | 6725 | { |
6290 | handlerSpinStop(spinStop.ObjectData.ObjectID, this); | 6726 | handlerSpinStop(spinStop.ObjectData.ObjectID, this); |
@@ -6303,7 +6739,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6303 | } | 6739 | } |
6304 | #endregion | 6740 | #endregion |
6305 | 6741 | ||
6306 | handlerObjectDescription = null; | 6742 | GenericCall7 handlerObjectDescription = null; |
6307 | 6743 | ||
6308 | for (int i = 0; i < objDes.ObjectData.Length; i++) | 6744 | for (int i = 0; i < objDes.ObjectData.Length; i++) |
6309 | { | 6745 | { |
@@ -6327,7 +6763,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6327 | } | 6763 | } |
6328 | #endregion | 6764 | #endregion |
6329 | 6765 | ||
6330 | handlerObjectName = null; | 6766 | GenericCall7 handlerObjectName = null; |
6331 | for (int i = 0; i < objName.ObjectData.Length; i++) | 6767 | for (int i = 0; i < objName.ObjectData.Length; i++) |
6332 | { | 6768 | { |
6333 | handlerObjectName = OnObjectName; | 6769 | handlerObjectName = OnObjectName; |
@@ -6355,7 +6791,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6355 | UUID AgentID = newobjPerms.AgentData.AgentID; | 6791 | UUID AgentID = newobjPerms.AgentData.AgentID; |
6356 | UUID SessionID = newobjPerms.AgentData.SessionID; | 6792 | UUID SessionID = newobjPerms.AgentData.SessionID; |
6357 | 6793 | ||
6358 | handlerObjectPermissions = null; | 6794 | ObjectPermissions handlerObjectPermissions = null; |
6359 | 6795 | ||
6360 | for (int i = 0; i < newobjPerms.ObjectData.Length; i++) | 6796 | for (int i = 0; i < newobjPerms.ObjectData.Length; i++) |
6361 | { | 6797 | { |
@@ -6404,7 +6840,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6404 | for (int i = 0; i < undoitem.ObjectData.Length; i++) | 6840 | for (int i = 0; i < undoitem.ObjectData.Length; i++) |
6405 | { | 6841 | { |
6406 | UUID objiD = undoitem.ObjectData[i].ObjectID; | 6842 | UUID objiD = undoitem.ObjectData[i].ObjectID; |
6407 | handlerOnUndo = OnUndo; | 6843 | AgentSit handlerOnUndo = OnUndo; |
6408 | if (handlerOnUndo != null) | 6844 | if (handlerOnUndo != null) |
6409 | { | 6845 | { |
6410 | handlerOnUndo(this, objiD); | 6846 | handlerOnUndo(this, objiD); |
@@ -6425,8 +6861,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6425 | } | 6861 | } |
6426 | #endregion | 6862 | #endregion |
6427 | 6863 | ||
6428 | handlerObjectDuplicateOnRay = null; | 6864 | ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null; |
6429 | |||
6430 | 6865 | ||
6431 | for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) | 6866 | for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) |
6432 | { | 6867 | { |
@@ -6456,7 +6891,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6456 | 6891 | ||
6457 | RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; | 6892 | RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; |
6458 | 6893 | ||
6459 | handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; | 6894 | RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; |
6460 | 6895 | ||
6461 | if (handlerRequestObjectPropertiesFamily != null) | 6896 | if (handlerRequestObjectPropertiesFamily != null) |
6462 | { | 6897 | { |
@@ -6468,7 +6903,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6468 | case PacketType.ObjectIncludeInSearch: | 6903 | case PacketType.ObjectIncludeInSearch: |
6469 | //This lets us set objects to appear in search (stuff like DataSnapshot, etc) | 6904 | //This lets us set objects to appear in search (stuff like DataSnapshot, etc) |
6470 | ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; | 6905 | ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; |
6471 | handlerObjectIncludeInSearch = null; | 6906 | ObjectIncludeInSearch handlerObjectIncludeInSearch = null; |
6472 | 6907 | ||
6473 | #region Packet Session and User Check | 6908 | #region Packet Session and User Check |
6474 | if (m_checkPackets) | 6909 | if (m_checkPackets) |
@@ -6505,7 +6940,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6505 | } | 6940 | } |
6506 | #endregion | 6941 | #endregion |
6507 | 6942 | ||
6508 | handlerScriptAnswer = OnScriptAnswer; | 6943 | ScriptAnswer handlerScriptAnswer = OnScriptAnswer; |
6509 | if (handlerScriptAnswer != null) | 6944 | if (handlerScriptAnswer != null) |
6510 | { | 6945 | { |
6511 | handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); | 6946 | handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); |
@@ -6524,7 +6959,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6524 | } | 6959 | } |
6525 | #endregion | 6960 | #endregion |
6526 | 6961 | ||
6527 | handlerObjectClickAction = OnObjectClickAction; | 6962 | GenericCall7 handlerObjectClickAction = OnObjectClickAction; |
6528 | if (handlerObjectClickAction != null) | 6963 | if (handlerObjectClickAction != null) |
6529 | { | 6964 | { |
6530 | foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData) | 6965 | foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData) |
@@ -6548,7 +6983,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6548 | } | 6983 | } |
6549 | #endregion | 6984 | #endregion |
6550 | 6985 | ||
6551 | handlerObjectMaterial = OnObjectMaterial; | 6986 | GenericCall7 handlerObjectMaterial = OnObjectMaterial; |
6552 | if (handlerObjectMaterial != null) | 6987 | if (handlerObjectMaterial != null) |
6553 | { | 6988 | { |
6554 | foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData) | 6989 | foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData) |
@@ -6702,7 +7137,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6702 | // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); | 7137 | // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); |
6703 | UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); | 7138 | UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); |
6704 | 7139 | ||
6705 | handlerAssetUploadRequest = OnAssetUploadRequest; | 7140 | UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest; |
6706 | 7141 | ||
6707 | if (handlerAssetUploadRequest != null) | 7142 | if (handlerAssetUploadRequest != null) |
6708 | { | 7143 | { |
@@ -6715,7 +7150,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6715 | case PacketType.RequestXfer: | 7150 | case PacketType.RequestXfer: |
6716 | RequestXferPacket xferReq = (RequestXferPacket)Pack; | 7151 | RequestXferPacket xferReq = (RequestXferPacket)Pack; |
6717 | 7152 | ||
6718 | handlerRequestXfer = OnRequestXfer; | 7153 | RequestXfer handlerRequestXfer = OnRequestXfer; |
6719 | 7154 | ||
6720 | if (handlerRequestXfer != null) | 7155 | if (handlerRequestXfer != null) |
6721 | { | 7156 | { |
@@ -6725,7 +7160,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6725 | case PacketType.SendXferPacket: | 7160 | case PacketType.SendXferPacket: |
6726 | SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; | 7161 | SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; |
6727 | 7162 | ||
6728 | handlerXferReceive = OnXferReceive; | 7163 | XferReceive handlerXferReceive = OnXferReceive; |
6729 | if (handlerXferReceive != null) | 7164 | if (handlerXferReceive != null) |
6730 | { | 7165 | { |
6731 | handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); | 7166 | handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); |
@@ -6734,7 +7169,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6734 | case PacketType.ConfirmXferPacket: | 7169 | case PacketType.ConfirmXferPacket: |
6735 | ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; | 7170 | ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; |
6736 | 7171 | ||
6737 | handlerConfirmXfer = OnConfirmXfer; | 7172 | ConfirmXfer handlerConfirmXfer = OnConfirmXfer; |
6738 | if (handlerConfirmXfer != null) | 7173 | if (handlerConfirmXfer != null) |
6739 | { | 7174 | { |
6740 | handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); | 7175 | handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); |
@@ -6742,7 +7177,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6742 | break; | 7177 | break; |
6743 | case PacketType.AbortXfer: | 7178 | case PacketType.AbortXfer: |
6744 | AbortXferPacket abortXfer = (AbortXferPacket)Pack; | 7179 | AbortXferPacket abortXfer = (AbortXferPacket)Pack; |
6745 | handlerAbortXfer = OnAbortXfer; | 7180 | AbortXfer handlerAbortXfer = OnAbortXfer; |
6746 | if (handlerAbortXfer != null) | 7181 | if (handlerAbortXfer != null) |
6747 | { | 7182 | { |
6748 | handlerAbortXfer(this, abortXfer.XferID.ID); | 7183 | handlerAbortXfer(this, abortXfer.XferID.ID); |
@@ -6761,7 +7196,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6761 | } | 7196 | } |
6762 | #endregion | 7197 | #endregion |
6763 | 7198 | ||
6764 | handlerCreateInventoryFolder = OnCreateNewInventoryFolder; | 7199 | CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder; |
6765 | if (handlerCreateInventoryFolder != null) | 7200 | if (handlerCreateInventoryFolder != null) |
6766 | { | 7201 | { |
6767 | handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID, | 7202 | handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID, |
@@ -6784,7 +7219,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6784 | } | 7219 | } |
6785 | #endregion | 7220 | #endregion |
6786 | 7221 | ||
6787 | handlerUpdateInventoryFolder = null; | 7222 | UpdateInventoryFolder handlerUpdateInventoryFolder = null; |
6788 | 7223 | ||
6789 | for (int i = 0; i < invFolderx.FolderData.Length; i++) | 7224 | for (int i = 0; i < invFolderx.FolderData.Length; i++) |
6790 | { | 7225 | { |
@@ -6813,7 +7248,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6813 | } | 7248 | } |
6814 | #endregion | 7249 | #endregion |
6815 | 7250 | ||
6816 | handlerMoveInventoryFolder = null; | 7251 | MoveInventoryFolder handlerMoveInventoryFolder = null; |
6817 | 7252 | ||
6818 | for (int i = 0; i < invFoldery.InventoryData.Length; i++) | 7253 | for (int i = 0; i < invFoldery.InventoryData.Length; i++) |
6819 | { | 7254 | { |
@@ -6838,7 +7273,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6838 | } | 7273 | } |
6839 | #endregion | 7274 | #endregion |
6840 | 7275 | ||
6841 | handlerCreateNewInventoryItem = OnCreateNewInventoryItem; | 7276 | CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem; |
6842 | if (handlerCreateNewInventoryItem != null) | 7277 | if (handlerCreateNewInventoryItem != null) |
6843 | { | 7278 | { |
6844 | handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, | 7279 | handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, |
@@ -6867,7 +7302,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6867 | } | 7302 | } |
6868 | #endregion | 7303 | #endregion |
6869 | 7304 | ||
6870 | handlerFetchInventory = null; | 7305 | FetchInventory handlerFetchInventory = null; |
6871 | 7306 | ||
6872 | for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++) | 7307 | for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++) |
6873 | { | 7308 | { |
@@ -6893,7 +7328,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6893 | } | 7328 | } |
6894 | #endregion | 7329 | #endregion |
6895 | 7330 | ||
6896 | handlerFetchInventoryDescendents = OnFetchInventoryDescendents; | 7331 | FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents; |
6897 | if (handlerFetchInventoryDescendents != null) | 7332 | if (handlerFetchInventoryDescendents != null) |
6898 | { | 7333 | { |
6899 | handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, | 7334 | handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, |
@@ -6913,7 +7348,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6913 | } | 7348 | } |
6914 | #endregion | 7349 | #endregion |
6915 | 7350 | ||
6916 | handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; | 7351 | PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; |
6917 | if (handlerPurgeInventoryDescendents != null) | 7352 | if (handlerPurgeInventoryDescendents != null) |
6918 | { | 7353 | { |
6919 | handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); | 7354 | handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); |
@@ -6933,7 +7368,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6933 | 7368 | ||
6934 | if (OnUpdateInventoryItem != null) | 7369 | if (OnUpdateInventoryItem != null) |
6935 | { | 7370 | { |
6936 | handlerUpdateInventoryItem = null; | 7371 | UpdateInventoryItem handlerUpdateInventoryItem = null; |
6937 | for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) | 7372 | for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) |
6938 | { | 7373 | { |
6939 | handlerUpdateInventoryItem = OnUpdateInventoryItem; | 7374 | handlerUpdateInventoryItem = OnUpdateInventoryItem; |
@@ -6955,49 +7390,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6955 | itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice; | 7390 | itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice; |
6956 | itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType; | 7391 | itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType; |
6957 | itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags; | 7392 | itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags; |
6958 | /* | 7393 | |
6959 | OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, | ||
6960 | inventoryItemUpdate.InventoryData[i].ItemID, | ||
6961 | Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name), | ||
6962 | Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description), | ||
6963 | inventoryItemUpdate.InventoryData[i].NextOwnerMask); | ||
6964 | */ | ||
6965 | OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, | 7394 | OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, |
6966 | inventoryItemUpdate.InventoryData[i].ItemID, | 7395 | inventoryItemUpdate.InventoryData[i].ItemID, |
6967 | itemUpd); | 7396 | itemUpd); |
6968 | } | 7397 | } |
6969 | } | 7398 | } |
6970 | } | 7399 | } |
6971 | //m_log.Debug(Pack.ToString()); | ||
6972 | /*for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) | ||
6973 | { | ||
6974 | if (inventoryItemUpdate.InventoryData[i].TransactionID != UUID.Zero) | ||
6975 | { | ||
6976 | AssetBase asset = m_assetCache.GetAsset(inventoryItemUpdate.InventoryData[i].TransactionID.Combine(this.SecureSessionId)); | ||
6977 | if (asset != null) | ||
6978 | { | ||
6979 | // m_log.Debug("updating inventory item, found asset" + asset.FullID.ToString() + " already in cache"); | ||
6980 | m_inventoryCache.UpdateInventoryItemAsset(this, inventoryItemUpdate.InventoryData[i].ItemID, asset); | ||
6981 | } | ||
6982 | else | ||
6983 | { | ||
6984 | asset = this.UploadAssets.AddUploadToAssetCache(inventoryItemUpdate.InventoryData[i].TransactionID); | ||
6985 | if (asset != null) | ||
6986 | { | ||
6987 | //m_log.Debug("updating inventory item, adding asset" + asset.FullID.ToString() + " to cache"); | ||
6988 | m_inventoryCache.UpdateInventoryItemAsset(this, inventoryItemUpdate.InventoryData[i].ItemID, asset); | ||
6989 | } | ||
6990 | else | ||
6991 | { | ||
6992 | //m_log.Debug("trying to update inventory item, but asset is null"); | ||
6993 | } | ||
6994 | } | ||
6995 | } | ||
6996 | else | ||
6997 | { | ||
6998 | m_inventoryCache.UpdateInventoryItemDetails(this, inventoryItemUpdate.InventoryData[i].ItemID, inventoryItemUpdate.InventoryData[i]); ; | ||
6999 | } | ||
7000 | }*/ | ||
7001 | break; | 7400 | break; |
7002 | case PacketType.CopyInventoryItem: | 7401 | case PacketType.CopyInventoryItem: |
7003 | CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; | 7402 | CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; |
@@ -7011,7 +7410,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7011 | } | 7410 | } |
7012 | #endregion | 7411 | #endregion |
7013 | 7412 | ||
7014 | handlerCopyInventoryItem = null; | 7413 | CopyInventoryItem handlerCopyInventoryItem = null; |
7015 | if (OnCopyInventoryItem != null) | 7414 | if (OnCopyInventoryItem != null) |
7016 | { | 7415 | { |
7017 | foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) | 7416 | foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) |
@@ -7040,7 +7439,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7040 | 7439 | ||
7041 | if (OnMoveInventoryItem != null) | 7440 | if (OnMoveInventoryItem != null) |
7042 | { | 7441 | { |
7043 | handlerMoveInventoryItem = null; | 7442 | MoveInventoryItem handlerMoveInventoryItem = null; |
7044 | InventoryItemBase itm = null; | 7443 | InventoryItemBase itm = null; |
7045 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 7444 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
7046 | foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) | 7445 | foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) |
@@ -7073,7 +7472,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7073 | 7472 | ||
7074 | if (OnRemoveInventoryItem != null) | 7473 | if (OnRemoveInventoryItem != null) |
7075 | { | 7474 | { |
7076 | handlerRemoveInventoryItem = null; | 7475 | RemoveInventoryItem handlerRemoveInventoryItem = null; |
7077 | List<UUID> uuids = new List<UUID>(); | 7476 | List<UUID> uuids = new List<UUID>(); |
7078 | foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) | 7477 | foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) |
7079 | { | 7478 | { |
@@ -7101,7 +7500,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7101 | 7500 | ||
7102 | if (OnRemoveInventoryFolder != null) | 7501 | if (OnRemoveInventoryFolder != null) |
7103 | { | 7502 | { |
7104 | handlerRemoveInventoryFolder = null; | 7503 | RemoveInventoryFolder handlerRemoveInventoryFolder = null; |
7105 | List<UUID> uuids = new List<UUID>(); | 7504 | List<UUID> uuids = new List<UUID>(); |
7106 | foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) | 7505 | foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) |
7107 | { | 7506 | { |
@@ -7126,7 +7525,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7126 | #endregion | 7525 | #endregion |
7127 | if (OnRemoveInventoryFolder != null) | 7526 | if (OnRemoveInventoryFolder != null) |
7128 | { | 7527 | { |
7129 | handlerRemoveInventoryFolder = null; | 7528 | RemoveInventoryFolder handlerRemoveInventoryFolder = null; |
7130 | List<UUID> uuids = new List<UUID>(); | 7529 | List<UUID> uuids = new List<UUID>(); |
7131 | foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) | 7530 | foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) |
7132 | { | 7531 | { |
@@ -7141,7 +7540,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7141 | 7540 | ||
7142 | if (OnRemoveInventoryItem != null) | 7541 | if (OnRemoveInventoryItem != null) |
7143 | { | 7542 | { |
7144 | handlerRemoveInventoryItem = null; | 7543 | RemoveInventoryItem handlerRemoveInventoryItem = null; |
7145 | List<UUID> uuids = new List<UUID>(); | 7544 | List<UUID> uuids = new List<UUID>(); |
7146 | foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) | 7545 | foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) |
7147 | { | 7546 | { |
@@ -7166,7 +7565,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7166 | } | 7565 | } |
7167 | #endregion | 7566 | #endregion |
7168 | 7567 | ||
7169 | handlerRequestTaskInventory = OnRequestTaskInventory; | 7568 | RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory; |
7170 | if (handlerRequestTaskInventory != null) | 7569 | if (handlerRequestTaskInventory != null) |
7171 | { | 7570 | { |
7172 | handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); | 7571 | handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); |
@@ -7188,7 +7587,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7188 | { | 7587 | { |
7189 | if (updatetask.UpdateData.Key == 0) | 7588 | if (updatetask.UpdateData.Key == 0) |
7190 | { | 7589 | { |
7191 | handlerUpdateTaskInventory = OnUpdateTaskInventory; | 7590 | UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory; |
7192 | if (handlerUpdateTaskInventory != null) | 7591 | if (handlerUpdateTaskInventory != null) |
7193 | { | 7592 | { |
7194 | TaskInventoryItem newTaskItem = new TaskInventoryItem(); | 7593 | TaskInventoryItem newTaskItem = new TaskInventoryItem(); |
@@ -7232,7 +7631,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7232 | } | 7631 | } |
7233 | #endregion | 7632 | #endregion |
7234 | 7633 | ||
7235 | handlerRemoveTaskItem = OnRemoveTaskItem; | 7634 | RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem; |
7236 | 7635 | ||
7237 | if (handlerRemoveTaskItem != null) | 7636 | if (handlerRemoveTaskItem != null) |
7238 | { | 7637 | { |
@@ -7254,7 +7653,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7254 | } | 7653 | } |
7255 | #endregion | 7654 | #endregion |
7256 | 7655 | ||
7257 | handlerMoveTaskItem = OnMoveTaskItem; | 7656 | MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem; |
7258 | 7657 | ||
7259 | if (handlerMoveTaskItem != null) | 7658 | if (handlerMoveTaskItem != null) |
7260 | { | 7659 | { |
@@ -7279,7 +7678,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7279 | } | 7678 | } |
7280 | #endregion | 7679 | #endregion |
7281 | 7680 | ||
7282 | handlerRezScript = OnRezScript; | 7681 | RezScript handlerRezScript = OnRezScript; |
7283 | InventoryItemBase item = new InventoryItemBase(); | 7682 | InventoryItemBase item = new InventoryItemBase(); |
7284 | item.ID = rezScriptx.InventoryBlock.ItemID; | 7683 | item.ID = rezScriptx.InventoryBlock.ItemID; |
7285 | item.Folder = rezScriptx.InventoryBlock.FolderID; | 7684 | item.Folder = rezScriptx.InventoryBlock.FolderID; |
@@ -7322,7 +7721,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7322 | } | 7721 | } |
7323 | #endregion | 7722 | #endregion |
7324 | 7723 | ||
7325 | handlerRequestMapBlocks = OnRequestMapBlocks; | 7724 | RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks; |
7326 | if (handlerRequestMapBlocks != null) | 7725 | if (handlerRequestMapBlocks != null) |
7327 | { | 7726 | { |
7328 | handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, | 7727 | handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, |
@@ -7343,7 +7742,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7343 | 7742 | ||
7344 | string mapName = Util.UTF8.GetString(map.NameData.Name, 0, | 7743 | string mapName = Util.UTF8.GetString(map.NameData.Name, 0, |
7345 | map.NameData.Name.Length - 1); | 7744 | map.NameData.Name.Length - 1); |
7346 | handlerMapNameRequest = OnMapNameRequest; | 7745 | RequestMapName handlerMapNameRequest = OnMapNameRequest; |
7347 | if (handlerMapNameRequest != null) | 7746 | if (handlerMapNameRequest != null) |
7348 | { | 7747 | { |
7349 | handlerMapNameRequest(this, mapName); | 7748 | handlerMapNameRequest(this, mapName); |
@@ -7394,7 +7793,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7394 | else | 7793 | else |
7395 | { | 7794 | { |
7396 | // Teleport home request | 7795 | // Teleport home request |
7397 | handlerTeleportHomeRequest = OnTeleportHomeRequest; | 7796 | UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest; |
7398 | if (handlerTeleportHomeRequest != null) | 7797 | if (handlerTeleportHomeRequest != null) |
7399 | { | 7798 | { |
7400 | handlerTeleportHomeRequest(AgentId, this); | 7799 | handlerTeleportHomeRequest(AgentId, this); |
@@ -7402,7 +7801,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7402 | break; | 7801 | break; |
7403 | } | 7802 | } |
7404 | 7803 | ||
7405 | handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; | 7804 | TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; |
7406 | if (handlerTeleportLandmarkRequest != null) | 7805 | if (handlerTeleportLandmarkRequest != null) |
7407 | { | 7806 | { |
7408 | handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position); | 7807 | handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position); |
@@ -7433,7 +7832,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7433 | } | 7832 | } |
7434 | #endregion | 7833 | #endregion |
7435 | 7834 | ||
7436 | handlerTeleportLocationRequest = OnTeleportLocationRequest; | 7835 | TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest; |
7437 | if (handlerTeleportLocationRequest != null) | 7836 | if (handlerTeleportLocationRequest != null) |
7438 | { | 7837 | { |
7439 | handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, | 7838 | handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, |
@@ -7456,7 +7855,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7456 | 7855 | ||
7457 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) | 7856 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) |
7458 | { | 7857 | { |
7459 | handlerNameRequest = OnNameFromUUIDRequest; | 7858 | UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest; |
7460 | if (handlerNameRequest != null) | 7859 | if (handlerNameRequest != null) |
7461 | { | 7860 | { |
7462 | handlerNameRequest(UUIDBlock.ID, this); | 7861 | handlerNameRequest(UUIDBlock.ID, this); |
@@ -7469,7 +7868,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7469 | case PacketType.RegionHandleRequest: | 7868 | case PacketType.RegionHandleRequest: |
7470 | RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; | 7869 | RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; |
7471 | 7870 | ||
7472 | handlerRegionHandleRequest = OnRegionHandleRequest; | 7871 | RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest; |
7473 | if (handlerRegionHandleRequest != null) | 7872 | if (handlerRegionHandleRequest != null) |
7474 | { | 7873 | { |
7475 | handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID); | 7874 | handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID); |
@@ -7488,7 +7887,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7488 | } | 7887 | } |
7489 | #endregion | 7888 | #endregion |
7490 | 7889 | ||
7491 | handlerParcelInfoRequest = OnParcelInfoRequest; | 7890 | ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest; |
7492 | if (handlerParcelInfoRequest != null) | 7891 | if (handlerParcelInfoRequest != null) |
7493 | { | 7892 | { |
7494 | handlerParcelInfoRequest(this, pirPack.Data.ParcelID); | 7893 | handlerParcelInfoRequest(this, pirPack.Data.ParcelID); |
@@ -7507,7 +7906,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7507 | } | 7906 | } |
7508 | #endregion | 7907 | #endregion |
7509 | 7908 | ||
7510 | handlerParcelAccessListRequest = OnParcelAccessListRequest; | 7909 | ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest; |
7511 | 7910 | ||
7512 | if (handlerParcelAccessListRequest != null) | 7911 | if (handlerParcelAccessListRequest != null) |
7513 | { | 7912 | { |
@@ -7539,7 +7938,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7539 | entries.Add(entry); | 7938 | entries.Add(entry); |
7540 | } | 7939 | } |
7541 | 7940 | ||
7542 | handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; | 7941 | ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; |
7543 | if (handlerParcelAccessListUpdateRequest != null) | 7942 | if (handlerParcelAccessListUpdateRequest != null) |
7544 | { | 7943 | { |
7545 | handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, | 7944 | handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, |
@@ -7560,7 +7959,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7560 | } | 7959 | } |
7561 | #endregion | 7960 | #endregion |
7562 | 7961 | ||
7563 | handlerParcelPropertiesRequest = OnParcelPropertiesRequest; | 7962 | ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest; |
7564 | if (handlerParcelPropertiesRequest != null) | 7963 | if (handlerParcelPropertiesRequest != null) |
7565 | { | 7964 | { |
7566 | handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), | 7965 | handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), |
@@ -7583,7 +7982,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7583 | } | 7982 | } |
7584 | #endregion | 7983 | #endregion |
7585 | 7984 | ||
7586 | handlerParcelDivideRequest = OnParcelDivideRequest; | 7985 | ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest; |
7587 | if (handlerParcelDivideRequest != null) | 7986 | if (handlerParcelDivideRequest != null) |
7588 | { | 7987 | { |
7589 | handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), | 7988 | handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), |
@@ -7604,7 +8003,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7604 | } | 8003 | } |
7605 | #endregion | 8004 | #endregion |
7606 | 8005 | ||
7607 | handlerParcelJoinRequest = OnParcelJoinRequest; | 8006 | ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest; |
7608 | 8007 | ||
7609 | if (handlerParcelJoinRequest != null) | 8008 | if (handlerParcelJoinRequest != null) |
7610 | { | 8009 | { |
@@ -7626,7 +8025,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7626 | } | 8025 | } |
7627 | #endregion | 8026 | #endregion |
7628 | 8027 | ||
7629 | handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; | 8028 | ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; |
7630 | 8029 | ||
7631 | if (handlerParcelPropertiesUpdateRequest != null) | 8030 | if (handlerParcelPropertiesUpdateRequest != null) |
7632 | { | 8031 | { |
@@ -7672,7 +8071,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7672 | returnIDs.Add(rb.ReturnID); | 8071 | returnIDs.Add(rb.ReturnID); |
7673 | } | 8072 | } |
7674 | 8073 | ||
7675 | handlerParcelSelectObjects = OnParcelSelectObjects; | 8074 | ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects; |
7676 | 8075 | ||
7677 | if (handlerParcelSelectObjects != null) | 8076 | if (handlerParcelSelectObjects != null) |
7678 | { | 8077 | { |
@@ -7693,7 +8092,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7693 | } | 8092 | } |
7694 | #endregion | 8093 | #endregion |
7695 | 8094 | ||
7696 | handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; | 8095 | ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; |
7697 | 8096 | ||
7698 | if (handlerParcelObjectOwnerRequest != null) | 8097 | if (handlerParcelObjectOwnerRequest != null) |
7699 | { | 8098 | { |
@@ -7712,7 +8111,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7712 | } | 8111 | } |
7713 | #endregion | 8112 | #endregion |
7714 | 8113 | ||
7715 | handlerParcelGodForceOwner = OnParcelGodForceOwner; | 8114 | ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner; |
7716 | if (handlerParcelGodForceOwner != null) | 8115 | if (handlerParcelGodForceOwner != null) |
7717 | { | 8116 | { |
7718 | handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); | 8117 | handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); |
@@ -7730,7 +8129,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7730 | } | 8129 | } |
7731 | #endregion | 8130 | #endregion |
7732 | 8131 | ||
7733 | handlerParcelAbandonRequest = OnParcelAbandonRequest; | 8132 | ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest; |
7734 | if (handlerParcelAbandonRequest != null) | 8133 | if (handlerParcelAbandonRequest != null) |
7735 | { | 8134 | { |
7736 | handlerParcelAbandonRequest(releasePacket.Data.LocalID, this); | 8135 | handlerParcelAbandonRequest(releasePacket.Data.LocalID, this); |
@@ -7748,7 +8147,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7748 | } | 8147 | } |
7749 | #endregion | 8148 | #endregion |
7750 | 8149 | ||
7751 | handlerParcelReclaim = OnParcelReclaim; | 8150 | ParcelReclaim handlerParcelReclaim = OnParcelReclaim; |
7752 | if (handlerParcelReclaim != null) | 8151 | if (handlerParcelReclaim != null) |
7753 | { | 8152 | { |
7754 | handlerParcelReclaim(reclaimPacket.Data.LocalID, this); | 8153 | handlerParcelReclaim(reclaimPacket.Data.LocalID, this); |
@@ -7777,7 +8176,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7777 | for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++) | 8176 | for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++) |
7778 | puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID; | 8177 | puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID; |
7779 | 8178 | ||
7780 | handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest; | 8179 | ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest; |
7781 | if (handlerParcelReturnObjectsRequest != null) | 8180 | if (handlerParcelReturnObjectsRequest != null) |
7782 | { | 8181 | { |
7783 | handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this); | 8182 | handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this); |
@@ -7797,7 +8196,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7797 | } | 8196 | } |
7798 | #endregion | 8197 | #endregion |
7799 | 8198 | ||
7800 | handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime; | 8199 | ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime; |
7801 | if (handlerParcelSetOtherCleanTime != null) | 8200 | if (handlerParcelSetOtherCleanTime != null) |
7802 | { | 8201 | { |
7803 | handlerParcelSetOtherCleanTime(this, | 8202 | handlerParcelSetOtherCleanTime(this, |
@@ -7818,7 +8217,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7818 | } | 8217 | } |
7819 | #endregion | 8218 | #endregion |
7820 | 8219 | ||
7821 | handlerLandStatRequest = OnLandStatRequest; | 8220 | GodLandStatRequest handlerLandStatRequest = OnLandStatRequest; |
7822 | if (handlerLandStatRequest != null) | 8221 | if (handlerLandStatRequest != null) |
7823 | { | 8222 | { |
7824 | handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this); | 8223 | handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this); |
@@ -7838,7 +8237,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
7838 | } | 8237 | } |
7839 | #endregion | 8238 | #endregion |
7840 | 8239 | ||
7841 | handlerParcelDwellRequest = OnParcelDwellRequest; | 8240 | ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest; |
7842 | if (handlerParcelDwellRequest != null) | 8241 | if (handlerParcelDwellRequest != null) |
7843 | { | 8242 | { |
7844 | handlerParcelDwellRequest(dwellrq.Data.LocalID, this); | 8243 | handlerParcelDwellRequest(dwellrq.Data.LocalID, this); |
@@ -8082,7 +8481,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8082 | { | 8481 | { |
8083 | if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake") | 8482 | if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake") |
8084 | { | 8483 | { |
8085 | handlerBakeTerrain = OnBakeTerrain; | 8484 | BakeTerrain handlerBakeTerrain = OnBakeTerrain; |
8086 | if (handlerBakeTerrain != null) | 8485 | if (handlerBakeTerrain != null) |
8087 | { | 8486 | { |
8088 | handlerBakeTerrain(this); | 8487 | handlerBakeTerrain(this); |
@@ -8092,7 +8491,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8092 | { | 8491 | { |
8093 | if (messagePacket.ParamList.Length > 1) | 8492 | if (messagePacket.ParamList.Length > 1) |
8094 | { | 8493 | { |
8095 | handlerRequestTerrain = OnRequestTerrain; | 8494 | RequestTerrain handlerRequestTerrain = OnRequestTerrain; |
8096 | if (handlerRequestTerrain != null) | 8495 | if (handlerRequestTerrain != null) |
8097 | { | 8496 | { |
8098 | handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | 8497 | handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); |
@@ -8103,7 +8502,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8103 | { | 8502 | { |
8104 | if (messagePacket.ParamList.Length > 1) | 8503 | if (messagePacket.ParamList.Length > 1) |
8105 | { | 8504 | { |
8106 | handlerUploadTerrain = OnUploadTerrain; | 8505 | RequestTerrain handlerUploadTerrain = OnUploadTerrain; |
8107 | if (handlerUploadTerrain != null) | 8506 | if (handlerUploadTerrain != null) |
8108 | { | 8507 | { |
8109 | handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | 8508 | handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); |
@@ -8125,7 +8524,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8125 | UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | 8524 | UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); |
8126 | UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); | 8525 | UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); |
8127 | 8526 | ||
8128 | handlerEstateChangeInfo = OnEstateChangeInfo; | 8527 | EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo; |
8129 | if (handlerEstateChangeInfo != null) | 8528 | if (handlerEstateChangeInfo != null) |
8130 | { | 8529 | { |
8131 | handlerEstateChangeInfo(this, invoice, SenderID, param1, param2); | 8530 | handlerEstateChangeInfo(this, invoice, SenderID, param1, param2); |
@@ -8159,7 +8558,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8159 | } | 8558 | } |
8160 | #endregion | 8559 | #endregion |
8161 | 8560 | ||
8162 | handlerRegionInfoRequest = OnRegionInfoRequest; | 8561 | RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest; |
8163 | if (handlerRegionInfoRequest != null) | 8562 | if (handlerRegionInfoRequest != null) |
8164 | { | 8563 | { |
8165 | handlerRegionInfoRequest(this); | 8564 | handlerRegionInfoRequest(this); |
@@ -8170,7 +8569,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8170 | //EstateCovenantRequestPacket.AgentDataBlock epack = | 8569 | //EstateCovenantRequestPacket.AgentDataBlock epack = |
8171 | // ((EstateCovenantRequestPacket)Pack).AgentData; | 8570 | // ((EstateCovenantRequestPacket)Pack).AgentData; |
8172 | 8571 | ||
8173 | handlerEstateCovenantRequest = OnEstateCovenantRequest; | 8572 | EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest; |
8174 | if (handlerEstateCovenantRequest != null) | 8573 | if (handlerEstateCovenantRequest != null) |
8175 | { | 8574 | { |
8176 | handlerEstateCovenantRequest(this); | 8575 | handlerEstateCovenantRequest(this); |
@@ -8188,7 +8587,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8188 | 8587 | ||
8189 | RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; | 8588 | RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; |
8190 | 8589 | ||
8191 | handlerReqGodlikePowers = OnRequestGodlikePowers; | 8590 | RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers; |
8192 | 8591 | ||
8193 | if (handlerReqGodlikePowers != null) | 8592 | if (handlerReqGodlikePowers != null) |
8194 | { | 8593 | { |
@@ -8201,7 +8600,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8201 | 8600 | ||
8202 | if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) | 8601 | if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) |
8203 | { | 8602 | { |
8204 | handlerGodKickUser = OnGodKickUser; | 8603 | GodKickUser handlerGodKickUser = OnGodKickUser; |
8205 | if (handlerGodKickUser != null) | 8604 | if (handlerGodKickUser != null) |
8206 | { | 8605 | { |
8207 | handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, | 8606 | handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, |
@@ -8241,7 +8640,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8241 | } | 8640 | } |
8242 | #endregion | 8641 | #endregion |
8243 | 8642 | ||
8244 | handlerMoneyBalanceRequest = OnMoneyBalanceRequest; | 8643 | MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest; |
8245 | 8644 | ||
8246 | if (handlerMoneyBalanceRequest != null) | 8645 | if (handlerMoneyBalanceRequest != null) |
8247 | { | 8646 | { |
@@ -8252,7 +8651,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8252 | case PacketType.EconomyDataRequest: | 8651 | case PacketType.EconomyDataRequest: |
8253 | 8652 | ||
8254 | 8653 | ||
8255 | handlerEconomoyDataRequest = OnEconomyDataRequest; | 8654 | EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest; |
8256 | if (handlerEconomoyDataRequest != null) | 8655 | if (handlerEconomoyDataRequest != null) |
8257 | { | 8656 | { |
8258 | handlerEconomoyDataRequest(AgentId); | 8657 | handlerEconomoyDataRequest(AgentId); |
@@ -8261,7 +8660,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8261 | case PacketType.RequestPayPrice: | 8660 | case PacketType.RequestPayPrice: |
8262 | RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; | 8661 | RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; |
8263 | 8662 | ||
8264 | handlerRequestPayPrice = OnRequestPayPrice; | 8663 | RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice; |
8265 | if (handlerRequestPayPrice != null) | 8664 | if (handlerRequestPayPrice != null) |
8266 | { | 8665 | { |
8267 | handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); | 8666 | handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); |
@@ -8280,7 +8679,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8280 | } | 8679 | } |
8281 | #endregion | 8680 | #endregion |
8282 | 8681 | ||
8283 | handlerObjectSaleInfo = OnObjectSaleInfo; | 8682 | ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo; |
8284 | if (handlerObjectSaleInfo != null) | 8683 | if (handlerObjectSaleInfo != null) |
8285 | { | 8684 | { |
8286 | foreach (ObjectSaleInfoPacket.ObjectDataBlock d | 8685 | foreach (ObjectSaleInfoPacket.ObjectDataBlock d |
@@ -8308,7 +8707,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8308 | } | 8707 | } |
8309 | #endregion | 8708 | #endregion |
8310 | 8709 | ||
8311 | handlerObjectBuy = OnObjectBuy; | 8710 | ObjectBuy handlerObjectBuy = OnObjectBuy; |
8312 | 8711 | ||
8313 | if (handlerObjectBuy != null) | 8712 | if (handlerObjectBuy != null) |
8314 | { | 8713 | { |
@@ -8334,7 +8733,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8334 | case PacketType.GetScriptRunning: | 8733 | case PacketType.GetScriptRunning: |
8335 | GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; | 8734 | GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; |
8336 | 8735 | ||
8337 | handlerGetScriptRunning = OnGetScriptRunning; | 8736 | GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; |
8338 | if (handlerGetScriptRunning != null) | 8737 | if (handlerGetScriptRunning != null) |
8339 | { | 8738 | { |
8340 | handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); | 8739 | handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); |
@@ -8353,7 +8752,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8353 | } | 8752 | } |
8354 | #endregion | 8753 | #endregion |
8355 | 8754 | ||
8356 | handlerSetScriptRunning = OnSetScriptRunning; | 8755 | SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning; |
8357 | if (handlerSetScriptRunning != null) | 8756 | if (handlerSetScriptRunning != null) |
8358 | { | 8757 | { |
8359 | handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); | 8758 | handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); |
@@ -8372,7 +8771,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8372 | } | 8771 | } |
8373 | #endregion | 8772 | #endregion |
8374 | 8773 | ||
8375 | handlerScriptReset = OnScriptReset; | 8774 | ScriptReset handlerScriptReset = OnScriptReset; |
8376 | if (handlerScriptReset != null) | 8775 | if (handlerScriptReset != null) |
8377 | { | 8776 | { |
8378 | handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); | 8777 | handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); |
@@ -8395,7 +8794,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8395 | } | 8794 | } |
8396 | #endregion | 8795 | #endregion |
8397 | 8796 | ||
8398 | handlerActivateGesture = OnActivateGesture; | 8797 | ActivateGesture handlerActivateGesture = OnActivateGesture; |
8399 | if (handlerActivateGesture != null) | 8798 | if (handlerActivateGesture != null) |
8400 | { | 8799 | { |
8401 | handlerActivateGesture(this, | 8800 | handlerActivateGesture(this, |
@@ -8418,7 +8817,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8418 | } | 8817 | } |
8419 | #endregion | 8818 | #endregion |
8420 | 8819 | ||
8421 | handlerDeactivateGesture = OnDeactivateGesture; | 8820 | DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture; |
8422 | if (handlerDeactivateGesture != null) | 8821 | if (handlerDeactivateGesture != null) |
8423 | { | 8822 | { |
8424 | handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID); | 8823 | handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID); |
@@ -8441,7 +8840,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8441 | foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData) | 8840 | foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData) |
8442 | localIDs.Add(d.ObjectLocalID); | 8841 | localIDs.Add(d.ObjectLocalID); |
8443 | 8842 | ||
8444 | handlerObjectOwner = OnObjectOwner; | 8843 | ObjectOwner handlerObjectOwner = OnObjectOwner; |
8445 | if (handlerObjectOwner != null) | 8844 | if (handlerObjectOwner != null) |
8446 | { | 8845 | { |
8447 | handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); | 8846 | handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); |
@@ -8454,14 +8853,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8454 | #region unimplemented handlers | 8853 | #region unimplemented handlers |
8455 | 8854 | ||
8456 | case PacketType.StartPingCheck: | 8855 | case PacketType.StartPingCheck: |
8457 | // Send the client the ping response back | 8856 | StartPingCheckPacket pingStart = (StartPingCheckPacket)Pack; |
8458 | // Pass the same PingID in the matching packet | 8857 | CompletePingCheckPacket pingComplete = new CompletePingCheckPacket(); |
8459 | // Handled In the packet processing | 8858 | pingComplete.PingID.PingID = pingStart.PingID.PingID; |
8460 | //m_log.Debug("[CLIENT]: possibly unhandled StartPingCheck packet"); | 8859 | m_udpServer.SendPacket(m_udpClient, pingComplete, ThrottleOutPacketType.Unknown, false); |
8461 | break; | 8860 | break; |
8861 | |||
8462 | case PacketType.CompletePingCheck: | 8862 | case PacketType.CompletePingCheck: |
8463 | // TODO: Perhaps this should be processed on the Sim to determine whether or not to drop a dead client | 8863 | // TODO: Do stats tracking or something with these? |
8464 | //m_log.Warn("[CLIENT]: unhandled CompletePingCheck packet"); | ||
8465 | break; | 8864 | break; |
8466 | 8865 | ||
8467 | case PacketType.ViewerStats: | 8866 | case PacketType.ViewerStats: |
@@ -8482,7 +8881,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8482 | #endregion | 8881 | #endregion |
8483 | 8882 | ||
8484 | //m_log.Debug(mirpk.ToString()); | 8883 | //m_log.Debug(mirpk.ToString()); |
8485 | handlerMapItemRequest = OnMapItemRequest; | 8884 | MapItemRequest handlerMapItemRequest = OnMapItemRequest; |
8486 | if (handlerMapItemRequest != null) | 8885 | if (handlerMapItemRequest != null) |
8487 | { | 8886 | { |
8488 | handlerMapItemRequest(this,mirpk.AgentData.Flags, mirpk.AgentData.EstateID, | 8887 | handlerMapItemRequest(this,mirpk.AgentData.Flags, mirpk.AgentData.EstateID, |
@@ -8509,7 +8908,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8509 | } | 8908 | } |
8510 | #endregion | 8909 | #endregion |
8511 | 8910 | ||
8512 | handlerMuteListRequest = OnMuteListRequest; | 8911 | MuteListRequest handlerMuteListRequest = OnMuteListRequest; |
8513 | if (handlerMuteListRequest != null) | 8912 | if (handlerMuteListRequest != null) |
8514 | { | 8913 | { |
8515 | handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC); | 8914 | handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC); |
@@ -8546,7 +8945,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8546 | } | 8945 | } |
8547 | #endregion | 8946 | #endregion |
8548 | 8947 | ||
8549 | handlerDirPlacesQuery = OnDirPlacesQuery; | 8948 | DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery; |
8550 | if (handlerDirPlacesQuery != null) | 8949 | if (handlerDirPlacesQuery != null) |
8551 | { | 8950 | { |
8552 | handlerDirPlacesQuery(this, | 8951 | handlerDirPlacesQuery(this, |
@@ -8572,7 +8971,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8572 | } | 8971 | } |
8573 | #endregion | 8972 | #endregion |
8574 | 8973 | ||
8575 | handlerDirFindQuery = OnDirFindQuery; | 8974 | DirFindQuery handlerDirFindQuery = OnDirFindQuery; |
8576 | if (handlerDirFindQuery != null) | 8975 | if (handlerDirFindQuery != null) |
8577 | { | 8976 | { |
8578 | handlerDirFindQuery(this, | 8977 | handlerDirFindQuery(this, |
@@ -8595,7 +8994,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8595 | } | 8994 | } |
8596 | #endregion | 8995 | #endregion |
8597 | 8996 | ||
8598 | handlerDirLandQuery = OnDirLandQuery; | 8997 | DirLandQuery handlerDirLandQuery = OnDirLandQuery; |
8599 | if (handlerDirLandQuery != null) | 8998 | if (handlerDirLandQuery != null) |
8600 | { | 8999 | { |
8601 | handlerDirLandQuery(this, | 9000 | handlerDirLandQuery(this, |
@@ -8619,7 +9018,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8619 | } | 9018 | } |
8620 | #endregion | 9019 | #endregion |
8621 | 9020 | ||
8622 | handlerDirPopularQuery = OnDirPopularQuery; | 9021 | DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery; |
8623 | if (handlerDirPopularQuery != null) | 9022 | if (handlerDirPopularQuery != null) |
8624 | { | 9023 | { |
8625 | handlerDirPopularQuery(this, | 9024 | handlerDirPopularQuery(this, |
@@ -8639,7 +9038,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8639 | } | 9038 | } |
8640 | #endregion | 9039 | #endregion |
8641 | 9040 | ||
8642 | handlerDirClassifiedQuery = OnDirClassifiedQuery; | 9041 | DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery; |
8643 | if (handlerDirClassifiedQuery != null) | 9042 | if (handlerDirClassifiedQuery != null) |
8644 | { | 9043 | { |
8645 | handlerDirClassifiedQuery(this, | 9044 | handlerDirClassifiedQuery(this, |
@@ -9155,7 +9554,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9155 | ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack; | 9554 | ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack; |
9156 | if (m_GroupsModule != null) | 9555 | if (m_GroupsModule != null) |
9157 | { | 9556 | { |
9158 | handlerParcelDeedToGroup = OnParcelDeedToGroup; | 9557 | ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup; |
9159 | if (handlerParcelDeedToGroup != null) | 9558 | if (handlerParcelDeedToGroup != null) |
9160 | { | 9559 | { |
9161 | handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID,this); | 9560 | handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID,this); |
@@ -9399,7 +9798,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9399 | } | 9798 | } |
9400 | #endregion | 9799 | #endregion |
9401 | 9800 | ||
9402 | handlerStartLure = OnStartLure; | 9801 | StartLure handlerStartLure = OnStartLure; |
9403 | if (handlerStartLure != null) | 9802 | if (handlerStartLure != null) |
9404 | handlerStartLure(startLureRequest.Info.LureType, | 9803 | handlerStartLure(startLureRequest.Info.LureType, |
9405 | Utils.BytesToString( | 9804 | Utils.BytesToString( |
@@ -9421,7 +9820,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9421 | } | 9820 | } |
9422 | #endregion | 9821 | #endregion |
9423 | 9822 | ||
9424 | handlerTeleportLureRequest = OnTeleportLureRequest; | 9823 | TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest; |
9425 | if (handlerTeleportLureRequest != null) | 9824 | if (handlerTeleportLureRequest != null) |
9426 | handlerTeleportLureRequest( | 9825 | handlerTeleportLureRequest( |
9427 | teleportLureRequest.Info.LureID, | 9826 | teleportLureRequest.Info.LureID, |
@@ -9442,7 +9841,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9442 | } | 9841 | } |
9443 | #endregion | 9842 | #endregion |
9444 | 9843 | ||
9445 | handlerClassifiedInfoRequest = OnClassifiedInfoRequest; | 9844 | ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest; |
9446 | if (handlerClassifiedInfoRequest != null) | 9845 | if (handlerClassifiedInfoRequest != null) |
9447 | handlerClassifiedInfoRequest( | 9846 | handlerClassifiedInfoRequest( |
9448 | classifiedInfoRequest.Data.ClassifiedID, | 9847 | classifiedInfoRequest.Data.ClassifiedID, |
@@ -9462,7 +9861,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9462 | } | 9861 | } |
9463 | #endregion | 9862 | #endregion |
9464 | 9863 | ||
9465 | handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate; | 9864 | ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate; |
9466 | if (handlerClassifiedInfoUpdate != null) | 9865 | if (handlerClassifiedInfoUpdate != null) |
9467 | handlerClassifiedInfoUpdate( | 9866 | handlerClassifiedInfoUpdate( |
9468 | classifiedInfoUpdate.Data.ClassifiedID, | 9867 | classifiedInfoUpdate.Data.ClassifiedID, |
@@ -9494,7 +9893,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9494 | } | 9893 | } |
9495 | #endregion | 9894 | #endregion |
9496 | 9895 | ||
9497 | handlerClassifiedDelete = OnClassifiedDelete; | 9896 | ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete; |
9498 | if (handlerClassifiedDelete != null) | 9897 | if (handlerClassifiedDelete != null) |
9499 | handlerClassifiedDelete( | 9898 | handlerClassifiedDelete( |
9500 | classifiedDelete.Data.ClassifiedID, | 9899 | classifiedDelete.Data.ClassifiedID, |
@@ -9514,7 +9913,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9514 | } | 9913 | } |
9515 | #endregion | 9914 | #endregion |
9516 | 9915 | ||
9517 | handlerClassifiedGodDelete = OnClassifiedGodDelete; | 9916 | ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete; |
9518 | if (handlerClassifiedGodDelete != null) | 9917 | if (handlerClassifiedGodDelete != null) |
9519 | handlerClassifiedGodDelete( | 9918 | handlerClassifiedGodDelete( |
9520 | classifiedGodDelete.Data.ClassifiedID, | 9919 | classifiedGodDelete.Data.ClassifiedID, |
@@ -9534,7 +9933,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9534 | } | 9933 | } |
9535 | #endregion | 9934 | #endregion |
9536 | 9935 | ||
9537 | handlerEventGodDelete = OnEventGodDelete; | 9936 | EventGodDelete handlerEventGodDelete = OnEventGodDelete; |
9538 | if (handlerEventGodDelete != null) | 9937 | if (handlerEventGodDelete != null) |
9539 | handlerEventGodDelete( | 9938 | handlerEventGodDelete( |
9540 | eventGodDelete.EventData.EventID, | 9939 | eventGodDelete.EventData.EventID, |
@@ -9559,7 +9958,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9559 | } | 9958 | } |
9560 | #endregion | 9959 | #endregion |
9561 | 9960 | ||
9562 | handlerEventNotificationAddRequest = OnEventNotificationAddRequest; | 9961 | EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest; |
9563 | if (handlerEventNotificationAddRequest != null) | 9962 | if (handlerEventNotificationAddRequest != null) |
9564 | handlerEventNotificationAddRequest( | 9963 | handlerEventNotificationAddRequest( |
9565 | eventNotificationAdd.EventData.EventID, this); | 9964 | eventNotificationAdd.EventData.EventID, this); |
@@ -9578,7 +9977,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9578 | } | 9977 | } |
9579 | #endregion | 9978 | #endregion |
9580 | 9979 | ||
9581 | handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest; | 9980 | EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest; |
9582 | if (handlerEventNotificationRemoveRequest != null) | 9981 | if (handlerEventNotificationRemoveRequest != null) |
9583 | handlerEventNotificationRemoveRequest( | 9982 | handlerEventNotificationRemoveRequest( |
9584 | eventNotificationRemove.EventData.EventID, this); | 9983 | eventNotificationRemove.EventData.EventID, this); |
@@ -9596,7 +9995,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9596 | } | 9995 | } |
9597 | #endregion | 9996 | #endregion |
9598 | 9997 | ||
9599 | handlerRetrieveInstantMessages = OnRetrieveInstantMessages; | 9998 | RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages; |
9600 | if (handlerRetrieveInstantMessages != null) | 9999 | if (handlerRetrieveInstantMessages != null) |
9601 | handlerRetrieveInstantMessages(this); | 10000 | handlerRetrieveInstantMessages(this); |
9602 | break; | 10001 | break; |
@@ -9614,7 +10013,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9614 | } | 10013 | } |
9615 | #endregion | 10014 | #endregion |
9616 | 10015 | ||
9617 | handlerPickDelete = OnPickDelete; | 10016 | PickDelete handlerPickDelete = OnPickDelete; |
9618 | if (handlerPickDelete != null) | 10017 | if (handlerPickDelete != null) |
9619 | handlerPickDelete(this, pickDelete.Data.PickID); | 10018 | handlerPickDelete(this, pickDelete.Data.PickID); |
9620 | break; | 10019 | break; |
@@ -9631,7 +10030,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9631 | } | 10030 | } |
9632 | #endregion | 10031 | #endregion |
9633 | 10032 | ||
9634 | handlerPickGodDelete = OnPickGodDelete; | 10033 | PickGodDelete handlerPickGodDelete = OnPickGodDelete; |
9635 | if (handlerPickGodDelete != null) | 10034 | if (handlerPickGodDelete != null) |
9636 | handlerPickGodDelete(this, | 10035 | handlerPickGodDelete(this, |
9637 | pickGodDelete.AgentData.AgentID, | 10036 | pickGodDelete.AgentData.AgentID, |
@@ -9651,7 +10050,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9651 | } | 10050 | } |
9652 | #endregion | 10051 | #endregion |
9653 | 10052 | ||
9654 | handlerPickInfoUpdate = OnPickInfoUpdate; | 10053 | PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate; |
9655 | if (handlerPickInfoUpdate != null) | 10054 | if (handlerPickInfoUpdate != null) |
9656 | handlerPickInfoUpdate(this, | 10055 | handlerPickInfoUpdate(this, |
9657 | pickInfoUpdate.Data.PickID, | 10056 | pickInfoUpdate.Data.PickID, |
@@ -9676,7 +10075,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9676 | } | 10075 | } |
9677 | #endregion | 10076 | #endregion |
9678 | 10077 | ||
9679 | handlerAvatarNotesUpdate = OnAvatarNotesUpdate; | 10078 | AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate; |
9680 | if (handlerAvatarNotesUpdate != null) | 10079 | if (handlerAvatarNotesUpdate != null) |
9681 | handlerAvatarNotesUpdate(this, | 10080 | handlerAvatarNotesUpdate(this, |
9682 | avatarNotesUpdate.Data.TargetID, | 10081 | avatarNotesUpdate.Data.TargetID, |
@@ -9693,7 +10092,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9693 | PlacesQueryPacket placesQueryPacket = | 10092 | PlacesQueryPacket placesQueryPacket = |
9694 | (PlacesQueryPacket)Pack; | 10093 | (PlacesQueryPacket)Pack; |
9695 | 10094 | ||
9696 | handlerPlacesQuery = OnPlacesQuery; | 10095 | PlacesQuery handlerPlacesQuery = OnPlacesQuery; |
9697 | 10096 | ||
9698 | if (handlerPlacesQuery != null) | 10097 | if (handlerPlacesQuery != null) |
9699 | handlerPlacesQuery(placesQueryPacket.AgentData.QueryID, | 10098 | handlerPlacesQuery(placesQueryPacket.AgentData.QueryID, |
@@ -9747,304 +10146,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9747 | //shape.Textures = ntex; | 10146 | //shape.Textures = ntex; |
9748 | return shape; | 10147 | return shape; |
9749 | } | 10148 | } |
9750 | 10149 | ||
9751 | /// <summary> | ||
9752 | /// Send the client an Estate message blue box pop-down with a single OK button | ||
9753 | /// </summary> | ||
9754 | /// <param name="FromAvatarID"></param> | ||
9755 | /// <param name="fromSessionID"></param> | ||
9756 | /// <param name="FromAvatarName"></param> | ||
9757 | /// <param name="Message"></param> | ||
9758 | public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message) | ||
9759 | { | ||
9760 | if (!ChildAgentStatus()) | ||
9761 | SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3())); | ||
9762 | |||
9763 | //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch()); | ||
9764 | } | ||
9765 | |||
9766 | public void SendLogoutPacket() | ||
9767 | { | ||
9768 | // I know this is a bit of a hack, however there are times when you don't | ||
9769 | // want to send this, but still need to do the rest of the shutdown process | ||
9770 | // this method gets called from the packet server.. which makes it practically | ||
9771 | // impossible to do any other way. | ||
9772 | |||
9773 | if (m_SendLogoutPacketWhenClosing) | ||
9774 | { | ||
9775 | LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); | ||
9776 | // TODO: don't create new blocks if recycling an old packet | ||
9777 | logReply.AgentData.AgentID = AgentId; | ||
9778 | logReply.AgentData.SessionID = SessionId; | ||
9779 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | ||
9780 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | ||
9781 | logReply.InventoryData[0].ItemID = UUID.Zero; | ||
9782 | |||
9783 | OutPacket(logReply, ThrottleOutPacketType.Task); | ||
9784 | } | ||
9785 | } | ||
9786 | |||
9787 | public void SendHealth(float health) | ||
9788 | { | ||
9789 | HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage); | ||
9790 | healthpacket.HealthData.Health = health; | ||
9791 | OutPacket(healthpacket, ThrottleOutPacketType.Task); | ||
9792 | } | ||
9793 | |||
9794 | public void SendAgentOnline(UUID[] agentIDs) | ||
9795 | { | ||
9796 | OnlineNotificationPacket onp = new OnlineNotificationPacket(); | ||
9797 | OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length]; | ||
9798 | for (int i = 0; i < agentIDs.Length; i++) | ||
9799 | { | ||
9800 | OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock(); | ||
9801 | onpbl.AgentID = agentIDs[i]; | ||
9802 | onpb[i] = onpbl; | ||
9803 | } | ||
9804 | onp.AgentBlock = onpb; | ||
9805 | onp.Header.Reliable = true; | ||
9806 | OutPacket(onp, ThrottleOutPacketType.Task); | ||
9807 | } | ||
9808 | |||
9809 | public void SendAgentOffline(UUID[] agentIDs) | ||
9810 | { | ||
9811 | OfflineNotificationPacket offp = new OfflineNotificationPacket(); | ||
9812 | OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length]; | ||
9813 | for (int i = 0; i < agentIDs.Length; i++) | ||
9814 | { | ||
9815 | OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock(); | ||
9816 | onpbl.AgentID = agentIDs[i]; | ||
9817 | offpb[i] = onpbl; | ||
9818 | } | ||
9819 | offp.AgentBlock = offpb; | ||
9820 | offp.Header.Reliable = true; | ||
9821 | OutPacket(offp, ThrottleOutPacketType.Task); | ||
9822 | } | ||
9823 | |||
9824 | public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, | ||
9825 | Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) | ||
9826 | { | ||
9827 | AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); | ||
9828 | avatarSitResponse.SitObject.ID = TargetID; | ||
9829 | if (CameraAtOffset != Vector3.Zero) | ||
9830 | { | ||
9831 | avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset; | ||
9832 | avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset; | ||
9833 | } | ||
9834 | avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook; | ||
9835 | avatarSitResponse.SitTransform.AutoPilot = autopilot; | ||
9836 | avatarSitResponse.SitTransform.SitPosition = OffsetPos; | ||
9837 | avatarSitResponse.SitTransform.SitRotation = SitOrientation; | ||
9838 | |||
9839 | OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); | ||
9840 | } | ||
9841 | |||
9842 | public void SendAdminResponse(UUID Token, uint AdminLevel) | ||
9843 | { | ||
9844 | GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); | ||
9845 | GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock(); | ||
9846 | GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock(); | ||
9847 | |||
9848 | adb.AgentID = AgentId; | ||
9849 | adb.SessionID = SessionId; // More security | ||
9850 | gdb.GodLevel = (byte)AdminLevel; | ||
9851 | gdb.Token = Token; | ||
9852 | //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; | ||
9853 | respondPacket.GrantData = gdb; | ||
9854 | respondPacket.AgentData = adb; | ||
9855 | OutPacket(respondPacket, ThrottleOutPacketType.Task); | ||
9856 | } | ||
9857 | |||
9858 | public void SendGroupMembership(GroupMembershipData[] GroupMembership) | ||
9859 | { | ||
9860 | m_groupPowers.Clear(); | ||
9861 | |||
9862 | AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket(); | ||
9863 | AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length]; | ||
9864 | for (int i = 0; i < GroupMembership.Length; i++) | ||
9865 | { | ||
9866 | m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; | ||
9867 | |||
9868 | AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); | ||
9869 | Group.AcceptNotices = GroupMembership[i].AcceptNotices; | ||
9870 | Group.Contribution = GroupMembership[i].Contribution; | ||
9871 | Group.GroupID = GroupMembership[i].GroupID; | ||
9872 | Group.GroupInsigniaID = GroupMembership[i].GroupPicture; | ||
9873 | Group.GroupName = Utils.StringToBytes(GroupMembership[i].GroupName); | ||
9874 | Group.GroupPowers = GroupMembership[i].GroupPowers; | ||
9875 | Groups[i] = Group; | ||
9876 | |||
9877 | |||
9878 | } | ||
9879 | Groupupdate.GroupData = Groups; | ||
9880 | Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock(); | ||
9881 | Groupupdate.AgentData.AgentID = AgentId; | ||
9882 | OutPacket(Groupupdate, ThrottleOutPacketType.Task); | ||
9883 | |||
9884 | try | ||
9885 | { | ||
9886 | IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>(); | ||
9887 | if (eq != null) | ||
9888 | { | ||
9889 | eq.GroupMembership(Groupupdate, this.AgentId); | ||
9890 | } | ||
9891 | } | ||
9892 | catch (Exception ex) | ||
9893 | { | ||
9894 | m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString()); | ||
9895 | m_log.Warn("sending group membership data via UDP"); | ||
9896 | OutPacket(Groupupdate, ThrottleOutPacketType.Task); | ||
9897 | } | ||
9898 | } | ||
9899 | |||
9900 | |||
9901 | public void SendGroupNameReply(UUID groupLLUID, string GroupName) | ||
9902 | { | ||
9903 | UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket(); | ||
9904 | UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1]; | ||
9905 | UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock(); | ||
9906 | uidnamebloc.ID = groupLLUID; | ||
9907 | uidnamebloc.GroupName = Utils.StringToBytes(GroupName); | ||
9908 | uidnameblock[0] = uidnamebloc; | ||
9909 | pack.UUIDNameBlock = uidnameblock; | ||
9910 | OutPacket(pack, ThrottleOutPacketType.Task); | ||
9911 | } | ||
9912 | |||
9913 | public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) | ||
9914 | { | ||
9915 | LandStatReplyPacket lsrp = new LandStatReplyPacket(); | ||
9916 | // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock(); | ||
9917 | LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length]; | ||
9918 | //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); | ||
9919 | // lsrepdb. | ||
9920 | lsrp.RequestData.ReportType = reportType; | ||
9921 | lsrp.RequestData.RequestFlags = requestFlags; | ||
9922 | lsrp.RequestData.TotalObjectCount = resultCount; | ||
9923 | for (int i = 0; i < lsrpia.Length; i++) | ||
9924 | { | ||
9925 | LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); | ||
9926 | lsrepdb.LocationX = lsrpia[i].LocationX; | ||
9927 | lsrepdb.LocationY = lsrpia[i].LocationY; | ||
9928 | lsrepdb.LocationZ = lsrpia[i].LocationZ; | ||
9929 | lsrepdb.Score = lsrpia[i].Score; | ||
9930 | lsrepdb.TaskID = lsrpia[i].TaskID; | ||
9931 | lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID; | ||
9932 | lsrepdb.TaskName = Utils.StringToBytes(lsrpia[i].TaskName); | ||
9933 | lsrepdb.OwnerName = Utils.StringToBytes(lsrpia[i].OwnerName); | ||
9934 | lsrepdba[i] = lsrepdb; | ||
9935 | } | ||
9936 | lsrp.ReportData = lsrepdba; | ||
9937 | OutPacket(lsrp, ThrottleOutPacketType.Task); | ||
9938 | } | ||
9939 | |||
9940 | public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running) | ||
9941 | { | ||
9942 | ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket(); | ||
9943 | scriptRunningReply.Script.ObjectID = objectID; | ||
9944 | scriptRunningReply.Script.ItemID = itemID; | ||
9945 | scriptRunningReply.Script.Running = running; | ||
9946 | |||
9947 | OutPacket(scriptRunningReply, ThrottleOutPacketType.Task); | ||
9948 | } | ||
9949 | |||
9950 | public void SendAsset(AssetRequestToClient req) | ||
9951 | { | ||
9952 | //m_log.Debug("sending asset " + req.RequestAssetID); | ||
9953 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
9954 | Transfer.TransferInfo.ChannelType = 2; | ||
9955 | Transfer.TransferInfo.Status = 0; | ||
9956 | Transfer.TransferInfo.TargetType = 0; | ||
9957 | if (req.AssetRequestSource == 2) | ||
9958 | { | ||
9959 | Transfer.TransferInfo.Params = new byte[20]; | ||
9960 | Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | ||
9961 | int assType = req.AssetInf.Type; | ||
9962 | Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); | ||
9963 | } | ||
9964 | else if (req.AssetRequestSource == 3) | ||
9965 | { | ||
9966 | Transfer.TransferInfo.Params = req.Params; | ||
9967 | // Transfer.TransferInfo.Params = new byte[100]; | ||
9968 | //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | ||
9969 | //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); | ||
9970 | } | ||
9971 | Transfer.TransferInfo.Size = req.AssetInf.Data.Length; | ||
9972 | Transfer.TransferInfo.TransferID = req.TransferRequestID; | ||
9973 | Transfer.Header.Zerocoded = true; | ||
9974 | OutPacket(Transfer, ThrottleOutPacketType.Asset); | ||
9975 | |||
9976 | if (req.NumPackets == 1) | ||
9977 | { | ||
9978 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
9979 | TransferPacket.TransferData.Packet = 0; | ||
9980 | TransferPacket.TransferData.ChannelType = 2; | ||
9981 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
9982 | TransferPacket.TransferData.Data = req.AssetInf.Data; | ||
9983 | TransferPacket.TransferData.Status = 1; | ||
9984 | TransferPacket.Header.Zerocoded = true; | ||
9985 | OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | ||
9986 | } | ||
9987 | else | ||
9988 | { | ||
9989 | int processedLength = 0; | ||
9990 | int maxChunkSize = Settings.MAX_PACKET_SIZE - 100; | ||
9991 | int packetNumber = 0; | ||
9992 | |||
9993 | while (processedLength < req.AssetInf.Data.Length) | ||
9994 | { | ||
9995 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
9996 | TransferPacket.TransferData.Packet = packetNumber; | ||
9997 | TransferPacket.TransferData.ChannelType = 2; | ||
9998 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
9999 | |||
10000 | int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); | ||
10001 | byte[] chunk = new byte[chunkSize]; | ||
10002 | Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); | ||
10003 | |||
10004 | TransferPacket.TransferData.Data = chunk; | ||
10005 | |||
10006 | // 0 indicates more packets to come, 1 indicates last packet | ||
10007 | if (req.AssetInf.Data.Length - processedLength > maxChunkSize) | ||
10008 | { | ||
10009 | TransferPacket.TransferData.Status = 0; | ||
10010 | } | ||
10011 | else | ||
10012 | { | ||
10013 | TransferPacket.TransferData.Status = 1; | ||
10014 | } | ||
10015 | TransferPacket.Header.Zerocoded = true; | ||
10016 | OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | ||
10017 | |||
10018 | processedLength += chunkSize; | ||
10019 | packetNumber++; | ||
10020 | } | ||
10021 | } | ||
10022 | } | ||
10023 | |||
10024 | public void SendTexture(AssetBase TextureAsset) | ||
10025 | { | ||
10026 | |||
10027 | } | ||
10028 | |||
10029 | public ClientInfo GetClientInfo() | 10150 | public ClientInfo GetClientInfo() |
10030 | { | 10151 | { |
10031 | ClientInfo info = m_PacketHandler.GetClientInfo(); | 10152 | ClientInfo info = m_udpClient.GetClientInfo(); |
10032 | 10153 | ||
10033 | info.userEP = m_userEndPoint; | 10154 | info.userEP = m_userEndPoint; |
10034 | info.proxyEP = m_proxyEndPoint; | 10155 | info.proxyEP = null; |
10035 | info.agentcircuit = new sAgentCircuitData(RequestClientInfo()); | 10156 | info.agentcircuit = new sAgentCircuitData(RequestClientInfo()); |
10036 | 10157 | ||
10037 | return info; | 10158 | return info; |
10038 | } | 10159 | } |
10039 | 10160 | ||
10040 | public EndPoint GetClientEP() | 10161 | public void SetClientInfo(ClientInfo info) |
10041 | { | 10162 | { |
10042 | return m_userEndPoint; | 10163 | m_udpClient.SetClientInfo(info); |
10043 | } | 10164 | } |
10044 | 10165 | ||
10045 | public void SetClientInfo(ClientInfo info) | 10166 | public EndPoint GetClientEP() |
10046 | { | 10167 | { |
10047 | m_PacketHandler.SetClientInfo(info); | 10168 | return m_userEndPoint; |
10048 | } | 10169 | } |
10049 | 10170 | ||
10050 | #region Media Parcel Members | 10171 | #region Media Parcel Members |
@@ -10079,7 +10200,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10079 | 10200 | ||
10080 | #endregion | 10201 | #endregion |
10081 | 10202 | ||
10082 | |||
10083 | #region Camera | 10203 | #region Camera |
10084 | 10204 | ||
10085 | public void SendSetFollowCamProperties (UUID objectID, SortedDictionary<int, float> parameters) | 10205 | public void SendSetFollowCamProperties (UUID objectID, SortedDictionary<int, float> parameters) |
@@ -10109,70 +10229,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10109 | 10229 | ||
10110 | #endregion | 10230 | #endregion |
10111 | 10231 | ||
10112 | public void SendRegionHandle(UUID regionID, ulong handle) { | ||
10113 | RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply); | ||
10114 | reply.ReplyBlock.RegionID = regionID; | ||
10115 | reply.ReplyBlock.RegionHandle = handle; | ||
10116 | OutPacket(reply, ThrottleOutPacketType.Land); | ||
10117 | } | ||
10118 | |||
10119 | public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y) | ||
10120 | { | ||
10121 | ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply); | ||
10122 | reply.AgentData.AgentID = m_agentId; | ||
10123 | reply.Data.ParcelID = parcelID; | ||
10124 | reply.Data.OwnerID = land.OwnerID; | ||
10125 | reply.Data.Name = Utils.StringToBytes(land.Name); | ||
10126 | reply.Data.Desc = Utils.StringToBytes(land.Description); | ||
10127 | reply.Data.ActualArea = land.Area; | ||
10128 | reply.Data.BillableArea = land.Area; // TODO: what is this? | ||
10129 | |||
10130 | // Bit 0: Mature, bit 7: on sale, other bits: no idea | ||
10131 | reply.Data.Flags = (byte)( | ||
10132 | ((land.Flags & (uint)ParcelFlags.MaturePublish) != 0 ? (1 << 0) : 0) + | ||
10133 | ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0)); | ||
10134 | |||
10135 | Vector3 pos = land.UserLocation; | ||
10136 | if (pos.Equals(Vector3.Zero)) | ||
10137 | { | ||
10138 | pos = (land.AABBMax + land.AABBMin) * 0.5f; | ||
10139 | } | ||
10140 | reply.Data.GlobalX = info.RegionLocX * Constants.RegionSize + x; | ||
10141 | reply.Data.GlobalY = info.RegionLocY * Constants.RegionSize + y; | ||
10142 | reply.Data.GlobalZ = pos.Z; | ||
10143 | reply.Data.SimName = Utils.StringToBytes(info.RegionName); | ||
10144 | reply.Data.SnapshotID = land.SnapshotID; | ||
10145 | reply.Data.Dwell = land.Dwell; | ||
10146 | reply.Data.SalePrice = land.SalePrice; | ||
10147 | reply.Data.AuctionID = (int)land.AuctionID; | ||
10148 | |||
10149 | OutPacket(reply, ThrottleOutPacketType.Land); | ||
10150 | } | ||
10151 | |||
10152 | public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt) | ||
10153 | { | ||
10154 | ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest); | ||
10155 | |||
10156 | packet.Data.ObjectName = Utils.StringToBytes(objName); | ||
10157 | packet.Data.SimName = Utils.StringToBytes(simName); | ||
10158 | packet.Data.SimPosition = pos; | ||
10159 | packet.Data.LookAt = lookAt; | ||
10160 | |||
10161 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10162 | } | ||
10163 | |||
10164 | public void SetClientOption(string option, string value) | 10232 | public void SetClientOption(string option, string value) |
10165 | { | 10233 | { |
10166 | switch (option) | 10234 | switch (option) |
10167 | { | 10235 | { |
10168 | case "ReliableIsImportant": | 10236 | default: |
10169 | bool val; | 10237 | break; |
10170 | |||
10171 | if (bool.TryParse(value, out val)) | ||
10172 | m_PacketHandler.ReliableIsImportant = val; | ||
10173 | break; | ||
10174 | default: | ||
10175 | break; | ||
10176 | } | 10238 | } |
10177 | } | 10239 | } |
10178 | 10240 | ||
@@ -10180,571 +10242,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10180 | { | 10242 | { |
10181 | switch (option) | 10243 | switch (option) |
10182 | { | 10244 | { |
10183 | case "ReliableIsImportant": | ||
10184 | return m_PacketHandler.ReliableIsImportant.ToString(); | ||
10185 | |||
10186 | default: | 10245 | default: |
10187 | break; | 10246 | break; |
10188 | } | 10247 | } |
10189 | return string.Empty; | 10248 | return string.Empty; |
10190 | } | 10249 | } |
10191 | 10250 | ||
10192 | public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data) | ||
10193 | { | ||
10194 | DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply); | ||
10195 | |||
10196 | packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock(); | ||
10197 | |||
10198 | packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1]; | ||
10199 | packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock(); | ||
10200 | |||
10201 | packet.QueryReplies = | ||
10202 | new DirPlacesReplyPacket.QueryRepliesBlock[data.Length]; | ||
10203 | |||
10204 | packet.StatusData = new DirPlacesReplyPacket.StatusDataBlock[ | ||
10205 | data.Length]; | ||
10206 | |||
10207 | packet.AgentData.AgentID = AgentId; | ||
10208 | |||
10209 | packet.QueryData[0].QueryID = queryID; | ||
10210 | |||
10211 | int i = 0; | ||
10212 | foreach (DirPlacesReplyData d in data) | ||
10213 | { | ||
10214 | packet.QueryReplies[i] = | ||
10215 | new DirPlacesReplyPacket.QueryRepliesBlock(); | ||
10216 | packet.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock(); | ||
10217 | packet.QueryReplies[i].ParcelID = d.parcelID; | ||
10218 | packet.QueryReplies[i].Name = Utils.StringToBytes(d.name); | ||
10219 | packet.QueryReplies[i].ForSale = d.forSale; | ||
10220 | packet.QueryReplies[i].Auction = d.auction; | ||
10221 | packet.QueryReplies[i].Dwell = d.dwell; | ||
10222 | packet.StatusData[i].Status = d.Status; | ||
10223 | i++; | ||
10224 | } | ||
10225 | |||
10226 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10227 | } | ||
10228 | |||
10229 | public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data) | ||
10230 | { | ||
10231 | DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply); | ||
10232 | |||
10233 | packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock(); | ||
10234 | packet.AgentData.AgentID = AgentId; | ||
10235 | |||
10236 | packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock(); | ||
10237 | packet.QueryData.QueryID = queryID; | ||
10238 | |||
10239 | packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[ | ||
10240 | data.Length]; | ||
10241 | |||
10242 | int i = 0; | ||
10243 | foreach (DirPeopleReplyData d in data) | ||
10244 | { | ||
10245 | packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock(); | ||
10246 | packet.QueryReplies[i].AgentID = d.agentID; | ||
10247 | packet.QueryReplies[i].FirstName = | ||
10248 | Utils.StringToBytes(d.firstName); | ||
10249 | packet.QueryReplies[i].LastName = | ||
10250 | Utils.StringToBytes(d.lastName); | ||
10251 | packet.QueryReplies[i].Group = | ||
10252 | Utils.StringToBytes(d.group); | ||
10253 | packet.QueryReplies[i].Online = d.online; | ||
10254 | packet.QueryReplies[i].Reputation = d.reputation; | ||
10255 | i++; | ||
10256 | } | ||
10257 | |||
10258 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10259 | } | ||
10260 | |||
10261 | public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data) | ||
10262 | { | ||
10263 | DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply); | ||
10264 | |||
10265 | packet.AgentData = new DirEventsReplyPacket.AgentDataBlock(); | ||
10266 | packet.AgentData.AgentID = AgentId; | ||
10267 | |||
10268 | packet.QueryData = new DirEventsReplyPacket.QueryDataBlock(); | ||
10269 | packet.QueryData.QueryID = queryID; | ||
10270 | |||
10271 | packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[ | ||
10272 | data.Length]; | ||
10273 | |||
10274 | packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[ | ||
10275 | data.Length]; | ||
10276 | |||
10277 | int i = 0; | ||
10278 | foreach (DirEventsReplyData d in data) | ||
10279 | { | ||
10280 | packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock(); | ||
10281 | packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock(); | ||
10282 | packet.QueryReplies[i].OwnerID = d.ownerID; | ||
10283 | packet.QueryReplies[i].Name = | ||
10284 | Utils.StringToBytes(d.name); | ||
10285 | packet.QueryReplies[i].EventID = d.eventID; | ||
10286 | packet.QueryReplies[i].Date = | ||
10287 | Utils.StringToBytes(d.date); | ||
10288 | packet.QueryReplies[i].UnixTime = d.unixTime; | ||
10289 | packet.QueryReplies[i].EventFlags = d.eventFlags; | ||
10290 | packet.StatusData[i].Status = d.Status; | ||
10291 | i++; | ||
10292 | } | ||
10293 | |||
10294 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10295 | } | ||
10296 | |||
10297 | public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data) | ||
10298 | { | ||
10299 | DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply); | ||
10300 | |||
10301 | packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock(); | ||
10302 | packet.AgentData.AgentID = AgentId; | ||
10303 | |||
10304 | packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock(); | ||
10305 | packet.QueryData.QueryID = queryID; | ||
10306 | |||
10307 | packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[ | ||
10308 | data.Length]; | ||
10309 | |||
10310 | int i = 0; | ||
10311 | foreach (DirGroupsReplyData d in data) | ||
10312 | { | ||
10313 | packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock(); | ||
10314 | packet.QueryReplies[i].GroupID = d.groupID; | ||
10315 | packet.QueryReplies[i].GroupName = | ||
10316 | Utils.StringToBytes(d.groupName); | ||
10317 | packet.QueryReplies[i].Members = d.members; | ||
10318 | packet.QueryReplies[i].SearchOrder = d.searchOrder; | ||
10319 | i++; | ||
10320 | } | ||
10321 | |||
10322 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10323 | } | ||
10324 | |||
10325 | public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data) | ||
10326 | { | ||
10327 | DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply); | ||
10328 | |||
10329 | packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock(); | ||
10330 | packet.AgentData.AgentID = AgentId; | ||
10331 | |||
10332 | packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock(); | ||
10333 | packet.QueryData.QueryID = queryID; | ||
10334 | |||
10335 | packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[ | ||
10336 | data.Length]; | ||
10337 | packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[ | ||
10338 | data.Length]; | ||
10339 | |||
10340 | int i = 0; | ||
10341 | foreach (DirClassifiedReplyData d in data) | ||
10342 | { | ||
10343 | packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock(); | ||
10344 | packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock(); | ||
10345 | packet.QueryReplies[i].ClassifiedID = d.classifiedID; | ||
10346 | packet.QueryReplies[i].Name = | ||
10347 | Utils.StringToBytes(d.name); | ||
10348 | packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags; | ||
10349 | packet.QueryReplies[i].CreationDate = d.creationDate; | ||
10350 | packet.QueryReplies[i].ExpirationDate = d.expirationDate; | ||
10351 | packet.QueryReplies[i].PriceForListing = d.price; | ||
10352 | packet.StatusData[i].Status = d.Status; | ||
10353 | i++; | ||
10354 | } | ||
10355 | |||
10356 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10357 | } | ||
10358 | |||
10359 | public void SendDirLandReply(UUID queryID, DirLandReplyData[] data) | ||
10360 | { | ||
10361 | DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply); | ||
10362 | |||
10363 | packet.AgentData = new DirLandReplyPacket.AgentDataBlock(); | ||
10364 | packet.AgentData.AgentID = AgentId; | ||
10365 | |||
10366 | packet.QueryData = new DirLandReplyPacket.QueryDataBlock(); | ||
10367 | packet.QueryData.QueryID = queryID; | ||
10368 | |||
10369 | packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[ | ||
10370 | data.Length]; | ||
10371 | |||
10372 | int i = 0; | ||
10373 | foreach (DirLandReplyData d in data) | ||
10374 | { | ||
10375 | packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock(); | ||
10376 | packet.QueryReplies[i].ParcelID = d.parcelID; | ||
10377 | packet.QueryReplies[i].Name = | ||
10378 | Utils.StringToBytes(d.name); | ||
10379 | packet.QueryReplies[i].Auction = d.auction; | ||
10380 | packet.QueryReplies[i].ForSale = d.forSale; | ||
10381 | packet.QueryReplies[i].SalePrice = d.salePrice; | ||
10382 | packet.QueryReplies[i].ActualArea = d.actualArea; | ||
10383 | i++; | ||
10384 | } | ||
10385 | |||
10386 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10387 | } | ||
10388 | |||
10389 | public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data) | ||
10390 | { | ||
10391 | DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply); | ||
10392 | |||
10393 | packet.AgentData = new DirPopularReplyPacket.AgentDataBlock(); | ||
10394 | packet.AgentData.AgentID = AgentId; | ||
10395 | |||
10396 | packet.QueryData = new DirPopularReplyPacket.QueryDataBlock(); | ||
10397 | packet.QueryData.QueryID = queryID; | ||
10398 | |||
10399 | packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[ | ||
10400 | data.Length]; | ||
10401 | |||
10402 | int i = 0; | ||
10403 | foreach (DirPopularReplyData d in data) | ||
10404 | { | ||
10405 | packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock(); | ||
10406 | packet.QueryReplies[i].ParcelID = d.parcelID; | ||
10407 | packet.QueryReplies[i].Name = | ||
10408 | Utils.StringToBytes(d.name); | ||
10409 | packet.QueryReplies[i].Dwell = d.dwell; | ||
10410 | i++; | ||
10411 | } | ||
10412 | |||
10413 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10414 | } | ||
10415 | |||
10416 | public void SendEventInfoReply(EventData data) | ||
10417 | { | ||
10418 | EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply); | ||
10419 | |||
10420 | packet.AgentData = new EventInfoReplyPacket.AgentDataBlock(); | ||
10421 | packet.AgentData.AgentID = AgentId; | ||
10422 | |||
10423 | packet.EventData = new EventInfoReplyPacket.EventDataBlock(); | ||
10424 | packet.EventData.EventID = data.eventID; | ||
10425 | packet.EventData.Creator = Utils.StringToBytes(data.creator); | ||
10426 | packet.EventData.Name = Utils.StringToBytes(data.name); | ||
10427 | packet.EventData.Category = Utils.StringToBytes(data.category); | ||
10428 | packet.EventData.Desc = Utils.StringToBytes(data.description); | ||
10429 | packet.EventData.Date = Utils.StringToBytes(data.date); | ||
10430 | packet.EventData.DateUTC = data.dateUTC; | ||
10431 | packet.EventData.Duration = data.duration; | ||
10432 | packet.EventData.Cover = data.cover; | ||
10433 | packet.EventData.Amount = data.amount; | ||
10434 | packet.EventData.SimName = Utils.StringToBytes(data.simName); | ||
10435 | packet.EventData.GlobalPos = new Vector3d(data.globalPos); | ||
10436 | packet.EventData.EventFlags = data.eventFlags; | ||
10437 | |||
10438 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
10439 | } | ||
10440 | |||
10441 | public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) | ||
10442 | { | ||
10443 | MapItemReplyPacket mirplk = new MapItemReplyPacket(); | ||
10444 | mirplk.AgentData.AgentID = AgentId; | ||
10445 | mirplk.RequestData.ItemType = mapitemtype; | ||
10446 | mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length]; | ||
10447 | for (int i = 0; i < replies.Length; i++) | ||
10448 | { | ||
10449 | MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock(); | ||
10450 | mrdata.X = replies[i].x; | ||
10451 | mrdata.Y = replies[i].y; | ||
10452 | mrdata.ID = replies[i].id; | ||
10453 | mrdata.Extra = replies[i].Extra; | ||
10454 | mrdata.Extra2 = replies[i].Extra2; | ||
10455 | mrdata.Name = Utils.StringToBytes(replies[i].name); | ||
10456 | mirplk.Data[i] = mrdata; | ||
10457 | } | ||
10458 | //m_log.Debug(mirplk.ToString()); | ||
10459 | OutPacket(mirplk, ThrottleOutPacketType.Task); | ||
10460 | |||
10461 | } | ||
10462 | |||
10463 | public void SendOfferCallingCard(UUID srcID, UUID transactionID) | ||
10464 | { | ||
10465 | // a bit special, as this uses AgentID to store the source instead | ||
10466 | // of the destination. The destination (the receiver) goes into destID | ||
10467 | OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard); | ||
10468 | p.AgentData.AgentID = srcID; | ||
10469 | p.AgentData.SessionID = UUID.Zero; | ||
10470 | p.AgentBlock.DestID = AgentId; | ||
10471 | p.AgentBlock.TransactionID = transactionID; | ||
10472 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10473 | } | ||
10474 | |||
10475 | public void SendAcceptCallingCard(UUID transactionID) | ||
10476 | { | ||
10477 | AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard); | ||
10478 | p.AgentData.AgentID = AgentId; | ||
10479 | p.AgentData.SessionID = UUID.Zero; | ||
10480 | p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1]; | ||
10481 | p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock(); | ||
10482 | p.FolderData[0].FolderID = UUID.Zero; | ||
10483 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10484 | } | ||
10485 | |||
10486 | public void SendDeclineCallingCard(UUID transactionID) | ||
10487 | { | ||
10488 | DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard); | ||
10489 | p.AgentData.AgentID = AgentId; | ||
10490 | p.AgentData.SessionID = UUID.Zero; | ||
10491 | p.TransactionBlock.TransactionID = transactionID; | ||
10492 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10493 | } | ||
10494 | |||
10495 | public void SendTerminateFriend(UUID exFriendID) | ||
10496 | { | ||
10497 | TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship); | ||
10498 | p.AgentData.AgentID = AgentId; | ||
10499 | p.AgentData.SessionID = SessionId; | ||
10500 | p.ExBlock.OtherID = exFriendID; | ||
10501 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10502 | } | ||
10503 | |||
10504 | public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) | ||
10505 | { | ||
10506 | AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); | ||
10507 | |||
10508 | p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); | ||
10509 | p.AgentData.AgentID = AgentId; | ||
10510 | p.AgentData.AvatarID = avatarID; | ||
10511 | |||
10512 | p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; | ||
10513 | int i = 0; | ||
10514 | foreach (GroupMembershipData m in data) | ||
10515 | { | ||
10516 | p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); | ||
10517 | p.GroupData[i].GroupPowers = m.GroupPowers; | ||
10518 | p.GroupData[i].AcceptNotices = m.AcceptNotices; | ||
10519 | p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); | ||
10520 | p.GroupData[i].GroupID = m.GroupID; | ||
10521 | p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); | ||
10522 | p.GroupData[i].GroupInsigniaID = m.GroupPicture; | ||
10523 | i++; | ||
10524 | } | ||
10525 | |||
10526 | p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); | ||
10527 | p.NewGroupData.ListInProfile = true; | ||
10528 | |||
10529 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10530 | } | ||
10531 | |||
10532 | public void SendJoinGroupReply(UUID groupID, bool success) | ||
10533 | { | ||
10534 | JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply); | ||
10535 | |||
10536 | p.AgentData = new JoinGroupReplyPacket.AgentDataBlock(); | ||
10537 | p.AgentData.AgentID = AgentId; | ||
10538 | |||
10539 | p.GroupData = new JoinGroupReplyPacket.GroupDataBlock(); | ||
10540 | p.GroupData.GroupID = groupID; | ||
10541 | p.GroupData.Success = success; | ||
10542 | |||
10543 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10544 | } | ||
10545 | |||
10546 | public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) | ||
10547 | { | ||
10548 | EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply); | ||
10549 | |||
10550 | p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock(); | ||
10551 | p.AgentData.AgentID = agentID; | ||
10552 | |||
10553 | p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock(); | ||
10554 | p.GroupData.GroupID = groupID; | ||
10555 | |||
10556 | p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock(); | ||
10557 | p.EjectData.Success = success; | ||
10558 | |||
10559 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10560 | } | ||
10561 | |||
10562 | public void SendLeaveGroupReply(UUID groupID, bool success) | ||
10563 | { | ||
10564 | LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply); | ||
10565 | |||
10566 | p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock(); | ||
10567 | p.AgentData.AgentID = AgentId; | ||
10568 | |||
10569 | p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock(); | ||
10570 | p.GroupData.GroupID = groupID; | ||
10571 | p.GroupData.Success = success; | ||
10572 | |||
10573 | OutPacket(p, ThrottleOutPacketType.Task); | ||
10574 | } | ||
10575 | |||
10576 | public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) | ||
10577 | { | ||
10578 | if (classifiedID.Length != name.Length) | ||
10579 | return; | ||
10580 | |||
10581 | AvatarClassifiedReplyPacket ac = | ||
10582 | (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( | ||
10583 | PacketType.AvatarClassifiedReply); | ||
10584 | |||
10585 | ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); | ||
10586 | ac.AgentData.AgentID = AgentId; | ||
10587 | ac.AgentData.TargetID = targetID; | ||
10588 | |||
10589 | ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length]; | ||
10590 | int i; | ||
10591 | for (i = 0 ; i < classifiedID.Length ; i++) | ||
10592 | { | ||
10593 | ac.Data[i].ClassifiedID = classifiedID[i]; | ||
10594 | ac.Data[i].Name = Utils.StringToBytes(name[i]); | ||
10595 | } | ||
10596 | |||
10597 | OutPacket(ac, ThrottleOutPacketType.Task); | ||
10598 | } | ||
10599 | |||
10600 | public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price) | ||
10601 | { | ||
10602 | ClassifiedInfoReplyPacket cr = | ||
10603 | (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket( | ||
10604 | PacketType.ClassifiedInfoReply); | ||
10605 | |||
10606 | cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock(); | ||
10607 | cr.AgentData.AgentID = AgentId; | ||
10608 | |||
10609 | cr.Data = new ClassifiedInfoReplyPacket.DataBlock(); | ||
10610 | cr.Data.ClassifiedID = classifiedID; | ||
10611 | cr.Data.CreatorID = creatorID; | ||
10612 | cr.Data.CreationDate = creationDate; | ||
10613 | cr.Data.ExpirationDate = expirationDate; | ||
10614 | cr.Data.Category = category; | ||
10615 | cr.Data.Name = Utils.StringToBytes(name); | ||
10616 | cr.Data.Desc = Utils.StringToBytes(description); | ||
10617 | cr.Data.ParcelID = parcelID; | ||
10618 | cr.Data.ParentEstate = parentEstate; | ||
10619 | cr.Data.SnapshotID = snapshotID; | ||
10620 | cr.Data.SimName = Utils.StringToBytes(simName); | ||
10621 | cr.Data.PosGlobal = new Vector3d(globalPos); | ||
10622 | cr.Data.ParcelName = Utils.StringToBytes(parcelName); | ||
10623 | cr.Data.ClassifiedFlags = classifiedFlags; | ||
10624 | cr.Data.PriceForListing = price; | ||
10625 | |||
10626 | OutPacket(cr, ThrottleOutPacketType.Task); | ||
10627 | } | ||
10628 | |||
10629 | public void SendAgentDropGroup(UUID groupID) | ||
10630 | { | ||
10631 | AgentDropGroupPacket dg = | ||
10632 | (AgentDropGroupPacket)PacketPool.Instance.GetPacket( | ||
10633 | PacketType.AgentDropGroup); | ||
10634 | |||
10635 | dg.AgentData = new AgentDropGroupPacket.AgentDataBlock(); | ||
10636 | dg.AgentData.AgentID = AgentId; | ||
10637 | dg.AgentData.GroupID = groupID; | ||
10638 | |||
10639 | OutPacket(dg, ThrottleOutPacketType.Task); | ||
10640 | } | ||
10641 | |||
10642 | public void SendAvatarNotesReply(UUID targetID, string text) | ||
10643 | { | ||
10644 | AvatarNotesReplyPacket an = | ||
10645 | (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket( | ||
10646 | PacketType.AvatarNotesReply); | ||
10647 | |||
10648 | an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock(); | ||
10649 | an.AgentData.AgentID = AgentId; | ||
10650 | |||
10651 | an.Data = new AvatarNotesReplyPacket.DataBlock(); | ||
10652 | an.Data.TargetID = targetID; | ||
10653 | an.Data.Notes = Utils.StringToBytes(text); | ||
10654 | |||
10655 | OutPacket(an, ThrottleOutPacketType.Task); | ||
10656 | } | ||
10657 | |||
10658 | public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks) | ||
10659 | { | ||
10660 | AvatarPicksReplyPacket ap = | ||
10661 | (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket( | ||
10662 | PacketType.AvatarPicksReply); | ||
10663 | |||
10664 | ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock(); | ||
10665 | ap.AgentData.AgentID = AgentId; | ||
10666 | ap.AgentData.TargetID = targetID; | ||
10667 | |||
10668 | ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count]; | ||
10669 | |||
10670 | int i = 0; | ||
10671 | foreach (KeyValuePair<UUID, string> pick in picks) | ||
10672 | { | ||
10673 | ap.Data[i] = new AvatarPicksReplyPacket.DataBlock(); | ||
10674 | ap.Data[i].PickID = pick.Key; | ||
10675 | ap.Data[i].PickName = Utils.StringToBytes(pick.Value); | ||
10676 | i++; | ||
10677 | } | ||
10678 | |||
10679 | OutPacket(ap, ThrottleOutPacketType.Task); | ||
10680 | } | ||
10681 | |||
10682 | public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds) | ||
10683 | { | ||
10684 | AvatarClassifiedReplyPacket ac = | ||
10685 | (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( | ||
10686 | PacketType.AvatarClassifiedReply); | ||
10687 | |||
10688 | ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); | ||
10689 | ac.AgentData.AgentID = AgentId; | ||
10690 | ac.AgentData.TargetID = targetID; | ||
10691 | |||
10692 | ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count]; | ||
10693 | |||
10694 | int i = 0; | ||
10695 | foreach (KeyValuePair<UUID, string> classified in classifieds) | ||
10696 | { | ||
10697 | ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock(); | ||
10698 | ac.Data[i].ClassifiedID = classified.Key; | ||
10699 | ac.Data[i].Name = Utils.StringToBytes(classified.Value); | ||
10700 | i++; | ||
10701 | } | ||
10702 | |||
10703 | OutPacket(ac, ThrottleOutPacketType.Task); | ||
10704 | } | ||
10705 | |||
10706 | public void SendParcelDwellReply(int localID, UUID parcelID, float dwell) | ||
10707 | { | ||
10708 | ParcelDwellReplyPacket pd = | ||
10709 | (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket( | ||
10710 | PacketType.ParcelDwellReply); | ||
10711 | |||
10712 | pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock(); | ||
10713 | pd.AgentData.AgentID = AgentId; | ||
10714 | |||
10715 | pd.Data = new ParcelDwellReplyPacket.DataBlock(); | ||
10716 | pd.Data.LocalID = localID; | ||
10717 | pd.Data.ParcelID = parcelID; | ||
10718 | pd.Data.Dwell = dwell; | ||
10719 | |||
10720 | OutPacket(pd, ThrottleOutPacketType.Land); | ||
10721 | } | ||
10722 | |||
10723 | public void SendUserInfoReply(bool imViaEmail, bool visible, string email) | ||
10724 | { | ||
10725 | UserInfoReplyPacket ur = | ||
10726 | (UserInfoReplyPacket)PacketPool.Instance.GetPacket( | ||
10727 | PacketType.UserInfoReply); | ||
10728 | |||
10729 | string Visible = "hidden"; | ||
10730 | if (visible) | ||
10731 | Visible = "default"; | ||
10732 | |||
10733 | ur.AgentData = new UserInfoReplyPacket.AgentDataBlock(); | ||
10734 | ur.AgentData.AgentID = AgentId; | ||
10735 | |||
10736 | ur.UserData = new UserInfoReplyPacket.UserDataBlock(); | ||
10737 | ur.UserData.IMViaEMail = imViaEmail; | ||
10738 | ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible); | ||
10739 | ur.UserData.EMail = Utils.StringToBytes(email); | ||
10740 | |||
10741 | OutPacket(ur, ThrottleOutPacketType.Task); | ||
10742 | } | ||
10743 | |||
10744 | public void KillEndDone() | 10251 | public void KillEndDone() |
10745 | { | 10252 | { |
10746 | KillPacket kp = new KillPacket(); | 10253 | m_udpClient.Shutdown(); |
10747 | OutPacket(kp, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); | ||
10748 | } | 10254 | } |
10749 | 10255 | ||
10750 | #region IClientCore | 10256 | #region IClientCore |
@@ -10767,13 +10273,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10767 | } | 10273 | } |
10768 | } | 10274 | } |
10769 | 10275 | ||
10770 | protected virtual void RegisterInterfaces() | ||
10771 | { | ||
10772 | RegisterInterface<IClientIM>(this); | ||
10773 | RegisterInterface<IClientChat>(this); | ||
10774 | RegisterInterface<IClientIPEndpoint>(this); | ||
10775 | } | ||
10776 | |||
10777 | public bool TryGet<T>(out T iface) | 10276 | public bool TryGet<T>(out T iface) |
10778 | { | 10277 | { |
10779 | if (m_clientInterfaces.ContainsKey(typeof(T))) | 10278 | if (m_clientInterfaces.ContainsKey(typeof(T))) |
@@ -10821,78 +10320,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10821 | } | 10320 | } |
10822 | } | 10321 | } |
10823 | 10322 | ||
10824 | public void SendCreateGroupReply(UUID groupID, bool success, string message) | ||
10825 | { | ||
10826 | CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply); | ||
10827 | |||
10828 | createGroupReply.AgentData = | ||
10829 | new CreateGroupReplyPacket.AgentDataBlock(); | ||
10830 | createGroupReply.ReplyData = | ||
10831 | new CreateGroupReplyPacket.ReplyDataBlock(); | ||
10832 | |||
10833 | createGroupReply.AgentData.AgentID = AgentId; | ||
10834 | createGroupReply.ReplyData.GroupID = groupID; | ||
10835 | |||
10836 | createGroupReply.ReplyData.Success = success; | ||
10837 | createGroupReply.ReplyData.Message = Utils.StringToBytes(message); | ||
10838 | OutPacket(createGroupReply, ThrottleOutPacketType.Task); | ||
10839 | } | ||
10840 | |||
10841 | public void SendUseCachedMuteList() | ||
10842 | { | ||
10843 | UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList); | ||
10844 | |||
10845 | useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock(); | ||
10846 | useCachedMuteList.AgentData.AgentID = AgentId; | ||
10847 | |||
10848 | OutPacket(useCachedMuteList, ThrottleOutPacketType.Task); | ||
10849 | } | ||
10850 | |||
10851 | public void SendMuteListUpdate(string filename) | ||
10852 | { | ||
10853 | MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate); | ||
10854 | |||
10855 | muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock(); | ||
10856 | muteListUpdate.MuteData.AgentID = AgentId; | ||
10857 | muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename); | ||
10858 | |||
10859 | OutPacket(muteListUpdate, ThrottleOutPacketType.Task); | ||
10860 | } | ||
10861 | |||
10862 | public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) | ||
10863 | { | ||
10864 | PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply); | ||
10865 | |||
10866 | pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock(); | ||
10867 | pickInfoReply.AgentData.AgentID = AgentId; | ||
10868 | |||
10869 | pickInfoReply.Data = new PickInfoReplyPacket.DataBlock(); | ||
10870 | pickInfoReply.Data.PickID = pickID; | ||
10871 | pickInfoReply.Data.CreatorID = creatorID; | ||
10872 | pickInfoReply.Data.TopPick = topPick; | ||
10873 | pickInfoReply.Data.ParcelID = parcelID; | ||
10874 | pickInfoReply.Data.Name = Utils.StringToBytes(name); | ||
10875 | pickInfoReply.Data.Desc = Utils.StringToBytes(desc); | ||
10876 | pickInfoReply.Data.SnapshotID = snapshotID; | ||
10877 | pickInfoReply.Data.User = Utils.StringToBytes(user); | ||
10878 | pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName); | ||
10879 | pickInfoReply.Data.SimName = Utils.StringToBytes(simName); | ||
10880 | pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal); | ||
10881 | pickInfoReply.Data.SortOrder = sortOrder; | ||
10882 | pickInfoReply.Data.Enabled = enabled; | ||
10883 | |||
10884 | OutPacket(pickInfoReply, ThrottleOutPacketType.Task); | ||
10885 | } | ||
10886 | |||
10887 | public string Report() | 10323 | public string Report() |
10888 | { | 10324 | { |
10889 | LLPacketHandler handler = (LLPacketHandler) m_PacketHandler; | 10325 | return m_udpClient.GetStats(); |
10890 | return handler.PacketQueue.GetStats(); | ||
10891 | } | 10326 | } |
10892 | 10327 | ||
10893 | public string XReport(string uptime, string version) | 10328 | public string XReport(string uptime, string version) |
10894 | { | 10329 | { |
10895 | return ""; | 10330 | return String.Empty; |
10896 | } | 10331 | } |
10897 | 10332 | ||
10898 | public void MakeAssetRequest(TransferRequestPacket transferRequest) | 10333 | public void MakeAssetRequest(TransferRequestPacket transferRequest) |
@@ -10981,7 +10416,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
10981 | return numPackets; | 10416 | return numPackets; |
10982 | } | 10417 | } |
10983 | 10418 | ||
10984 | |||
10985 | #region IClientIPEndpoint Members | 10419 | #region IClientIPEndpoint Members |
10986 | 10420 | ||
10987 | public IPAddress EndPoint | 10421 | public IPAddress EndPoint |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index cc290ed..343f537 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | |||
@@ -172,7 +172,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
172 | m_lastloopprocessed = DateTime.Now.Ticks; | 172 | m_lastloopprocessed = DateTime.Now.Ticks; |
173 | 173 | ||
174 | // This can happen during Close() | 174 | // This can happen during Close() |
175 | if (m_client == null || m_client.PacketHandler == null || m_client.PacketHandler.PacketQueue == null) | 175 | if (m_client == null) |
176 | return false; | 176 | return false; |
177 | 177 | ||
178 | while ((imagereq = GetHighestPriorityImage()) != null) | 178 | while ((imagereq = GetHighestPriorityImage()) != null) |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs deleted file mode 100644 index e98a360..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ /dev/null | |||
@@ -1,870 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net.Sockets; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.Packets; | ||
36 | using log4net; | ||
37 | using OpenSim.Framework; | ||
38 | using Timer=System.Timers.Timer; | ||
39 | |||
40 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
41 | { | ||
42 | public class LLPacketHandler : ILLPacketHandler | ||
43 | { | ||
44 | private static readonly ILog m_log | ||
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | //private int m_resentCount; | ||
48 | |||
49 | // Packet queues | ||
50 | // | ||
51 | LLPacketQueue m_PacketQueue; | ||
52 | |||
53 | public LLPacketQueue PacketQueue | ||
54 | { | ||
55 | get { return m_PacketQueue; } | ||
56 | } | ||
57 | |||
58 | // Timer to run stats and acks on | ||
59 | // | ||
60 | private Timer m_AckTimer = new Timer(250); | ||
61 | |||
62 | // A list of the packets we haven't acked yet | ||
63 | // | ||
64 | private List<uint> m_PendingAcks = new List<uint>(); | ||
65 | private Dictionary<uint, uint> m_PendingAcksMap = new Dictionary<uint, uint>(); | ||
66 | |||
67 | private Dictionary<uint, LLQueItem> m_NeedAck = | ||
68 | new Dictionary<uint, LLQueItem>(); | ||
69 | |||
70 | /// <summary> | ||
71 | /// The number of milliseconds that can pass before a packet that needs an ack is resent. | ||
72 | /// </param> | ||
73 | private uint m_ResendTimeout = 4000; | ||
74 | |||
75 | public uint ResendTimeout | ||
76 | { | ||
77 | get { return m_ResendTimeout; } | ||
78 | set { m_ResendTimeout = value; } | ||
79 | } | ||
80 | |||
81 | private int m_MaxReliableResends = 3; | ||
82 | |||
83 | public int MaxReliableResends | ||
84 | { | ||
85 | get { return m_MaxReliableResends; } | ||
86 | set { m_MaxReliableResends = value; } | ||
87 | } | ||
88 | |||
89 | // Track duplicated packets. This uses a Dictionary. Both insertion | ||
90 | // and lookup are common operations and need to take advantage of | ||
91 | // the hashing. Expiration is less common and can be allowed the | ||
92 | // time for a linear scan. | ||
93 | // | ||
94 | private List<uint> m_alreadySeenList = new List<uint>(); | ||
95 | private Dictionary<uint, int>m_alreadySeenTracker = new Dictionary<uint, int>(); | ||
96 | private int m_alreadySeenWindow = 30000; | ||
97 | private int m_lastAlreadySeenCheck = Environment.TickCount & Int32.MaxValue; | ||
98 | |||
99 | // private Dictionary<uint, int> m_DupeTracker = | ||
100 | // new Dictionary<uint, int>(); | ||
101 | // private uint m_DupeTrackerWindow = 30; | ||
102 | // private int m_DupeTrackerLastCheck = Environment.TickCount; | ||
103 | |||
104 | // Values for the SimStatsReporter | ||
105 | // | ||
106 | private int m_PacketsReceived = 0; | ||
107 | private int m_PacketsReceivedReported = 0; | ||
108 | private int m_PacketsSent = 0; | ||
109 | private int m_PacketsSentReported = 0; | ||
110 | private int m_UnackedBytes = 0; | ||
111 | |||
112 | private int m_LastResend = 0; | ||
113 | |||
114 | public int PacketsReceived | ||
115 | { | ||
116 | get { return m_PacketsReceived; } | ||
117 | } | ||
118 | |||
119 | public int PacketsReceivedReported | ||
120 | { | ||
121 | get { return m_PacketsReceivedReported; } | ||
122 | } | ||
123 | |||
124 | // The client we are working for | ||
125 | // | ||
126 | private IClientAPI m_Client; | ||
127 | |||
128 | // Some events | ||
129 | // | ||
130 | public event PacketStats OnPacketStats; | ||
131 | public event PacketDrop OnPacketDrop; | ||
132 | public event QueueEmpty OnQueueEmpty; | ||
133 | |||
134 | |||
135 | //private SynchronizeClientHandler m_SynchronizeClient = null; | ||
136 | |||
137 | public SynchronizeClientHandler SynchronizeClient | ||
138 | { | ||
139 | set { /* m_SynchronizeClient = value; */ } | ||
140 | } | ||
141 | |||
142 | // Packet sequencing | ||
143 | // | ||
144 | private uint m_Sequence = 0; | ||
145 | private object m_SequenceLock = new object(); | ||
146 | private const int MAX_SEQUENCE = 0xFFFFFF; | ||
147 | |||
148 | // Packet dropping | ||
149 | // | ||
150 | List<PacketType> m_ImportantPackets = new List<PacketType>(); | ||
151 | private bool m_ReliableIsImportant = false; | ||
152 | |||
153 | public bool ReliableIsImportant | ||
154 | { | ||
155 | get { return m_ReliableIsImportant; } | ||
156 | set { m_ReliableIsImportant = value; } | ||
157 | } | ||
158 | |||
159 | private int m_DropSafeTimeout; | ||
160 | |||
161 | LLPacketServer m_PacketServer; | ||
162 | private byte[] m_ZeroOutBuffer = new byte[4096]; | ||
163 | |||
164 | //////////////////////////////////////////////////////////////////// | ||
165 | |||
166 | // Constructors | ||
167 | // | ||
168 | public LLPacketHandler(IClientAPI client, LLPacketServer server, ClientStackUserSettings userSettings) | ||
169 | { | ||
170 | m_Client = client; | ||
171 | m_PacketServer = server; | ||
172 | m_DropSafeTimeout = Environment.TickCount + 15000; | ||
173 | |||
174 | m_PacketQueue = new LLPacketQueue(client.AgentId, userSettings); | ||
175 | |||
176 | m_PacketQueue.OnQueueEmpty += TriggerOnQueueEmpty; | ||
177 | |||
178 | m_AckTimer.Elapsed += AckTimerElapsed; | ||
179 | m_AckTimer.Start(); | ||
180 | } | ||
181 | |||
182 | public void Dispose() | ||
183 | { | ||
184 | m_AckTimer.Stop(); | ||
185 | m_AckTimer.Close(); | ||
186 | |||
187 | m_PacketQueue.Enqueue(null); | ||
188 | m_PacketQueue.Close(); | ||
189 | m_Client = null; | ||
190 | } | ||
191 | |||
192 | // Send one packet. This actually doesn't send anything, it queues | ||
193 | // it. Designed to be fire-and-forget, but there is an optional | ||
194 | // notifier. | ||
195 | // | ||
196 | public void OutPacket( | ||
197 | Packet packet, ThrottleOutPacketType throttlePacketType) | ||
198 | { | ||
199 | OutPacket(packet, throttlePacketType, null); | ||
200 | } | ||
201 | |||
202 | public void OutPacket( | ||
203 | Packet packet, ThrottleOutPacketType throttlePacketType, | ||
204 | Object id) | ||
205 | { | ||
206 | // Call the load balancer's hook. If this is not active here | ||
207 | // we defer to the sim server this client is actually connected | ||
208 | // to. Packet drop notifies will not be triggered in this | ||
209 | // configuration! | ||
210 | // | ||
211 | |||
212 | packet.Header.Sequence = 0; | ||
213 | |||
214 | lock (m_NeedAck) | ||
215 | { | ||
216 | DropResend(id); | ||
217 | |||
218 | AddAcks(ref packet); | ||
219 | QueuePacket(packet, throttlePacketType, id); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | private void AddAcks(ref Packet packet) | ||
224 | { | ||
225 | // These packet types have shown to have issues with | ||
226 | // acks being appended to the payload, just don't send | ||
227 | // any with them until libsl is fixed. | ||
228 | // | ||
229 | if (packet is ViewerEffectPacket) | ||
230 | return; | ||
231 | if (packet is SimStatsPacket) | ||
232 | return; | ||
233 | |||
234 | // Add acks to outgoing packets | ||
235 | // | ||
236 | if (m_PendingAcks.Count > 0) | ||
237 | { | ||
238 | int count = m_PendingAcks.Count; | ||
239 | if (count > 10) | ||
240 | count = 10; | ||
241 | packet.Header.AckList = new uint[count]; | ||
242 | packet.Header.AppendedAcks = true; | ||
243 | |||
244 | for (int i = 0; i < count; i++) | ||
245 | { | ||
246 | packet.Header.AckList[i] = m_PendingAcks[i]; | ||
247 | m_PendingAcksMap.Remove(m_PendingAcks[i]); | ||
248 | } | ||
249 | m_PendingAcks.RemoveRange(0, count); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | private void QueuePacket( | ||
254 | Packet packet, ThrottleOutPacketType throttlePacketType, | ||
255 | Object id) | ||
256 | { | ||
257 | LLQueItem item = new LLQueItem(); | ||
258 | item.Packet = packet; | ||
259 | item.Incoming = false; | ||
260 | item.throttleType = throttlePacketType; | ||
261 | item.TickCount = Environment.TickCount; | ||
262 | item.Identifier = id; | ||
263 | item.Resends = 0; | ||
264 | item.Length = packet.Length; | ||
265 | item.Sequence = packet.Header.Sequence; | ||
266 | |||
267 | m_PacketQueue.Enqueue(item); | ||
268 | m_PacketsSent++; | ||
269 | } | ||
270 | |||
271 | private void ResendUnacked() | ||
272 | { | ||
273 | int now = Environment.TickCount; | ||
274 | |||
275 | int intervalMs = 250; | ||
276 | |||
277 | if (m_LastResend != 0) | ||
278 | intervalMs = now - m_LastResend; | ||
279 | |||
280 | lock (m_NeedAck) | ||
281 | { | ||
282 | if (m_DropSafeTimeout > now || | ||
283 | intervalMs > 500) // We were frozen! | ||
284 | { | ||
285 | foreach (LLQueItem data in m_NeedAck.Values) | ||
286 | { | ||
287 | if (m_DropSafeTimeout > now) | ||
288 | { | ||
289 | m_NeedAck[data.Packet.Header.Sequence].TickCount = now; | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | m_NeedAck[data.Packet.Header.Sequence].TickCount += intervalMs; | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | |||
298 | m_LastResend = now; | ||
299 | |||
300 | // Unless we have received at least one ack, don't bother resending | ||
301 | // anything. There may not be a client there, don't clog up the | ||
302 | // pipes. | ||
303 | |||
304 | |||
305 | // Nothing to do | ||
306 | // | ||
307 | if (m_NeedAck.Count == 0) | ||
308 | return; | ||
309 | |||
310 | int resent = 0; | ||
311 | long dueDate = now - m_ResendTimeout; | ||
312 | |||
313 | List<LLQueItem> dropped = new List<LLQueItem>(); | ||
314 | foreach (LLQueItem data in m_NeedAck.Values) | ||
315 | { | ||
316 | Packet packet = data.Packet; | ||
317 | |||
318 | // Packets this old get resent | ||
319 | // | ||
320 | if (data.TickCount < dueDate && data.Sequence != 0 && !m_PacketQueue.Contains(data.Sequence)) | ||
321 | { | ||
322 | if (resent < 20) // Was 20 (= Max 117kbit/sec resends) | ||
323 | { | ||
324 | m_NeedAck[packet.Header.Sequence].Resends++; | ||
325 | |||
326 | // The client needs to be told that a packet is being resent, otherwise it appears to believe | ||
327 | // that it should reset its sequence to that packet number. | ||
328 | packet.Header.Resent = true; | ||
329 | |||
330 | if ((m_NeedAck[packet.Header.Sequence].Resends >= m_MaxReliableResends) && | ||
331 | (!m_ReliableIsImportant)) | ||
332 | { | ||
333 | dropped.Add(data); | ||
334 | continue; | ||
335 | } | ||
336 | |||
337 | m_NeedAck[packet.Header.Sequence].TickCount = Environment.TickCount; | ||
338 | QueuePacket(packet, ThrottleOutPacketType.Resend, data.Identifier); | ||
339 | resent++; | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | m_NeedAck[packet.Header.Sequence].TickCount += intervalMs; | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | |||
348 | foreach (LLQueItem data in dropped) | ||
349 | { | ||
350 | m_NeedAck.Remove(data.Packet.Header.Sequence); | ||
351 | TriggerOnPacketDrop(data.Packet, data.Identifier); | ||
352 | m_PacketQueue.Cancel(data.Packet.Header.Sequence); | ||
353 | PacketPool.Instance.ReturnPacket(data.Packet); | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | |||
358 | // Send the pending packet acks to the client | ||
359 | // Will send blocks of acks for up to 250 packets | ||
360 | // | ||
361 | private void SendAcks() | ||
362 | { | ||
363 | lock (m_NeedAck) | ||
364 | { | ||
365 | if (m_PendingAcks.Count == 0) | ||
366 | return; | ||
367 | |||
368 | PacketAckPacket acks = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); | ||
369 | |||
370 | // The case of equality is more common than one might think, | ||
371 | // because this function will be called unconditionally when | ||
372 | // the counter reaches 250. So there is a good chance another | ||
373 | // packet with 250 blocks exists. | ||
374 | // | ||
375 | if (acks.Packets == null || | ||
376 | acks.Packets.Length != m_PendingAcks.Count) | ||
377 | acks.Packets = new PacketAckPacket.PacketsBlock[m_PendingAcks.Count]; | ||
378 | |||
379 | for (int i = 0; i < m_PendingAcks.Count; i++) | ||
380 | { | ||
381 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
382 | acks.Packets[i].ID = m_PendingAcks[i]; | ||
383 | |||
384 | } | ||
385 | m_PendingAcks.Clear(); | ||
386 | m_PendingAcksMap.Clear(); | ||
387 | |||
388 | acks.Header.Reliable = false; | ||
389 | OutPacket(acks, ThrottleOutPacketType.Unknown); | ||
390 | } | ||
391 | } | ||
392 | |||
393 | // Queue a packet ack. It will be sent either after 250 acks are | ||
394 | // queued, or when the timer fires. | ||
395 | // | ||
396 | private void AckPacket(Packet packet) | ||
397 | { | ||
398 | lock (m_NeedAck) | ||
399 | { | ||
400 | if (m_PendingAcks.Count < 250) | ||
401 | { | ||
402 | if (!m_PendingAcksMap.ContainsKey(packet.Header.Sequence)) | ||
403 | { | ||
404 | m_PendingAcks.Add(packet.Header.Sequence); | ||
405 | m_PendingAcksMap.Add(packet.Header.Sequence, | ||
406 | packet.Header.Sequence); | ||
407 | } | ||
408 | return; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | SendAcks(); | ||
413 | |||
414 | lock (m_NeedAck) | ||
415 | { | ||
416 | // If this is still full we have a truly exceptional | ||
417 | // condition (means, can't happen) | ||
418 | // | ||
419 | if (m_PendingAcks.Count < 250) | ||
420 | { | ||
421 | if (!m_PendingAcksMap.ContainsKey(packet.Header.Sequence)) | ||
422 | { | ||
423 | m_PendingAcks.Add(packet.Header.Sequence); | ||
424 | m_PendingAcksMap.Add(packet.Header.Sequence, | ||
425 | packet.Header.Sequence); | ||
426 | } | ||
427 | return; | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | |||
432 | // When the timer elapses, send the pending acks, trigger resends | ||
433 | // and report all the stats. | ||
434 | // | ||
435 | private void AckTimerElapsed(object sender, ElapsedEventArgs ea) | ||
436 | { | ||
437 | SendAcks(); | ||
438 | ResendUnacked(); | ||
439 | SendPacketStats(); | ||
440 | } | ||
441 | |||
442 | // Push out pachet counts for the sim status reporter | ||
443 | // | ||
444 | private void SendPacketStats() | ||
445 | { | ||
446 | PacketStats handlerPacketStats = OnPacketStats; | ||
447 | if (handlerPacketStats != null) | ||
448 | { | ||
449 | handlerPacketStats( | ||
450 | m_PacketsReceived - m_PacketsReceivedReported, | ||
451 | m_PacketsSent - m_PacketsSentReported, | ||
452 | m_UnackedBytes); | ||
453 | |||
454 | m_PacketsReceivedReported = m_PacketsReceived; | ||
455 | m_PacketsSentReported = m_PacketsSent; | ||
456 | } | ||
457 | } | ||
458 | |||
459 | // We can't keep an unlimited record of dupes. This will prune the | ||
460 | // dictionary by age. | ||
461 | // | ||
462 | // NOTE: this needs to be called from within lock | ||
463 | // (m_alreadySeenTracker) context! | ||
464 | private void ExpireSeenPackets() | ||
465 | { | ||
466 | if (m_alreadySeenList.Count < 1024) | ||
467 | return; | ||
468 | |||
469 | int ticks = 0; | ||
470 | int tc = Environment.TickCount & Int32.MaxValue; | ||
471 | if (tc >= m_lastAlreadySeenCheck) | ||
472 | ticks = tc - m_lastAlreadySeenCheck; | ||
473 | else | ||
474 | ticks = Int32.MaxValue - m_lastAlreadySeenCheck + tc; | ||
475 | |||
476 | if (ticks < 2000) return; | ||
477 | m_lastAlreadySeenCheck = tc; | ||
478 | |||
479 | // we calculate the drop dead tick count here instead of | ||
480 | // in the loop: any packet with a timestamp before | ||
481 | // dropDeadTC can be expired | ||
482 | int dropDeadTC = tc - m_alreadySeenWindow; | ||
483 | int i = 0; | ||
484 | while (i < m_alreadySeenList.Count && m_alreadySeenTracker[m_alreadySeenList[i]] < dropDeadTC) | ||
485 | { | ||
486 | m_alreadySeenTracker.Remove(m_alreadySeenList[i]); | ||
487 | i++; | ||
488 | } | ||
489 | // if we dropped packet from m_alreadySeenTracker we need | ||
490 | // to drop them from m_alreadySeenList as well, let's do | ||
491 | // that in one go: the list is ordered after all. | ||
492 | if (i > 0) | ||
493 | { | ||
494 | m_alreadySeenList.RemoveRange(0, i); | ||
495 | // m_log.DebugFormat("[CLIENT]: expired {0} packets, {1}:{2} left", i, m_alreadySeenList.Count, m_alreadySeenTracker.Count); | ||
496 | } | ||
497 | } | ||
498 | |||
499 | public void InPacket(Packet packet) | ||
500 | { | ||
501 | if (packet == null) | ||
502 | return; | ||
503 | |||
504 | // When too many acks are needed to be sent, the client sends | ||
505 | // a packet consisting of acks only | ||
506 | // | ||
507 | if (packet.Type == PacketType.PacketAck) | ||
508 | { | ||
509 | PacketAckPacket ackPacket = (PacketAckPacket)packet; | ||
510 | |||
511 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
512 | { | ||
513 | ProcessAck(block.ID); | ||
514 | } | ||
515 | |||
516 | PacketPool.Instance.ReturnPacket(packet); | ||
517 | return; | ||
518 | } | ||
519 | |||
520 | // Any packet can have some packet acks in the header. | ||
521 | // Process them here | ||
522 | // | ||
523 | if (packet.Header.AppendedAcks) | ||
524 | { | ||
525 | foreach (uint id in packet.Header.AckList) | ||
526 | { | ||
527 | ProcessAck(id); | ||
528 | } | ||
529 | } | ||
530 | |||
531 | // If this client is on another partial instance, no need | ||
532 | // to handle packets | ||
533 | // | ||
534 | if (!m_Client.IsActive && packet.Type != PacketType.LogoutRequest) | ||
535 | { | ||
536 | PacketPool.Instance.ReturnPacket(packet); | ||
537 | return; | ||
538 | } | ||
539 | |||
540 | if (packet.Type == PacketType.StartPingCheck) | ||
541 | { | ||
542 | StartPingCheckPacket startPing = (StartPingCheckPacket)packet; | ||
543 | CompletePingCheckPacket endPing | ||
544 | = (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck); | ||
545 | |||
546 | endPing.PingID.PingID = startPing.PingID.PingID; | ||
547 | OutPacket(endPing, ThrottleOutPacketType.Task); | ||
548 | } | ||
549 | else | ||
550 | { | ||
551 | LLQueItem item = new LLQueItem(); | ||
552 | item.Packet = packet; | ||
553 | item.Incoming = true; | ||
554 | m_PacketQueue.Enqueue(item); | ||
555 | } | ||
556 | } | ||
557 | |||
558 | public void ProcessInPacket(LLQueItem item) | ||
559 | { | ||
560 | Packet packet = item.Packet; | ||
561 | |||
562 | // Always ack the packet! | ||
563 | // | ||
564 | if (packet.Header.Reliable) | ||
565 | AckPacket(packet); | ||
566 | |||
567 | if (packet.Type != PacketType.AgentUpdate) | ||
568 | m_PacketsReceived++; | ||
569 | |||
570 | // Check for duplicate packets.. packets that the client is | ||
571 | // resending because it didn't receive our ack | ||
572 | // | ||
573 | lock (m_alreadySeenTracker) | ||
574 | { | ||
575 | ExpireSeenPackets(); | ||
576 | |||
577 | if (m_alreadySeenTracker.ContainsKey(packet.Header.Sequence)) | ||
578 | return; | ||
579 | |||
580 | m_alreadySeenTracker.Add(packet.Header.Sequence, Environment.TickCount & Int32.MaxValue); | ||
581 | m_alreadySeenList.Add(packet.Header.Sequence); | ||
582 | } | ||
583 | |||
584 | m_Client.ProcessInPacket(packet); | ||
585 | } | ||
586 | |||
587 | public void Flush() | ||
588 | { | ||
589 | m_PacketQueue.Flush(); | ||
590 | m_UnackedBytes = (-1 * m_UnackedBytes); | ||
591 | SendPacketStats(); | ||
592 | } | ||
593 | |||
594 | public void Clear() | ||
595 | { | ||
596 | m_UnackedBytes = (-1 * m_UnackedBytes); | ||
597 | SendPacketStats(); | ||
598 | lock (m_NeedAck) | ||
599 | { | ||
600 | m_NeedAck.Clear(); | ||
601 | m_PendingAcks.Clear(); | ||
602 | m_PendingAcksMap.Clear(); | ||
603 | } | ||
604 | m_Sequence += 1000000; | ||
605 | } | ||
606 | |||
607 | private void ProcessAck(uint id) | ||
608 | { | ||
609 | LLQueItem data; | ||
610 | |||
611 | lock (m_NeedAck) | ||
612 | { | ||
613 | //m_log.DebugFormat("[CLIENT]: In {0} received ack for packet {1}", m_Client.Scene.RegionInfo.ExternalEndPoint.Port, id); | ||
614 | |||
615 | if (!m_NeedAck.TryGetValue(id, out data)) | ||
616 | return; | ||
617 | |||
618 | m_NeedAck.Remove(id); | ||
619 | m_PacketQueue.Cancel(data.Sequence); | ||
620 | PacketPool.Instance.ReturnPacket(data.Packet); | ||
621 | m_UnackedBytes -= data.Length; | ||
622 | } | ||
623 | } | ||
624 | |||
625 | // Allocate packet sequence numbers in a threadsave manner | ||
626 | // | ||
627 | protected uint NextPacketSequenceNumber() | ||
628 | { | ||
629 | // Set the sequence number | ||
630 | uint seq = 1; | ||
631 | lock (m_SequenceLock) | ||
632 | { | ||
633 | if (m_Sequence >= MAX_SEQUENCE) | ||
634 | { | ||
635 | m_Sequence = 1; | ||
636 | } | ||
637 | else | ||
638 | { | ||
639 | m_Sequence++; | ||
640 | } | ||
641 | seq = m_Sequence; | ||
642 | } | ||
643 | return seq; | ||
644 | } | ||
645 | |||
646 | public ClientInfo GetClientInfo() | ||
647 | { | ||
648 | ClientInfo info = new ClientInfo(); | ||
649 | |||
650 | info.pendingAcks = m_PendingAcksMap; | ||
651 | info.needAck = new Dictionary<uint, byte[]>(); | ||
652 | |||
653 | lock (m_NeedAck) | ||
654 | { | ||
655 | foreach (uint key in m_NeedAck.Keys) | ||
656 | info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes()); | ||
657 | } | ||
658 | |||
659 | LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); | ||
660 | |||
661 | for (int i = 0; i < queitems.Length; i++) | ||
662 | { | ||
663 | if (queitems[i].Incoming == false) | ||
664 | info.out_packets.Add(queitems[i].Packet.ToBytes()); | ||
665 | } | ||
666 | |||
667 | info.sequence = m_Sequence; | ||
668 | |||
669 | float multiplier = m_PacketQueue.ThrottleMultiplier; | ||
670 | info.resendThrottle = (int) (m_PacketQueue.ResendThrottle.Throttle / multiplier); | ||
671 | info.landThrottle = (int) (m_PacketQueue.LandThrottle.Throttle / multiplier); | ||
672 | info.windThrottle = (int) (m_PacketQueue.WindThrottle.Throttle / multiplier); | ||
673 | info.cloudThrottle = (int) (m_PacketQueue.CloudThrottle.Throttle / multiplier); | ||
674 | info.taskThrottle = (int) (m_PacketQueue.TaskThrottle.Throttle / multiplier); | ||
675 | info.assetThrottle = (int) (m_PacketQueue.AssetThrottle.Throttle / multiplier); | ||
676 | info.textureThrottle = (int) (m_PacketQueue.TextureThrottle.Throttle / multiplier); | ||
677 | info.totalThrottle = (int) (m_PacketQueue.TotalThrottle.Throttle / multiplier); | ||
678 | |||
679 | return info; | ||
680 | } | ||
681 | |||
682 | public void SetClientInfo(ClientInfo info) | ||
683 | { | ||
684 | m_PendingAcksMap = info.pendingAcks; | ||
685 | m_PendingAcks = new List<uint>(m_PendingAcksMap.Keys); | ||
686 | m_NeedAck = new Dictionary<uint, LLQueItem>(); | ||
687 | |||
688 | Packet packet = null; | ||
689 | int packetEnd = 0; | ||
690 | byte[] zero = new byte[3000]; | ||
691 | |||
692 | foreach (uint key in info.needAck.Keys) | ||
693 | { | ||
694 | byte[] buff = info.needAck[key]; | ||
695 | packetEnd = buff.Length - 1; | ||
696 | |||
697 | try | ||
698 | { | ||
699 | packet = PacketPool.Instance.GetPacket(buff, ref packetEnd, zero); | ||
700 | } | ||
701 | catch (Exception) | ||
702 | { | ||
703 | } | ||
704 | |||
705 | LLQueItem item = new LLQueItem(); | ||
706 | item.Packet = packet; | ||
707 | item.Incoming = false; | ||
708 | item.throttleType = 0; | ||
709 | item.TickCount = Environment.TickCount; | ||
710 | item.Identifier = 0; | ||
711 | item.Resends = 0; | ||
712 | item.Length = packet.Length; | ||
713 | item.Sequence = packet.Header.Sequence; | ||
714 | m_NeedAck.Add(key, item); | ||
715 | } | ||
716 | |||
717 | m_Sequence = info.sequence; | ||
718 | |||
719 | m_PacketQueue.ResendThrottle.Throttle = info.resendThrottle; | ||
720 | m_PacketQueue.LandThrottle.Throttle = info.landThrottle; | ||
721 | m_PacketQueue.WindThrottle.Throttle = info.windThrottle; | ||
722 | m_PacketQueue.CloudThrottle.Throttle = info.cloudThrottle; | ||
723 | m_PacketQueue.TaskThrottle.Throttle = info.taskThrottle; | ||
724 | m_PacketQueue.AssetThrottle.Throttle = info.assetThrottle; | ||
725 | m_PacketQueue.TextureThrottle.Throttle = info.textureThrottle; | ||
726 | m_PacketQueue.TotalThrottle.Throttle = info.totalThrottle; | ||
727 | } | ||
728 | |||
729 | public void AddImportantPacket(PacketType type) | ||
730 | { | ||
731 | if (m_ImportantPackets.Contains(type)) | ||
732 | return; | ||
733 | |||
734 | m_ImportantPackets.Add(type); | ||
735 | } | ||
736 | |||
737 | public void RemoveImportantPacket(PacketType type) | ||
738 | { | ||
739 | if (!m_ImportantPackets.Contains(type)) | ||
740 | return; | ||
741 | |||
742 | m_ImportantPackets.Remove(type); | ||
743 | } | ||
744 | |||
745 | private void DropResend(Object id) | ||
746 | { | ||
747 | LLQueItem d = null; | ||
748 | |||
749 | foreach (LLQueItem data in m_NeedAck.Values) | ||
750 | { | ||
751 | if (data.Identifier != null && data.Identifier == id) | ||
752 | { | ||
753 | d = data; | ||
754 | break; | ||
755 | } | ||
756 | } | ||
757 | |||
758 | if (null == d) return; | ||
759 | |||
760 | m_NeedAck.Remove(d.Packet.Header.Sequence); | ||
761 | m_PacketQueue.Cancel(d.Sequence); | ||
762 | PacketPool.Instance.ReturnPacket(d.Packet); | ||
763 | } | ||
764 | |||
765 | private void TriggerOnPacketDrop(Packet packet, Object id) | ||
766 | { | ||
767 | PacketDrop handlerPacketDrop = OnPacketDrop; | ||
768 | |||
769 | if (handlerPacketDrop == null) | ||
770 | return; | ||
771 | |||
772 | handlerPacketDrop(packet, id); | ||
773 | } | ||
774 | |||
775 | private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) | ||
776 | { | ||
777 | QueueEmpty handlerQueueEmpty = OnQueueEmpty; | ||
778 | |||
779 | if (handlerQueueEmpty != null) | ||
780 | handlerQueueEmpty(queue); | ||
781 | } | ||
782 | |||
783 | // Convert the packet to bytes and stuff it onto the send queue | ||
784 | // | ||
785 | public void ProcessOutPacket(LLQueItem item) | ||
786 | { | ||
787 | Packet packet = item.Packet; | ||
788 | |||
789 | // Assign sequence number here to prevent out of order packets | ||
790 | if (packet.Header.Sequence == 0) | ||
791 | { | ||
792 | lock (m_NeedAck) | ||
793 | { | ||
794 | packet.Header.Sequence = NextPacketSequenceNumber(); | ||
795 | item.Sequence = packet.Header.Sequence; | ||
796 | item.TickCount = Environment.TickCount; | ||
797 | |||
798 | // We want to see that packet arrive if it's reliable | ||
799 | if (packet.Header.Reliable) | ||
800 | { | ||
801 | m_UnackedBytes += item.Length; | ||
802 | |||
803 | // Keep track of when this packet was sent out | ||
804 | item.TickCount = Environment.TickCount; | ||
805 | |||
806 | m_NeedAck[packet.Header.Sequence] = item; | ||
807 | } | ||
808 | } | ||
809 | } | ||
810 | |||
811 | // If we sent a killpacket | ||
812 | if (packet is KillPacket) | ||
813 | Abort(); | ||
814 | |||
815 | try | ||
816 | { | ||
817 | // If this packet has been reused/returned, the ToBytes | ||
818 | // will blow up in our face. | ||
819 | // Fail gracefully. | ||
820 | // | ||
821 | |||
822 | // Actually make the byte array and send it | ||
823 | byte[] sendbuffer = item.Packet.ToBytes(); | ||
824 | |||
825 | if (packet.Header.Zerocoded) | ||
826 | { | ||
827 | int packetsize = Helpers.ZeroEncode(sendbuffer, | ||
828 | sendbuffer.Length, m_ZeroOutBuffer); | ||
829 | m_PacketServer.SendPacketTo(m_ZeroOutBuffer, packetsize, | ||
830 | SocketFlags.None, m_Client.CircuitCode); | ||
831 | } | ||
832 | else | ||
833 | { | ||
834 | // Need some extra space in case we need to add proxy | ||
835 | // information to the message later | ||
836 | Buffer.BlockCopy(sendbuffer, 0, m_ZeroOutBuffer, 0, | ||
837 | sendbuffer.Length); | ||
838 | m_PacketServer.SendPacketTo(m_ZeroOutBuffer, | ||
839 | sendbuffer.Length, SocketFlags.None, m_Client.CircuitCode); | ||
840 | } | ||
841 | } | ||
842 | catch (NullReferenceException) | ||
843 | { | ||
844 | m_log.Error("[PACKET]: Detected reuse of a returned packet"); | ||
845 | m_PacketQueue.Cancel(item.Sequence); | ||
846 | return; | ||
847 | } | ||
848 | |||
849 | // If this is a reliable packet, we are still holding a ref | ||
850 | // Dont't return in that case | ||
851 | // | ||
852 | if (!packet.Header.Reliable) | ||
853 | { | ||
854 | m_PacketQueue.Cancel(item.Sequence); | ||
855 | PacketPool.Instance.ReturnPacket(packet); | ||
856 | } | ||
857 | } | ||
858 | |||
859 | private void Abort() | ||
860 | { | ||
861 | m_PacketQueue.Close(); | ||
862 | Thread.CurrentThread.Abort(); | ||
863 | } | ||
864 | |||
865 | public int GetQueueCount(ThrottleOutPacketType queue) | ||
866 | { | ||
867 | return m_PacketQueue.GetQueueCount(queue); | ||
868 | } | ||
869 | } | ||
870 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs deleted file mode 100644 index 3eed2e0..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ /dev/null | |||
@@ -1,742 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using System.Timers; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Statistics; | ||
37 | using OpenSim.Framework.Statistics.Interfaces; | ||
38 | using Timer=System.Timers.Timer; | ||
39 | |||
40 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
41 | { | ||
42 | public class LLPacketQueue : IPullStatsProvider, IDisposable | ||
43 | { | ||
44 | private static readonly ILog m_log | ||
45 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | /// <summary> | ||
48 | /// Is queueing enabled at all? | ||
49 | /// </summary> | ||
50 | private bool m_enabled = true; | ||
51 | |||
52 | private OpenSim.Framework.BlockingQueue<LLQueItem> SendQueue; | ||
53 | |||
54 | private Queue<LLQueItem> IncomingPacketQueue; | ||
55 | private Queue<LLQueItem> OutgoingPacketQueue; | ||
56 | private Queue<LLQueItem> ResendOutgoingPacketQueue; | ||
57 | private Queue<LLQueItem> LandOutgoingPacketQueue; | ||
58 | private Queue<LLQueItem> WindOutgoingPacketQueue; | ||
59 | private Queue<LLQueItem> CloudOutgoingPacketQueue; | ||
60 | private Queue<LLQueItem> TaskOutgoingPacketQueue; | ||
61 | private Queue<LLQueItem> TaskLowpriorityPacketQueue; | ||
62 | private Queue<LLQueItem> TextureOutgoingPacketQueue; | ||
63 | private Queue<LLQueItem> AssetOutgoingPacketQueue; | ||
64 | |||
65 | private List<ThrottleOutPacketType> Empty = new List<ThrottleOutPacketType>(); | ||
66 | // m_log.Info("[THROTTLE]: Entering Throttle"); | ||
67 | // private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
68 | // private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
69 | |||
70 | // All throttle times and number of bytes are calculated by dividing by this value | ||
71 | // This value also determines how many times per throttletimems the timer will run | ||
72 | // If throttleimems is 1000 ms, then the timer will fire every 1000/7 milliseconds | ||
73 | |||
74 | private float throttleMultiplier = 2.0f; // Default value really doesn't matter. | ||
75 | private int throttleTimeDivisor = 7; | ||
76 | |||
77 | private int throttletimems = 1000; | ||
78 | |||
79 | internal LLPacketThrottle ResendThrottle; | ||
80 | internal LLPacketThrottle LandThrottle; | ||
81 | internal LLPacketThrottle WindThrottle; | ||
82 | internal LLPacketThrottle CloudThrottle; | ||
83 | internal LLPacketThrottle TaskThrottle; | ||
84 | internal LLPacketThrottle AssetThrottle; | ||
85 | internal LLPacketThrottle TextureThrottle; | ||
86 | internal LLPacketThrottle TotalThrottle; | ||
87 | |||
88 | private Dictionary<uint,int> contents = new Dictionary<uint, int>(); | ||
89 | |||
90 | // private long LastThrottle; | ||
91 | // private long ThrottleInterval; | ||
92 | private Timer throttleTimer; | ||
93 | |||
94 | private UUID m_agentId; | ||
95 | |||
96 | public event QueueEmpty OnQueueEmpty; | ||
97 | |||
98 | public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings) | ||
99 | { | ||
100 | // While working on this, the BlockingQueue had me fooled for a bit. | ||
101 | // The Blocking queue causes the thread to stop until there's something | ||
102 | // in it to process. it's an on-purpose threadlock though because | ||
103 | // without it, the clientloop will suck up all sim resources. | ||
104 | |||
105 | SendQueue = new OpenSim.Framework.BlockingQueue<LLQueItem>(); | ||
106 | |||
107 | IncomingPacketQueue = new Queue<LLQueItem>(); | ||
108 | OutgoingPacketQueue = new Queue<LLQueItem>(); | ||
109 | ResendOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
110 | LandOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
111 | WindOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
112 | CloudOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
113 | TaskOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
114 | TaskLowpriorityPacketQueue = new Queue<LLQueItem>(); | ||
115 | TextureOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
116 | AssetOutgoingPacketQueue = new Queue<LLQueItem>(); | ||
117 | |||
118 | // Store the throttle multiplier for posterity. | ||
119 | throttleMultiplier = userSettings.ClientThrottleMultipler; | ||
120 | |||
121 | |||
122 | int throttleMaxBPS = 1500000; | ||
123 | if (userSettings.TotalThrottleSettings != null) | ||
124 | throttleMaxBPS = userSettings.TotalThrottleSettings.Max; | ||
125 | |||
126 | // Set up the throttle classes (min, max, current) in bits per second | ||
127 | ResendThrottle = new LLPacketThrottle(5000, throttleMaxBPS / 15, 16000, userSettings.ClientThrottleMultipler); | ||
128 | LandThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 15, 2000, userSettings.ClientThrottleMultipler); | ||
129 | WindThrottle = new LLPacketThrottle(0, throttleMaxBPS / 15, 0, userSettings.ClientThrottleMultipler); | ||
130 | CloudThrottle = new LLPacketThrottle(0, throttleMaxBPS / 15, 0, userSettings.ClientThrottleMultipler); | ||
131 | TaskThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 3000, userSettings.ClientThrottleMultipler); | ||
132 | AssetThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 1000, userSettings.ClientThrottleMultipler); | ||
133 | TextureThrottle = new LLPacketThrottle(1000, throttleMaxBPS / 2, 4000, userSettings.ClientThrottleMultipler); | ||
134 | |||
135 | |||
136 | // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second. | ||
137 | |||
138 | |||
139 | ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings; | ||
140 | if (null == totalThrottleSettings) | ||
141 | { | ||
142 | totalThrottleSettings = new ThrottleSettings(0, throttleMaxBPS, 28000); | ||
143 | } | ||
144 | |||
145 | TotalThrottle | ||
146 | = new LLPacketThrottle( | ||
147 | totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current, | ||
148 | userSettings.ClientThrottleMultipler); | ||
149 | |||
150 | throttleTimer = new Timer((int)(throttletimems / throttleTimeDivisor)); | ||
151 | throttleTimer.Elapsed += ThrottleTimerElapsed; | ||
152 | throttleTimer.Start(); | ||
153 | |||
154 | // TIMERS needed for this | ||
155 | // LastThrottle = DateTime.Now.Ticks; | ||
156 | // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); | ||
157 | |||
158 | m_agentId = agentId; | ||
159 | |||
160 | if (StatsManager.SimExtraStats != null) | ||
161 | { | ||
162 | StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(m_agentId, this); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /* STANDARD QUEUE MANIPULATION INTERFACES */ | ||
167 | |||
168 | public void Enqueue(LLQueItem item) | ||
169 | { | ||
170 | if (!m_enabled) | ||
171 | { | ||
172 | return; | ||
173 | } | ||
174 | // We could micro lock, but that will tend to actually | ||
175 | // probably be worse than just synchronizing on SendQueue | ||
176 | |||
177 | if (item == null) | ||
178 | { | ||
179 | SendQueue.Enqueue(item); | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | if (item.Incoming) | ||
184 | { | ||
185 | SendQueue.PriorityEnqueue(item); | ||
186 | return; | ||
187 | } | ||
188 | |||
189 | if (item.Sequence != 0) | ||
190 | lock (contents) | ||
191 | { | ||
192 | if (contents.ContainsKey(item.Sequence)) | ||
193 | contents[item.Sequence] += 1; | ||
194 | else | ||
195 | contents.Add(item.Sequence, 1); | ||
196 | } | ||
197 | |||
198 | lock (this) | ||
199 | { | ||
200 | switch (item.throttleType & ThrottleOutPacketType.TypeMask) | ||
201 | { | ||
202 | case ThrottleOutPacketType.Resend: | ||
203 | ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item, ThrottleOutPacketType.Resend); | ||
204 | break; | ||
205 | case ThrottleOutPacketType.Texture: | ||
206 | ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item, ThrottleOutPacketType.Texture); | ||
207 | break; | ||
208 | case ThrottleOutPacketType.Task: | ||
209 | if ((item.throttleType & ThrottleOutPacketType.LowPriority) != 0) | ||
210 | ThrottleCheck(ref TaskThrottle, ref TaskLowpriorityPacketQueue, item, ThrottleOutPacketType.Task); | ||
211 | else | ||
212 | ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item, ThrottleOutPacketType.Task); | ||
213 | break; | ||
214 | case ThrottleOutPacketType.Land: | ||
215 | ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item, ThrottleOutPacketType.Land); | ||
216 | break; | ||
217 | case ThrottleOutPacketType.Asset: | ||
218 | ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item, ThrottleOutPacketType.Asset); | ||
219 | break; | ||
220 | case ThrottleOutPacketType.Cloud: | ||
221 | ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item, ThrottleOutPacketType.Cloud); | ||
222 | break; | ||
223 | case ThrottleOutPacketType.Wind: | ||
224 | ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item, ThrottleOutPacketType.Wind); | ||
225 | break; | ||
226 | |||
227 | default: | ||
228 | // Acknowledgements and other such stuff should go directly to the blocking Queue | ||
229 | // Throttling them may and likely 'will' be problematic | ||
230 | SendQueue.PriorityEnqueue(item); | ||
231 | break; | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | public LLQueItem Dequeue() | ||
237 | { | ||
238 | while (true) | ||
239 | { | ||
240 | LLQueItem item = SendQueue.Dequeue(); | ||
241 | if (item == null) | ||
242 | return null; | ||
243 | if (item.Incoming) | ||
244 | return item; | ||
245 | item.TickCount = System.Environment.TickCount; | ||
246 | if (item.Sequence == 0) | ||
247 | return item; | ||
248 | lock (contents) | ||
249 | { | ||
250 | if (contents.ContainsKey(item.Sequence)) | ||
251 | { | ||
252 | if (contents[item.Sequence] == 1) | ||
253 | contents.Remove(item.Sequence); | ||
254 | else | ||
255 | contents[item.Sequence] -= 1; | ||
256 | return item; | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | |||
262 | public void Cancel(uint sequence) | ||
263 | { | ||
264 | lock (contents) contents.Remove(sequence); | ||
265 | } | ||
266 | |||
267 | public bool Contains(uint sequence) | ||
268 | { | ||
269 | lock (contents) return contents.ContainsKey(sequence); | ||
270 | } | ||
271 | |||
272 | public void Flush() | ||
273 | { | ||
274 | lock (this) | ||
275 | { | ||
276 | // These categories do not contain transactional packets so we can safely drop any pending data in them | ||
277 | LandOutgoingPacketQueue.Clear(); | ||
278 | WindOutgoingPacketQueue.Clear(); | ||
279 | CloudOutgoingPacketQueue.Clear(); | ||
280 | TextureOutgoingPacketQueue.Clear(); | ||
281 | AssetOutgoingPacketQueue.Clear(); | ||
282 | |||
283 | // Now comes the fun part.. we dump all remaining resend and task packets into the send queue | ||
284 | while (ResendOutgoingPacketQueue.Count > 0 || TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) | ||
285 | { | ||
286 | if (ResendOutgoingPacketQueue.Count > 0) | ||
287 | SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue()); | ||
288 | |||
289 | if (TaskOutgoingPacketQueue.Count > 0) | ||
290 | SendQueue.PriorityEnqueue(TaskOutgoingPacketQueue.Dequeue()); | ||
291 | |||
292 | if (TaskLowpriorityPacketQueue.Count > 0) | ||
293 | SendQueue.Enqueue(TaskLowpriorityPacketQueue.Dequeue()); | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | |||
298 | public void WipeClean() | ||
299 | { | ||
300 | lock (this) | ||
301 | { | ||
302 | ResendOutgoingPacketQueue.Clear(); | ||
303 | LandOutgoingPacketQueue.Clear(); | ||
304 | WindOutgoingPacketQueue.Clear(); | ||
305 | CloudOutgoingPacketQueue.Clear(); | ||
306 | TaskOutgoingPacketQueue.Clear(); | ||
307 | TaskLowpriorityPacketQueue.Clear(); | ||
308 | TextureOutgoingPacketQueue.Clear(); | ||
309 | AssetOutgoingPacketQueue.Clear(); | ||
310 | SendQueue.Clear(); | ||
311 | lock (contents) contents.Clear(); | ||
312 | } | ||
313 | } | ||
314 | |||
315 | public void Close() | ||
316 | { | ||
317 | Dispose(); | ||
318 | } | ||
319 | |||
320 | public void Dispose() | ||
321 | { | ||
322 | Flush(); | ||
323 | WipeClean(); // I'm sure there's a dirty joke in here somewhere. -AFrisby | ||
324 | |||
325 | m_enabled = false; | ||
326 | throttleTimer.Stop(); | ||
327 | throttleTimer.Close(); | ||
328 | |||
329 | if (StatsManager.SimExtraStats != null) | ||
330 | { | ||
331 | StatsManager.SimExtraStats.DeregisterPacketQueueStatsProvider(m_agentId); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | private void ResetCounters() | ||
336 | { | ||
337 | ResendThrottle.Reset(); | ||
338 | LandThrottle.Reset(); | ||
339 | WindThrottle.Reset(); | ||
340 | CloudThrottle.Reset(); | ||
341 | TaskThrottle.Reset(); | ||
342 | AssetThrottle.Reset(); | ||
343 | TextureThrottle.Reset(); | ||
344 | TotalThrottle.Reset(); | ||
345 | } | ||
346 | |||
347 | private bool PacketsWaiting() | ||
348 | { | ||
349 | return (ResendOutgoingPacketQueue.Count > 0 || | ||
350 | LandOutgoingPacketQueue.Count > 0 || | ||
351 | WindOutgoingPacketQueue.Count > 0 || | ||
352 | CloudOutgoingPacketQueue.Count > 0 || | ||
353 | TaskOutgoingPacketQueue.Count > 0 || | ||
354 | TaskLowpriorityPacketQueue.Count > 0 || | ||
355 | AssetOutgoingPacketQueue.Count > 0 || | ||
356 | TextureOutgoingPacketQueue.Count > 0); | ||
357 | } | ||
358 | |||
359 | public void ProcessThrottle() | ||
360 | { | ||
361 | // I was considering this.. Will an event fire if the thread it's on is blocked? | ||
362 | |||
363 | // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long | ||
364 | // The General overhead of the UDP protocol gets sent to the queue un-throttled by this | ||
365 | // so This'll pick up about around the right time. | ||
366 | |||
367 | int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. | ||
368 | int throttleLoops = 0; | ||
369 | List<ThrottleOutPacketType> e; | ||
370 | |||
371 | // We're going to dequeue all of the saved up packets until | ||
372 | // we've hit the throttle limit or there's no more packets to send | ||
373 | lock (this) | ||
374 | { | ||
375 | // this variable will be true if there was work done in the last execution of the | ||
376 | // loop, since each pass through the loop checks the queue length, we no longer | ||
377 | // need the check on entering the loop | ||
378 | bool qchanged = true; | ||
379 | |||
380 | ResetCounters(); | ||
381 | |||
382 | while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) | ||
383 | { | ||
384 | qchanged = false; // We will break out of the loop if no work was accomplished | ||
385 | |||
386 | throttleLoops++; | ||
387 | //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. | ||
388 | if ((ResendOutgoingPacketQueue.Count > 0) && ResendThrottle.UnderLimit()) | ||
389 | { | ||
390 | LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue(); | ||
391 | |||
392 | SendQueue.Enqueue(qpack); | ||
393 | TotalThrottle.AddBytes(qpack.Length); | ||
394 | ResendThrottle.AddBytes(qpack.Length); | ||
395 | |||
396 | qchanged = true; | ||
397 | } | ||
398 | |||
399 | if ((LandOutgoingPacketQueue.Count > 0) && LandThrottle.UnderLimit()) | ||
400 | { | ||
401 | LLQueItem qpack = LandOutgoingPacketQueue.Dequeue(); | ||
402 | |||
403 | SendQueue.Enqueue(qpack); | ||
404 | TotalThrottle.AddBytes(qpack.Length); | ||
405 | LandThrottle.AddBytes(qpack.Length); | ||
406 | qchanged = true; | ||
407 | |||
408 | if (LandOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Land)) | ||
409 | Empty.Add(ThrottleOutPacketType.Land); | ||
410 | } | ||
411 | |||
412 | if ((WindOutgoingPacketQueue.Count > 0) && WindThrottle.UnderLimit()) | ||
413 | { | ||
414 | LLQueItem qpack = WindOutgoingPacketQueue.Dequeue(); | ||
415 | |||
416 | SendQueue.Enqueue(qpack); | ||
417 | TotalThrottle.AddBytes(qpack.Length); | ||
418 | WindThrottle.AddBytes(qpack.Length); | ||
419 | qchanged = true; | ||
420 | |||
421 | if (WindOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Wind)) | ||
422 | Empty.Add(ThrottleOutPacketType.Wind); | ||
423 | } | ||
424 | |||
425 | if ((CloudOutgoingPacketQueue.Count > 0) && CloudThrottle.UnderLimit()) | ||
426 | { | ||
427 | LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue(); | ||
428 | |||
429 | SendQueue.Enqueue(qpack); | ||
430 | TotalThrottle.AddBytes(qpack.Length); | ||
431 | CloudThrottle.AddBytes(qpack.Length); | ||
432 | qchanged = true; | ||
433 | |||
434 | if (CloudOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Cloud)) | ||
435 | Empty.Add(ThrottleOutPacketType.Cloud); | ||
436 | } | ||
437 | |||
438 | if ((TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) && TaskThrottle.UnderLimit()) | ||
439 | { | ||
440 | LLQueItem qpack; | ||
441 | if (TaskOutgoingPacketQueue.Count > 0) | ||
442 | { | ||
443 | qpack = TaskOutgoingPacketQueue.Dequeue(); | ||
444 | SendQueue.PriorityEnqueue(qpack); | ||
445 | } | ||
446 | else | ||
447 | { | ||
448 | qpack = TaskLowpriorityPacketQueue.Dequeue(); | ||
449 | SendQueue.Enqueue(qpack); | ||
450 | } | ||
451 | |||
452 | TotalThrottle.AddBytes(qpack.Length); | ||
453 | TaskThrottle.AddBytes(qpack.Length); | ||
454 | qchanged = true; | ||
455 | |||
456 | if (TaskOutgoingPacketQueue.Count == 0 && TaskLowpriorityPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Task)) | ||
457 | Empty.Add(ThrottleOutPacketType.Task); | ||
458 | } | ||
459 | |||
460 | if ((TextureOutgoingPacketQueue.Count > 0) && TextureThrottle.UnderLimit()) | ||
461 | { | ||
462 | LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue(); | ||
463 | |||
464 | SendQueue.Enqueue(qpack); | ||
465 | TotalThrottle.AddBytes(qpack.Length); | ||
466 | TextureThrottle.AddBytes(qpack.Length); | ||
467 | qchanged = true; | ||
468 | |||
469 | if (TextureOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Texture)) | ||
470 | Empty.Add(ThrottleOutPacketType.Texture); | ||
471 | } | ||
472 | |||
473 | if ((AssetOutgoingPacketQueue.Count > 0) && AssetThrottle.UnderLimit()) | ||
474 | { | ||
475 | LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue(); | ||
476 | |||
477 | SendQueue.Enqueue(qpack); | ||
478 | TotalThrottle.AddBytes(qpack.Length); | ||
479 | AssetThrottle.AddBytes(qpack.Length); | ||
480 | qchanged = true; | ||
481 | |||
482 | if (AssetOutgoingPacketQueue.Count == 0 && !Empty.Contains(ThrottleOutPacketType.Asset)) | ||
483 | Empty.Add(ThrottleOutPacketType.Asset); | ||
484 | } | ||
485 | } | ||
486 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); | ||
487 | |||
488 | e = new List<ThrottleOutPacketType>(Empty); | ||
489 | Empty.Clear(); | ||
490 | } | ||
491 | |||
492 | foreach (ThrottleOutPacketType t in e) | ||
493 | { | ||
494 | if (GetQueueCount(t) == 0) | ||
495 | TriggerOnQueueEmpty(t); | ||
496 | } | ||
497 | } | ||
498 | |||
499 | private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) | ||
500 | { | ||
501 | QueueEmpty handlerQueueEmpty = OnQueueEmpty; | ||
502 | |||
503 | if (handlerQueueEmpty != null) | ||
504 | handlerQueueEmpty(queue); | ||
505 | } | ||
506 | |||
507 | private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) | ||
508 | { | ||
509 | // just to change the signature, and that ProcessThrottle | ||
510 | // will be used elsewhere possibly | ||
511 | ProcessThrottle(); | ||
512 | } | ||
513 | |||
514 | private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue<LLQueItem> q, LLQueItem item, ThrottleOutPacketType itemType) | ||
515 | { | ||
516 | // The idea.. is if the packet throttle queues are empty | ||
517 | // and the client is under throttle for the type. Queue | ||
518 | // it up directly. This basically short cuts having to | ||
519 | // wait for the timer to fire to put things into the | ||
520 | // output queue | ||
521 | |||
522 | if ((q.Count == 0) && (throttle.UnderLimit())) | ||
523 | { | ||
524 | try | ||
525 | { | ||
526 | Monitor.Enter(this); | ||
527 | throttle.AddBytes(item.Length); | ||
528 | TotalThrottle.AddBytes(item.Length); | ||
529 | SendQueue.Enqueue(item); | ||
530 | lock (this) | ||
531 | { | ||
532 | if (!Empty.Contains(itemType)) | ||
533 | Empty.Add(itemType); | ||
534 | } | ||
535 | } | ||
536 | catch (Exception e) | ||
537 | { | ||
538 | // Probably a serialization exception | ||
539 | m_log.WarnFormat("ThrottleCheck: {0}", e.ToString()); | ||
540 | } | ||
541 | finally | ||
542 | { | ||
543 | Monitor.Pulse(this); | ||
544 | Monitor.Exit(this); | ||
545 | } | ||
546 | } | ||
547 | else | ||
548 | { | ||
549 | q.Enqueue(item); | ||
550 | } | ||
551 | } | ||
552 | |||
553 | private static int ScaleThrottle(int value, int curmax, int newmax) | ||
554 | { | ||
555 | return (int)((value / (float)curmax) * newmax); | ||
556 | } | ||
557 | |||
558 | public byte[] GetThrottlesPacked(float multiplier) | ||
559 | { | ||
560 | int singlefloat = 4; | ||
561 | float tResend = ResendThrottle.Throttle*multiplier; | ||
562 | float tLand = LandThrottle.Throttle*multiplier; | ||
563 | float tWind = WindThrottle.Throttle*multiplier; | ||
564 | float tCloud = CloudThrottle.Throttle*multiplier; | ||
565 | float tTask = TaskThrottle.Throttle*multiplier; | ||
566 | float tTexture = TextureThrottle.Throttle*multiplier; | ||
567 | float tAsset = AssetThrottle.Throttle*multiplier; | ||
568 | |||
569 | byte[] throttles = new byte[singlefloat*7]; | ||
570 | int i = 0; | ||
571 | Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat); | ||
572 | i++; | ||
573 | Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat); | ||
574 | i++; | ||
575 | Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat); | ||
576 | i++; | ||
577 | Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat); | ||
578 | i++; | ||
579 | Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat); | ||
580 | i++; | ||
581 | Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat); | ||
582 | i++; | ||
583 | Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat); | ||
584 | |||
585 | return throttles; | ||
586 | } | ||
587 | |||
588 | public void SetThrottleFromClient(byte[] throttle) | ||
589 | { | ||
590 | // From mantis http://opensimulator.org/mantis/view.php?id=1374 | ||
591 | // it appears that sometimes we are receiving empty throttle byte arrays. | ||
592 | // TODO: Investigate this behaviour | ||
593 | if (throttle.Length == 0) | ||
594 | { | ||
595 | m_log.Warn("[PACKET QUEUE]: SetThrottleFromClient unexpectedly received a throttle byte array containing no elements!"); | ||
596 | return; | ||
597 | } | ||
598 | |||
599 | int tResend = -1; | ||
600 | int tLand = -1; | ||
601 | int tWind = -1; | ||
602 | int tCloud = -1; | ||
603 | int tTask = -1; | ||
604 | int tTexture = -1; | ||
605 | int tAsset = -1; | ||
606 | int tall = -1; | ||
607 | int singlefloat = 4; | ||
608 | |||
609 | //Agent Throttle Block contains 7 single floatingpoint values. | ||
610 | int j = 0; | ||
611 | |||
612 | // Some Systems may be big endian... | ||
613 | // it might be smart to do this check more often... | ||
614 | if (!BitConverter.IsLittleEndian) | ||
615 | for (int i = 0; i < 7; i++) | ||
616 | Array.Reverse(throttle, j + i*singlefloat, singlefloat); | ||
617 | |||
618 | // values gotten from OpenMetaverse.org/wiki/Throttle. Thanks MW_ | ||
619 | // bytes | ||
620 | // Convert to integer, since.. the full fp space isn't used. | ||
621 | tResend = (int) BitConverter.ToSingle(throttle, j); | ||
622 | j += singlefloat; | ||
623 | tLand = (int) BitConverter.ToSingle(throttle, j); | ||
624 | j += singlefloat; | ||
625 | tWind = (int) BitConverter.ToSingle(throttle, j); | ||
626 | j += singlefloat; | ||
627 | tCloud = (int) BitConverter.ToSingle(throttle, j); | ||
628 | j += singlefloat; | ||
629 | tTask = (int) BitConverter.ToSingle(throttle, j); | ||
630 | j += singlefloat; | ||
631 | tTexture = (int) BitConverter.ToSingle(throttle, j); | ||
632 | j += singlefloat; | ||
633 | tAsset = (int) BitConverter.ToSingle(throttle, j); | ||
634 | |||
635 | tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; | ||
636 | |||
637 | /* | ||
638 | m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbits=" + tResend + | ||
639 | " landbits=" + tLand + | ||
640 | " windbits=" + tWind + | ||
641 | " cloudbits=" + tCloud + | ||
642 | " taskbits=" + tTask + | ||
643 | " texturebits=" + tTexture + | ||
644 | " Assetbits=" + tAsset + | ||
645 | " Allbits=" + tall); | ||
646 | */ | ||
647 | |||
648 | |||
649 | // Total Sanity | ||
650 | // Make sure that the client sent sane total values. | ||
651 | |||
652 | // If the client didn't send acceptable values.... | ||
653 | // Scale the clients values down until they are acceptable. | ||
654 | |||
655 | if (tall <= TotalThrottle.Max) | ||
656 | { | ||
657 | ResendThrottle.Throttle = tResend; | ||
658 | LandThrottle.Throttle = tLand; | ||
659 | WindThrottle.Throttle = tWind; | ||
660 | CloudThrottle.Throttle = tCloud; | ||
661 | TaskThrottle.Throttle = tTask; | ||
662 | TextureThrottle.Throttle = tTexture; | ||
663 | AssetThrottle.Throttle = tAsset; | ||
664 | TotalThrottle.Throttle = tall; | ||
665 | } | ||
666 | // else if (tall < 1) | ||
667 | // { | ||
668 | // // client is stupid, penalize him by minning everything | ||
669 | // ResendThrottle.Throttle = ResendThrottle.Min; | ||
670 | // LandThrottle.Throttle = LandThrottle.Min; | ||
671 | // WindThrottle.Throttle = WindThrottle.Min; | ||
672 | // CloudThrottle.Throttle = CloudThrottle.Min; | ||
673 | // TaskThrottle.Throttle = TaskThrottle.Min; | ||
674 | // TextureThrottle.Throttle = TextureThrottle.Min; | ||
675 | // AssetThrottle.Throttle = AssetThrottle.Min; | ||
676 | // TotalThrottle.Throttle = TotalThrottle.Min; | ||
677 | // } | ||
678 | else | ||
679 | { | ||
680 | // we're over so figure out percentages and use those | ||
681 | ResendThrottle.Throttle = tResend; | ||
682 | |||
683 | LandThrottle.Throttle = ScaleThrottle(tLand, tall, TotalThrottle.Max); | ||
684 | WindThrottle.Throttle = ScaleThrottle(tWind, tall, TotalThrottle.Max); | ||
685 | CloudThrottle.Throttle = ScaleThrottle(tCloud, tall, TotalThrottle.Max); | ||
686 | TaskThrottle.Throttle = ScaleThrottle(tTask, tall, TotalThrottle.Max); | ||
687 | TextureThrottle.Throttle = ScaleThrottle(tTexture, tall, TotalThrottle.Max); | ||
688 | AssetThrottle.Throttle = ScaleThrottle(tAsset, tall, TotalThrottle.Max); | ||
689 | TotalThrottle.Throttle = TotalThrottle.Max; | ||
690 | } | ||
691 | // effectively wiggling the slider causes things reset | ||
692 | // ResetCounters(); // DO NOT reset, better to send less for one period than more | ||
693 | } | ||
694 | |||
695 | // See IPullStatsProvider | ||
696 | public string GetStats() | ||
697 | { | ||
698 | return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}", | ||
699 | SendQueue.Count(), | ||
700 | IncomingPacketQueue.Count, | ||
701 | OutgoingPacketQueue.Count, | ||
702 | ResendOutgoingPacketQueue.Count, | ||
703 | LandOutgoingPacketQueue.Count, | ||
704 | WindOutgoingPacketQueue.Count, | ||
705 | CloudOutgoingPacketQueue.Count, | ||
706 | TaskOutgoingPacketQueue.Count, | ||
707 | TextureOutgoingPacketQueue.Count, | ||
708 | AssetOutgoingPacketQueue.Count); | ||
709 | } | ||
710 | |||
711 | public LLQueItem[] GetQueueArray() | ||
712 | { | ||
713 | return SendQueue.GetQueueArray(); | ||
714 | } | ||
715 | |||
716 | public float ThrottleMultiplier | ||
717 | { | ||
718 | get { return throttleMultiplier; } | ||
719 | } | ||
720 | |||
721 | public int GetQueueCount(ThrottleOutPacketType queue) | ||
722 | { | ||
723 | switch (queue) | ||
724 | { | ||
725 | case ThrottleOutPacketType.Land: | ||
726 | return LandOutgoingPacketQueue.Count; | ||
727 | case ThrottleOutPacketType.Wind: | ||
728 | return WindOutgoingPacketQueue.Count; | ||
729 | case ThrottleOutPacketType.Cloud: | ||
730 | return CloudOutgoingPacketQueue.Count; | ||
731 | case ThrottleOutPacketType.Task: | ||
732 | return TaskOutgoingPacketQueue.Count; | ||
733 | case ThrottleOutPacketType.Texture: | ||
734 | return TextureOutgoingPacketQueue.Count; | ||
735 | case ThrottleOutPacketType.Asset: | ||
736 | return AssetOutgoingPacketQueue.Count; | ||
737 | } | ||
738 | |||
739 | return 0; | ||
740 | } | ||
741 | } | ||
742 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs deleted file mode 100644 index 70d94e7..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs +++ /dev/null | |||
@@ -1,206 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Net; | ||
29 | using System.Net.Sockets; | ||
30 | using OpenMetaverse; | ||
31 | using OpenMetaverse.Packets; | ||
32 | using OpenSim.Framework; | ||
33 | |||
34 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// This class sets up new client stacks. It also handles the immediate distribution of incoming packets to | ||
38 | /// client stacks | ||
39 | /// </summary> | ||
40 | public class LLPacketServer | ||
41 | { | ||
42 | // private static readonly log4net.ILog m_log | ||
43 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | protected readonly ILLClientStackNetworkHandler m_networkHandler; | ||
46 | protected IScene m_scene; | ||
47 | |||
48 | /// <summary> | ||
49 | /// Tweakable user settings | ||
50 | /// </summary> | ||
51 | private ClientStackUserSettings m_userSettings; | ||
52 | |||
53 | public LLPacketServer(ILLClientStackNetworkHandler networkHandler, ClientStackUserSettings userSettings) | ||
54 | { | ||
55 | m_userSettings = userSettings; | ||
56 | m_networkHandler = networkHandler; | ||
57 | |||
58 | m_networkHandler.RegisterPacketServer(this); | ||
59 | } | ||
60 | |||
61 | public IScene LocalScene | ||
62 | { | ||
63 | set { m_scene = value; } | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// Process an incoming packet. | ||
68 | /// </summary> | ||
69 | /// <param name="circuitCode"></param> | ||
70 | /// <param name="packet"></param> | ||
71 | public virtual void InPacket(uint circuitCode, Packet packet) | ||
72 | { | ||
73 | m_scene.ClientManager.InPacket(circuitCode, packet); | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Create a new client circuit | ||
78 | /// </summary> | ||
79 | /// <param name="remoteEP"></param> | ||
80 | /// <param name="scene"></param> | ||
81 | /// <param name="assetCache"></param> | ||
82 | /// <param name="packServer"></param> | ||
83 | /// <param name="sessionInfo"></param> | ||
84 | /// <param name="agentId"></param> | ||
85 | /// <param name="sessionId"></param> | ||
86 | /// <param name="circuitCode"></param> | ||
87 | /// <param name="proxyEP"></param> | ||
88 | /// <returns></returns> | ||
89 | protected virtual IClientAPI CreateNewCircuit( | ||
90 | EndPoint remoteEP, IScene scene, | ||
91 | LLPacketServer packServer, AuthenticateResponse sessionInfo, | ||
92 | UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP) | ||
93 | { | ||
94 | return | ||
95 | new LLClientView( | ||
96 | remoteEP, scene, packServer, sessionInfo, agentId, sessionId, circuitCode, proxyEP, | ||
97 | m_userSettings); | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Check whether a given client is authorized to connect. | ||
102 | /// </summary> | ||
103 | /// <param name="useCircuit"></param> | ||
104 | /// <param name="circuitManager"></param> | ||
105 | /// <param name="sessionInfo"></param> | ||
106 | /// <returns></returns> | ||
107 | public virtual bool IsClientAuthorized( | ||
108 | UseCircuitCodePacket useCircuit, AgentCircuitManager circuitManager, out AuthenticateResponse sessionInfo) | ||
109 | { | ||
110 | UUID agentId = useCircuit.CircuitCode.ID; | ||
111 | UUID sessionId = useCircuit.CircuitCode.SessionID; | ||
112 | uint circuitCode = useCircuit.CircuitCode.Code; | ||
113 | |||
114 | sessionInfo = circuitManager.AuthenticateSession(sessionId, agentId, circuitCode); | ||
115 | |||
116 | if (!sessionInfo.Authorised) | ||
117 | return false; | ||
118 | |||
119 | return true; | ||
120 | } | ||
121 | |||
122 | /// <summary> | ||
123 | /// Add a new client circuit. We assume that is has already passed an authorization check | ||
124 | /// </summary> | ||
125 | /// <param name="epSender"></param> | ||
126 | /// <param name="useCircuit"></param> | ||
127 | /// <param name="assetCache"></param> | ||
128 | /// <param name="sessionInfo"></param> | ||
129 | /// <param name="proxyEP"></param> | ||
130 | /// <returns> | ||
131 | /// true if a new circuit was created, false if a circuit with the given circuit code already existed | ||
132 | /// </returns> | ||
133 | public virtual bool AddNewClient( | ||
134 | EndPoint epSender, UseCircuitCodePacket useCircuit, | ||
135 | AuthenticateResponse sessionInfo, EndPoint proxyEP) | ||
136 | { | ||
137 | IClientAPI newuser; | ||
138 | uint circuitCode = useCircuit.CircuitCode.Code; | ||
139 | |||
140 | if (m_scene.ClientManager.TryGetClient(circuitCode, out newuser)) | ||
141 | { | ||
142 | // The circuit is already known to the scene. This not actually a problem since this will currently | ||
143 | // occur if a client is crossing borders (hence upgrading its circuit). However, we shouldn't | ||
144 | // really by trying to add a new client if this is the case. | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | UUID agentId = useCircuit.CircuitCode.ID; | ||
149 | UUID sessionId = useCircuit.CircuitCode.SessionID; | ||
150 | |||
151 | newuser | ||
152 | = CreateNewCircuit( | ||
153 | epSender, m_scene, this, sessionInfo, agentId, sessionId, circuitCode, proxyEP); | ||
154 | |||
155 | m_scene.ClientManager.Add(circuitCode, newuser); | ||
156 | |||
157 | newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; | ||
158 | newuser.OnLogout += LogoutHandler; | ||
159 | newuser.OnConnectionClosed += CloseClient; | ||
160 | |||
161 | newuser.Start(); | ||
162 | |||
163 | return true; | ||
164 | } | ||
165 | |||
166 | public void LogoutHandler(IClientAPI client) | ||
167 | { | ||
168 | client.SendLogoutPacket(); | ||
169 | CloseClient(client); | ||
170 | } | ||
171 | |||
172 | /// <summary> | ||
173 | /// Send a packet to the given circuit | ||
174 | /// </summary> | ||
175 | /// <param name="buffer"></param> | ||
176 | /// <param name="size"></param> | ||
177 | /// <param name="flags"></param> | ||
178 | /// <param name="circuitcode"></param> | ||
179 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | ||
180 | { | ||
181 | m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode); | ||
182 | } | ||
183 | |||
184 | /// <summary> | ||
185 | /// Close a client circuit only | ||
186 | /// </summary> | ||
187 | /// <param name="circuitcode"></param> | ||
188 | public virtual void CloseCircuit(uint circuitcode) | ||
189 | { | ||
190 | m_networkHandler.RemoveClientCircuit(circuitcode); | ||
191 | } | ||
192 | |||
193 | /// <summary> | ||
194 | /// Completely close down the given client. | ||
195 | /// </summary> | ||
196 | /// <param name="client"></param> | ||
197 | public virtual void CloseClient(IClientAPI client) | ||
198 | { | ||
199 | //m_log.Info("PacketServer:CloseClient()"); | ||
200 | |||
201 | CloseCircuit(client.CircuitCode); | ||
202 | m_scene.ClientManager.Remove(client.CircuitCode); | ||
203 | client.Close(false); | ||
204 | } | ||
205 | } | ||
206 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs deleted file mode 100644 index 52effc5..0000000 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
29 | { | ||
30 | public class LLPacketThrottle | ||
31 | { | ||
32 | private readonly int m_maxAllowableThrottle; | ||
33 | private readonly int m_minAllowableThrottle; | ||
34 | private int m_currentThrottle; | ||
35 | private const int m_throttleTimeDivisor = 7; | ||
36 | private int m_currentBitsSent; | ||
37 | private int m_throttleBits; | ||
38 | |||
39 | /// <value> | ||
40 | /// Value with which to multiply all the throttle fields | ||
41 | /// </value> | ||
42 | private float m_throttleMultiplier; | ||
43 | |||
44 | public int Max | ||
45 | { | ||
46 | get { return m_maxAllowableThrottle; } | ||
47 | } | ||
48 | |||
49 | public int Min | ||
50 | { | ||
51 | get { return m_minAllowableThrottle; } | ||
52 | } | ||
53 | |||
54 | public int Current | ||
55 | { | ||
56 | get { return m_currentThrottle; } | ||
57 | } | ||
58 | |||
59 | /// <summary> | ||
60 | /// Constructor. | ||
61 | /// </summary> | ||
62 | /// <param name="min"></param> | ||
63 | /// <param name="max"></param> | ||
64 | /// <param name="throttle"></param> | ||
65 | /// <param name="throttleMultiplier"> | ||
66 | /// A parameter that's ends up multiplying all throttle settings. An alternative solution would have been | ||
67 | /// to multiply all the parameters by this before giving them to the constructor. But doing it this way | ||
68 | /// represents the fact that the multiplier is a hack that pumps data to clients much faster than the actual | ||
69 | /// settings that we are given. | ||
70 | /// </param> | ||
71 | public LLPacketThrottle(int min, int max, int throttle, float throttleMultiplier) | ||
72 | { | ||
73 | m_throttleMultiplier = throttleMultiplier; | ||
74 | m_maxAllowableThrottle = max; | ||
75 | m_minAllowableThrottle = min; | ||
76 | m_currentThrottle = throttle; | ||
77 | m_currentBitsSent = 0; | ||
78 | |||
79 | CalcBits(); | ||
80 | } | ||
81 | |||
82 | /// <summary> | ||
83 | /// Calculate the actual throttle required. | ||
84 | /// </summary> | ||
85 | private void CalcBits() | ||
86 | { | ||
87 | m_throttleBits = (int)((float)m_currentThrottle * m_throttleMultiplier / (float)m_throttleTimeDivisor); | ||
88 | } | ||
89 | |||
90 | public void Reset() | ||
91 | { | ||
92 | m_currentBitsSent = 0; | ||
93 | } | ||
94 | |||
95 | public bool UnderLimit() | ||
96 | { | ||
97 | return m_currentBitsSent < m_throttleBits; | ||
98 | } | ||
99 | |||
100 | public int AddBytes(int bytes) | ||
101 | { | ||
102 | m_currentBitsSent += bytes * 8; | ||
103 | return m_currentBitsSent; | ||
104 | } | ||
105 | |||
106 | public int Throttle | ||
107 | { | ||
108 | get { return m_currentThrottle; } | ||
109 | set | ||
110 | { | ||
111 | if (value < m_minAllowableThrottle) | ||
112 | { | ||
113 | m_currentThrottle = m_minAllowableThrottle; | ||
114 | } | ||
115 | else if (value > m_maxAllowableThrottle) | ||
116 | { | ||
117 | m_currentThrottle = m_maxAllowableThrottle; | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | m_currentThrottle = value; | ||
122 | } | ||
123 | |||
124 | CalcBits(); | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs new file mode 100644 index 0000000..871e8e8 --- /dev/null +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs | |||
@@ -0,0 +1,442 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
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> | ||
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> | ||
53 | public delegate void QueueEmpty(ThrottleOutPacketType category); | ||
54 | |||
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 | ||
61 | { | ||
62 | /// <summary>The number of packet categories to throttle on. If a throttle category is added | ||
63 | /// or removed, this number must also change</summary> | ||
64 | const int THROTTLE_CATEGORY_COUNT = 7; | ||
65 | |||
66 | /// <summary>Fired when updated networking stats are produced for this client</summary> | ||
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> | ||
70 | public event QueueEmpty OnQueueEmpty; | ||
71 | |||
72 | /// <summary>AgentID for this client</summary> | ||
73 | public readonly UUID AgentID; | ||
74 | /// <summary>The remote address of the connected client</summary> | ||
75 | public readonly IPEndPoint RemoteEndPoint; | ||
76 | /// <summary>Circuit code that this client is connected on</summary> | ||
77 | public readonly uint CircuitCode; | ||
78 | /// <summary>Sequence numbers of packets we've received (for duplicate checking)</summary> | ||
79 | public readonly IncomingPacketHistoryCollection PacketArchive = new IncomingPacketHistoryCollection(200); | ||
80 | /// <summary>Packets we have sent that need to be ACKed by the client</summary> | ||
81 | public readonly UnackedPacketCollection NeedAcks = new UnackedPacketCollection(); | ||
82 | /// <summary>ACKs that are queued up, waiting to be sent to the client</summary> | ||
83 | public readonly LocklessQueue<uint> PendingAcks = new LocklessQueue<uint>(); | ||
84 | |||
85 | /// <summary>Reference to the IClientAPI for this client</summary> | ||
86 | public LLClientView ClientAPI; | ||
87 | /// <summary>Current packet sequence number</summary> | ||
88 | public int CurrentSequence; | ||
89 | /// <summary>Current ping sequence number</summary> | ||
90 | public byte CurrentPingSequence; | ||
91 | /// <summary>True when this connection is alive, otherwise false</summary> | ||
92 | public bool IsConnected = true; | ||
93 | /// <summary>True when this connection is paused, otherwise false</summary> | ||
94 | public bool IsPaused = true; | ||
95 | /// <summary>Environment.TickCount when the last packet was received for this client</summary> | ||
96 | public int TickLastPacketReceived; | ||
97 | |||
98 | /// <summary>Timer granularity. This is set to the measured resolution of Environment.TickCount</summary> | ||
99 | public readonly float G; | ||
100 | /// <summary>Smoothed round-trip time. A smoothed average of the round-trip time for sending a | ||
101 | /// reliable packet to the client and receiving an ACK</summary> | ||
102 | public float SRTT; | ||
103 | /// <summary>Round-trip time variance. Measures the consistency of round-trip times</summary> | ||
104 | public float RTTVAR; | ||
105 | /// <summary>Retransmission timeout. Packets that have not been acknowledged in this number of | ||
106 | /// milliseconds or longer will be resent</summary> | ||
107 | /// <remarks>Calculated from <seealso cref="SRTT"/> and <seealso cref="RTTVAR"/> using the | ||
108 | /// guidelines in RFC 2988</remarks> | ||
109 | public int RTO; | ||
110 | /// <summary>Number of bytes received since the last acknowledgement was sent out. This is used | ||
111 | /// to loosely follow the TCP delayed ACK algorithm in RFC 1122 (4.2.3.2)</summary> | ||
112 | public int BytesSinceLastACK; | ||
113 | /// <summary>Number of packets received from this client</summary> | ||
114 | public int PacketsReceived; | ||
115 | /// <summary>Number of packets sent to this client</summary> | ||
116 | public int PacketsSent; | ||
117 | /// <summary>Total byte count of unacked packets sent to this client</summary> | ||
118 | public int UnackedBytes; | ||
119 | |||
120 | /// <summary>Total number of received packets that we have reported to the OnPacketStats event(s)</summary> | ||
121 | private int m_packetsReceivedReported; | ||
122 | /// <summary>Total number of sent packets that we have reported to the OnPacketStats event(s)</summary> | ||
123 | private int m_packetsSentReported; | ||
124 | |||
125 | /// <summary>Throttle bucket for this agent's connection</summary> | ||
126 | private readonly TokenBucket throttle; | ||
127 | /// <summary>Throttle buckets for each packet category</summary> | ||
128 | private readonly TokenBucket[] throttleCategories; | ||
129 | /// <summary>Throttle rate defaults and limits</summary> | ||
130 | private readonly ThrottleRates defaultThrottleRates; | ||
131 | /// <summary>Outgoing queues for throttled packets</summary> | ||
132 | private readonly LocklessQueue<OutgoingPacket>[] packetOutboxes = new LocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT]; | ||
133 | /// <summary>A container that can hold one packet for each outbox, used to store | ||
134 | /// dequeued packets that are being held for throttling</summary> | ||
135 | private readonly OutgoingPacket[] nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT]; | ||
136 | /// <summary>An optimization to store the length of dequeued packets being held | ||
137 | /// for throttling. This avoids expensive calls to Packet.Length</summary> | ||
138 | private readonly int[] nextPacketLengths = new int[THROTTLE_CATEGORY_COUNT]; | ||
139 | /// <summary>A reference to the LLUDPServer that is managing this client</summary> | ||
140 | private readonly LLUDPServer udpServer; | ||
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> | ||
152 | public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint) | ||
153 | { | ||
154 | udpServer = server; | ||
155 | AgentID = agentID; | ||
156 | RemoteEndPoint = remoteEndPoint; | ||
157 | CircuitCode = circuitCode; | ||
158 | defaultThrottleRates = rates; | ||
159 | |||
160 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) | ||
161 | packetOutboxes[i] = new LocklessQueue<OutgoingPacket>(); | ||
162 | |||
163 | throttle = new TokenBucket(parentThrottle, 0, 0); | ||
164 | throttleCategories = new TokenBucket[THROTTLE_CATEGORY_COUNT]; | ||
165 | throttleCategories[(int)ThrottleOutPacketType.Resend] = new TokenBucket(throttle, rates.ResendLimit, rates.Resend); | ||
166 | throttleCategories[(int)ThrottleOutPacketType.Land] = new TokenBucket(throttle, rates.LandLimit, rates.Land); | ||
167 | throttleCategories[(int)ThrottleOutPacketType.Wind] = new TokenBucket(throttle, rates.WindLimit, rates.Wind); | ||
168 | throttleCategories[(int)ThrottleOutPacketType.Cloud] = new TokenBucket(throttle, rates.CloudLimit, rates.Cloud); | ||
169 | throttleCategories[(int)ThrottleOutPacketType.Task] = new TokenBucket(throttle, rates.TaskLimit, rates.Task); | ||
170 | throttleCategories[(int)ThrottleOutPacketType.Texture] = new TokenBucket(throttle, rates.TextureLimit, rates.Texture); | ||
171 | throttleCategories[(int)ThrottleOutPacketType.Asset] = new TokenBucket(throttle, rates.AssetLimit, rates.Asset); | ||
172 | |||
173 | // Set the granularity variable used for retransmission calculations to | ||
174 | // the measured resolution of Environment.TickCount | ||
175 | G = server.TickCountResolution; | ||
176 | |||
177 | // Default the retransmission timeout to three seconds | ||
178 | RTO = 3000; | ||
179 | } | ||
180 | |||
181 | /// <summary> | ||
182 | /// Shuts down this client connection | ||
183 | /// </summary> | ||
184 | public void Shutdown() | ||
185 | { | ||
186 | // TODO: Do we need to invalidate the circuit? | ||
187 | IsConnected = false; | ||
188 | } | ||
189 | |||
190 | /// <summary> | ||
191 | /// Gets information about this client connection | ||
192 | /// </summary> | ||
193 | /// <returns>Information about the client connection</returns> | ||
194 | public ClientInfo GetClientInfo() | ||
195 | { | ||
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 | ||
199 | ClientInfo info = new ClientInfo(); | ||
200 | info.pendingAcks = new Dictionary<uint, uint>(); | ||
201 | info.needAck = new Dictionary<uint, byte[]>(); | ||
202 | |||
203 | info.resendThrottle = throttleCategories[(int)ThrottleOutPacketType.Resend].DripRate; | ||
204 | info.landThrottle = throttleCategories[(int)ThrottleOutPacketType.Land].DripRate; | ||
205 | info.windThrottle = throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate; | ||
206 | info.cloudThrottle = throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate; | ||
207 | info.taskThrottle = throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; | ||
208 | info.assetThrottle = throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate; | ||
209 | info.textureThrottle = throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate; | ||
210 | info.totalThrottle = info.resendThrottle + info.landThrottle + info.windThrottle + info.cloudThrottle + | ||
211 | info.taskThrottle + info.assetThrottle + info.textureThrottle; | ||
212 | |||
213 | return info; | ||
214 | } | ||
215 | |||
216 | /// <summary> | ||
217 | /// Modifies the UDP throttles | ||
218 | /// </summary> | ||
219 | /// <param name="info">New throttling values</param> | ||
220 | public void SetClientInfo(ClientInfo info) | ||
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(); | ||
226 | } | ||
227 | |||
228 | public string GetStats() | ||
229 | { | ||
230 | // TODO: ??? | ||
231 | return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}", | ||
232 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
233 | } | ||
234 | |||
235 | public void SendPacketStats() | ||
236 | { | ||
237 | PacketStats callback = OnPacketStats; | ||
238 | if (callback != null) | ||
239 | { | ||
240 | int newPacketsReceived = PacketsReceived - m_packetsReceivedReported; | ||
241 | int newPacketsSent = PacketsSent - m_packetsSentReported; | ||
242 | |||
243 | callback(newPacketsReceived, newPacketsSent, UnackedBytes); | ||
244 | |||
245 | m_packetsReceivedReported += newPacketsReceived; | ||
246 | m_packetsSentReported += newPacketsSent; | ||
247 | } | ||
248 | } | ||
249 | |||
250 | public void SetThrottles(byte[] throttleData) | ||
251 | { | ||
252 | byte[] adjData; | ||
253 | int pos = 0; | ||
254 | |||
255 | if (!BitConverter.IsLittleEndian) | ||
256 | { | ||
257 | byte[] newData = new byte[7 * 4]; | ||
258 | Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4); | ||
259 | |||
260 | for (int i = 0; i < 7; i++) | ||
261 | Array.Reverse(newData, i * 4, 4); | ||
262 | |||
263 | adjData = newData; | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | adjData = throttleData; | ||
268 | } | ||
269 | |||
270 | int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
271 | int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
272 | int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
273 | int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
274 | int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
275 | int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; | ||
276 | int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); | ||
277 | |||
278 | resend = (resend <= defaultThrottleRates.ResendLimit) ? resend : defaultThrottleRates.ResendLimit; | ||
279 | land = (land <= defaultThrottleRates.LandLimit) ? land : defaultThrottleRates.LandLimit; | ||
280 | wind = (wind <= defaultThrottleRates.WindLimit) ? wind : defaultThrottleRates.WindLimit; | ||
281 | cloud = (cloud <= defaultThrottleRates.CloudLimit) ? cloud : defaultThrottleRates.CloudLimit; | ||
282 | task = (task <= defaultThrottleRates.TaskLimit) ? task : defaultThrottleRates.TaskLimit; | ||
283 | texture = (texture <= defaultThrottleRates.TextureLimit) ? texture : defaultThrottleRates.TextureLimit; | ||
284 | asset = (asset <= defaultThrottleRates.AssetLimit) ? asset : defaultThrottleRates.AssetLimit; | ||
285 | |||
286 | SetThrottle(ThrottleOutPacketType.Resend, resend); | ||
287 | SetThrottle(ThrottleOutPacketType.Land, land); | ||
288 | SetThrottle(ThrottleOutPacketType.Wind, wind); | ||
289 | SetThrottle(ThrottleOutPacketType.Cloud, cloud); | ||
290 | SetThrottle(ThrottleOutPacketType.Task, task); | ||
291 | SetThrottle(ThrottleOutPacketType.Texture, texture); | ||
292 | SetThrottle(ThrottleOutPacketType.Asset, asset); | ||
293 | } | ||
294 | |||
295 | public byte[] GetThrottlesPacked() | ||
296 | { | ||
297 | byte[] data = new byte[7 * 4]; | ||
298 | int i = 0; | ||
299 | |||
300 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Resend].DripRate), 0, data, i, 4); i += 4; | ||
301 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Land].DripRate), 0, data, i, 4); i += 4; | ||
302 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate), 0, data, i, 4); i += 4; | ||
303 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate), 0, data, i, 4); i += 4; | ||
304 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Task].DripRate), 0, data, i, 4); i += 4; | ||
305 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate), 0, data, i, 4); i += 4; | ||
306 | Buffer.BlockCopy(Utils.FloatToBytes((float)throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate), 0, data, i, 4); i += 4; | ||
307 | |||
308 | return data; | ||
309 | } | ||
310 | |||
311 | public void SetThrottle(ThrottleOutPacketType category, int rate) | ||
312 | { | ||
313 | int i = (int)category; | ||
314 | if (i >= 0 && i < throttleCategories.Length) | ||
315 | { | ||
316 | TokenBucket bucket = throttleCategories[(int)category]; | ||
317 | bucket.MaxBurst = rate; | ||
318 | bucket.DripRate = rate; | ||
319 | } | ||
320 | } | ||
321 | |||
322 | public bool EnqueueOutgoing(OutgoingPacket packet) | ||
323 | { | ||
324 | int category = (int)packet.Category; | ||
325 | |||
326 | if (category >= 0 && category < packetOutboxes.Length) | ||
327 | { | ||
328 | LocklessQueue<OutgoingPacket> queue = packetOutboxes[category]; | ||
329 | TokenBucket bucket = throttleCategories[category]; | ||
330 | |||
331 | if (throttleCategories[category].RemoveTokens(packet.Buffer.DataLength)) | ||
332 | { | ||
333 | // Enough tokens were removed from the bucket, the packet will not be queued | ||
334 | return false; | ||
335 | } | ||
336 | else | ||
337 | { | ||
338 | // Not enough tokens in the bucket, queue this packet | ||
339 | queue.Enqueue(packet); | ||
340 | return true; | ||
341 | } | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | // We don't have a token bucket for this category, so it will not be queued | ||
346 | return false; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | /// <summary> | ||
351 | /// Loops through all of the packet queues for this client and tries to send | ||
352 | /// any outgoing packets, obeying the throttling bucket limits | ||
353 | /// </summary> | ||
354 | /// <remarks>This function is only called from a synchronous loop in the | ||
355 | /// UDPServer so we don't need to bother making this thread safe</remarks> | ||
356 | /// <returns>True if any packets were sent, otherwise false</returns> | ||
357 | public bool DequeueOutgoing() | ||
358 | { | ||
359 | OutgoingPacket packet; | ||
360 | LocklessQueue<OutgoingPacket> queue; | ||
361 | TokenBucket bucket; | ||
362 | bool packetSent = false; | ||
363 | |||
364 | for (int i = 0; i < THROTTLE_CATEGORY_COUNT; i++) | ||
365 | { | ||
366 | bucket = throttleCategories[i]; | ||
367 | |||
368 | if (nextPackets[i] != null) | ||
369 | { | ||
370 | // This bucket was empty the last time we tried to send a packet, | ||
371 | // leaving a dequeued packet still waiting to be sent out. Try to | ||
372 | // send it again | ||
373 | if (bucket.RemoveTokens(nextPacketLengths[i])) | ||
374 | { | ||
375 | // Send the packet | ||
376 | udpServer.SendPacketFinal(nextPackets[i]); | ||
377 | nextPackets[i] = null; | ||
378 | packetSent = true; | ||
379 | } | ||
380 | } | ||
381 | else | ||
382 | { | ||
383 | // No dequeued packet waiting to be sent, try to pull one off | ||
384 | // this queue | ||
385 | queue = packetOutboxes[i]; | ||
386 | if (queue.Dequeue(out packet)) | ||
387 | { | ||
388 | // A packet was pulled off the queue. See if we have | ||
389 | // enough tokens in the bucket to send it out | ||
390 | if (bucket.RemoveTokens(packet.Buffer.DataLength)) | ||
391 | { | ||
392 | // Send the packet | ||
393 | udpServer.SendPacketFinal(packet); | ||
394 | packetSent = true; | ||
395 | } | ||
396 | else | ||
397 | { | ||
398 | // Save the dequeued packet and the length calculation for | ||
399 | // the next iteration | ||
400 | nextPackets[i] = packet; | ||
401 | nextPacketLengths[i] = packet.Buffer.DataLength; | ||
402 | } | ||
403 | } | ||
404 | else | ||
405 | { | ||
406 | // No packets in this queue. Fire the queue empty callback | ||
407 | QueueEmpty callback = OnQueueEmpty; | ||
408 | if (callback != null) | ||
409 | callback((ThrottleOutPacketType)i); | ||
410 | } | ||
411 | } | ||
412 | } | ||
413 | |||
414 | return packetSent; | ||
415 | } | ||
416 | |||
417 | public void UpdateRoundTrip(float r) | ||
418 | { | ||
419 | const float ALPHA = 0.125f; | ||
420 | const float BETA = 0.25f; | ||
421 | const float K = 4.0f; | ||
422 | |||
423 | if (RTTVAR == 0.0f) | ||
424 | { | ||
425 | // First RTT measurement | ||
426 | SRTT = r; | ||
427 | RTTVAR = r * 0.5f; | ||
428 | } | ||
429 | else | ||
430 | { | ||
431 | // Subsequence RTT measurement | ||
432 | RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r); | ||
433 | SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r; | ||
434 | } | ||
435 | |||
436 | // Always round retransmission timeout up to two seconds | ||
437 | RTO = Math.Max(2000, (int)(SRTT + Math.Max(G, K * RTTVAR))); | ||
438 | //Logger.Debug("Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " + | ||
439 | // RTTVAR + " based on new RTT of " + r + "ms"); | ||
440 | } | ||
441 | } | ||
442 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs new file mode 100644 index 0000000..f6ccf01 --- /dev/null +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenMetaverse; | ||
33 | |||
34 | using ReaderWriterLockImpl = OpenMetaverse.ReaderWriterLockSlim; | ||
35 | |||
36 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
37 | { | ||
38 | public sealed class UDPClientCollection | ||
39 | { | ||
40 | Dictionary<UUID, LLUDPClient> Dictionary1; | ||
41 | Dictionary<IPEndPoint, LLUDPClient> Dictionary2; | ||
42 | LLUDPClient[] Array; | ||
43 | ReaderWriterLockImpl rwLock = new ReaderWriterLockImpl(); | ||
44 | object m_sync = new object(); | ||
45 | |||
46 | public UDPClientCollection() | ||
47 | { | ||
48 | Dictionary1 = new Dictionary<UUID, LLUDPClient>(); | ||
49 | Dictionary2 = new Dictionary<IPEndPoint, LLUDPClient>(); | ||
50 | Array = new LLUDPClient[0]; | ||
51 | } | ||
52 | |||
53 | public UDPClientCollection(int capacity) | ||
54 | { | ||
55 | Dictionary1 = new Dictionary<UUID, LLUDPClient>(capacity); | ||
56 | Dictionary2 = new Dictionary<IPEndPoint, LLUDPClient>(capacity); | ||
57 | Array = new LLUDPClient[0]; | ||
58 | } | ||
59 | |||
60 | public void Add(UUID key1, IPEndPoint key2, LLUDPClient value) | ||
61 | { | ||
62 | //rwLock.EnterWriteLock(); | ||
63 | |||
64 | //try | ||
65 | //{ | ||
66 | // if (Dictionary1.ContainsKey(key1)) | ||
67 | // { | ||
68 | // if (!Dictionary2.ContainsKey(key2)) | ||
69 | // throw new ArgumentException("key1 exists in the dictionary but not key2"); | ||
70 | // } | ||
71 | // else if (Dictionary2.ContainsKey(key2)) | ||
72 | // { | ||
73 | // if (!Dictionary1.ContainsKey(key1)) | ||
74 | // throw new ArgumentException("key2 exists in the dictionary but not key1"); | ||
75 | // } | ||
76 | |||
77 | // Dictionary1[key1] = value; | ||
78 | // Dictionary2[key2] = value; | ||
79 | |||
80 | // LLUDPClient[] oldArray = Array; | ||
81 | // int oldLength = oldArray.Length; | ||
82 | |||
83 | // LLUDPClient[] newArray = new LLUDPClient[oldLength + 1]; | ||
84 | // for (int i = 0; i < oldLength; i++) | ||
85 | // newArray[i] = oldArray[i]; | ||
86 | // newArray[oldLength] = value; | ||
87 | |||
88 | // Array = newArray; | ||
89 | //} | ||
90 | //finally { rwLock.ExitWriteLock(); } | ||
91 | |||
92 | lock (m_sync) | ||
93 | { | ||
94 | if (Dictionary1.ContainsKey(key1)) | ||
95 | { | ||
96 | if (!Dictionary2.ContainsKey(key2)) | ||
97 | throw new ArgumentException("key1 exists in the dictionary but not key2"); | ||
98 | } | ||
99 | else if (Dictionary2.ContainsKey(key2)) | ||
100 | { | ||
101 | if (!Dictionary1.ContainsKey(key1)) | ||
102 | throw new ArgumentException("key2 exists in the dictionary but not key1"); | ||
103 | } | ||
104 | |||
105 | Dictionary1[key1] = value; | ||
106 | Dictionary2[key2] = value; | ||
107 | |||
108 | LLUDPClient[] oldArray = Array; | ||
109 | int oldLength = oldArray.Length; | ||
110 | |||
111 | LLUDPClient[] newArray = new LLUDPClient[oldLength + 1]; | ||
112 | for (int i = 0; i < oldLength; i++) | ||
113 | newArray[i] = oldArray[i]; | ||
114 | newArray[oldLength] = value; | ||
115 | |||
116 | Array = newArray; | ||
117 | } | ||
118 | |||
119 | } | ||
120 | |||
121 | public bool Remove(UUID key1, IPEndPoint key2) | ||
122 | { | ||
123 | //rwLock.EnterWriteLock(); | ||
124 | |||
125 | //try | ||
126 | //{ | ||
127 | // LLUDPClient value; | ||
128 | // if (Dictionary1.TryGetValue(key1, out value)) | ||
129 | // { | ||
130 | // Dictionary1.Remove(key1); | ||
131 | // Dictionary2.Remove(key2); | ||
132 | |||
133 | // LLUDPClient[] oldArray = Array; | ||
134 | // int oldLength = oldArray.Length; | ||
135 | |||
136 | // LLUDPClient[] newArray = new LLUDPClient[oldLength - 1]; | ||
137 | // int j = 0; | ||
138 | // for (int i = 0; i < oldLength; i++) | ||
139 | // { | ||
140 | // if (oldArray[i] != value) | ||
141 | // newArray[j++] = oldArray[i]; | ||
142 | // } | ||
143 | |||
144 | // Array = newArray; | ||
145 | // return true; | ||
146 | // } | ||
147 | //} | ||
148 | //finally { rwLock.ExitWriteLock(); } | ||
149 | |||
150 | //return false; | ||
151 | |||
152 | lock (m_sync) | ||
153 | { | ||
154 | LLUDPClient value; | ||
155 | if (Dictionary1.TryGetValue(key1, out value)) | ||
156 | { | ||
157 | Dictionary1.Remove(key1); | ||
158 | Dictionary2.Remove(key2); | ||
159 | |||
160 | LLUDPClient[] oldArray = Array; | ||
161 | int oldLength = oldArray.Length; | ||
162 | |||
163 | LLUDPClient[] newArray = new LLUDPClient[oldLength - 1]; | ||
164 | int j = 0; | ||
165 | for (int i = 0; i < oldLength; i++) | ||
166 | { | ||
167 | if (oldArray[i] != value) | ||
168 | newArray[j++] = oldArray[i]; | ||
169 | } | ||
170 | |||
171 | Array = newArray; | ||
172 | return true; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | return false; | ||
177 | |||
178 | } | ||
179 | |||
180 | public void Clear() | ||
181 | { | ||
182 | //rwLock.EnterWriteLock(); | ||
183 | |||
184 | //try | ||
185 | //{ | ||
186 | // Dictionary1.Clear(); | ||
187 | // Dictionary2.Clear(); | ||
188 | // Array = new LLUDPClient[0]; | ||
189 | //} | ||
190 | //finally { rwLock.ExitWriteLock(); } | ||
191 | |||
192 | lock (m_sync) | ||
193 | { | ||
194 | Dictionary1.Clear(); | ||
195 | Dictionary2.Clear(); | ||
196 | Array = new LLUDPClient[0]; | ||
197 | } | ||
198 | |||
199 | } | ||
200 | |||
201 | public int Count | ||
202 | { | ||
203 | get { return Array.Length; } | ||
204 | } | ||
205 | |||
206 | public bool ContainsKey(UUID key) | ||
207 | { | ||
208 | return Dictionary1.ContainsKey(key); | ||
209 | } | ||
210 | |||
211 | public bool ContainsKey(IPEndPoint key) | ||
212 | { | ||
213 | return Dictionary2.ContainsKey(key); | ||
214 | } | ||
215 | |||
216 | public bool TryGetValue(UUID key, out LLUDPClient value) | ||
217 | { | ||
218 | ////bool success; | ||
219 | ////bool doLock = !rwLock.IsUpgradeableReadLockHeld; | ||
220 | ////if (doLock) rwLock.EnterReadLock(); | ||
221 | |||
222 | ////try { success = Dictionary1.TryGetValue(key, out value); } | ||
223 | ////finally { if (doLock) rwLock.ExitReadLock(); } | ||
224 | |||
225 | ////return success; | ||
226 | |||
227 | //lock (m_sync) | ||
228 | // return Dictionary1.TryGetValue(key, out value); | ||
229 | |||
230 | try | ||
231 | { | ||
232 | return Dictionary1.TryGetValue(key, out value); | ||
233 | } | ||
234 | catch { } | ||
235 | value = null; | ||
236 | return false; | ||
237 | } | ||
238 | |||
239 | public bool TryGetValue(IPEndPoint key, out LLUDPClient value) | ||
240 | { | ||
241 | ////bool success; | ||
242 | ////bool doLock = !rwLock.IsUpgradeableReadLockHeld; | ||
243 | ////if (doLock) rwLock.EnterReadLock(); | ||
244 | |||
245 | ////try { success = Dictionary2.TryGetValue(key, out value); } | ||
246 | ////finally { if (doLock) rwLock.ExitReadLock(); } | ||
247 | |||
248 | ////return success; | ||
249 | |||
250 | lock (m_sync) | ||
251 | return Dictionary2.TryGetValue(key, out value); | ||
252 | |||
253 | //try | ||
254 | //{ | ||
255 | // return Dictionary2.TryGetValue(key, out value); | ||
256 | //} | ||
257 | //catch { } | ||
258 | //value = null; | ||
259 | //return false; | ||
260 | |||
261 | } | ||
262 | |||
263 | public void ForEach(Action<LLUDPClient> action) | ||
264 | { | ||
265 | //bool doLock = !rwLock.IsUpgradeableReadLockHeld; | ||
266 | //if (doLock) rwLock.EnterUpgradeableReadLock(); | ||
267 | |||
268 | //try { Parallel.ForEach<LLUDPClient>(Array, action); } | ||
269 | //finally { if (doLock) rwLock.ExitUpgradeableReadLock(); } | ||
270 | |||
271 | LLUDPClient[] localArray = null; | ||
272 | lock (m_sync) | ||
273 | { | ||
274 | localArray = new LLUDPClient[Array.Length]; | ||
275 | Array.CopyTo(localArray, 0); | ||
276 | } | ||
277 | |||
278 | Parallel.ForEach<LLUDPClient>(localArray, action); | ||
279 | |||
280 | } | ||
281 | } | ||
282 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index c779b08..2c5ad85 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -26,616 +26,779 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
31 | using System.Net; | 30 | using System.Net; |
32 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
33 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Threading; | ||
34 | using log4net; | 34 | using log4net; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenMetaverse.Packets; | 36 | using OpenMetaverse.Packets; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Statistics; | ||
38 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenMetaverse; | ||
39 | 41 | ||
40 | namespace OpenSim.Region.ClientStack.LindenUDP | 42 | namespace OpenSim.Region.ClientStack.LindenUDP |
41 | { | 43 | { |
42 | /// <summary> | 44 | /// <summary> |
43 | /// This class handles the initial UDP circuit setup with a client and passes on subsequent packets to the LLPacketServer | 45 | /// A shim around LLUDPServer that implements the IClientNetworkServer interface |
44 | /// </summary> | 46 | /// </summary> |
45 | public class LLUDPServer : ILLClientStackNetworkHandler, IClientNetworkServer | 47 | public sealed class LLUDPServerShim : IClientNetworkServer |
46 | { | 48 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | LLUDPServer m_udpServer; |
48 | |||
49 | /// <value> | ||
50 | /// The client circuits established with this UDP server. If a client exists here we can also assume that | ||
51 | /// it is populated in clientCircuits_reverse and proxyCircuits (if relevant) | ||
52 | /// </value> | ||
53 | protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); | ||
54 | public Hashtable clientCircuits_reverse = Hashtable.Synchronized(new Hashtable()); | ||
55 | protected Dictionary<uint, EndPoint> proxyCircuits = new Dictionary<uint, EndPoint>(); | ||
56 | |||
57 | private Socket m_socket; | ||
58 | protected IPEndPoint ServerIncoming; | ||
59 | protected byte[] RecvBuffer = new byte[4096]; | ||
60 | protected byte[] ZeroBuffer = new byte[8192]; | ||
61 | 50 | ||
62 | /// <value> | 51 | public LLUDPServerShim() |
63 | /// This is an endpoint that is reused where we don't need to protect the information from potentially | 52 | { |
64 | /// being stomped on by other threads. | 53 | } |
65 | /// </value> | ||
66 | protected EndPoint reusedEpSender = new IPEndPoint(IPAddress.Any, 0); | ||
67 | |||
68 | protected int proxyPortOffset; | ||
69 | |||
70 | protected AsyncCallback ReceivedData; | ||
71 | protected LLPacketServer m_packetServer; | ||
72 | protected Location m_location; | ||
73 | 54 | ||
74 | protected uint listenPort; | 55 | public void Initialise(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) |
75 | protected bool Allow_Alternate_Port; | 56 | { |
76 | protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); | 57 | m_udpServer = new LLUDPServer(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager); |
77 | protected IScene m_localScene; | 58 | } |
78 | protected int m_clientSocketReceiveBuffer = 0; | ||
79 | 59 | ||
80 | /// <value> | 60 | public void NetworkStop() |
81 | /// Manages authentication for agent circuits | 61 | { |
82 | /// </value> | 62 | m_udpServer.Stop(); |
83 | protected AgentCircuitManager m_circuitManager; | 63 | } |
84 | 64 | ||
85 | public IScene LocalScene | 65 | public void AddScene(IScene scene) |
86 | { | 66 | { |
87 | set | 67 | m_udpServer.AddScene(scene); |
88 | { | 68 | } |
89 | m_localScene = value; | ||
90 | m_packetServer.LocalScene = m_localScene; | ||
91 | 69 | ||
92 | m_location = new Location(m_localScene.RegionInfo.RegionHandle); | 70 | public bool HandlesRegion(Location x) |
93 | } | 71 | { |
72 | return m_udpServer.HandlesRegion(x); | ||
94 | } | 73 | } |
95 | 74 | ||
96 | public ulong RegionHandle | 75 | public void Start() |
97 | { | 76 | { |
98 | get { return m_location.RegionHandle; } | 77 | m_udpServer.Start(); |
99 | } | 78 | } |
100 | 79 | ||
101 | Socket IClientNetworkServer.Server | 80 | public void Stop() |
102 | { | 81 | { |
103 | get { return m_socket; } | 82 | m_udpServer.Stop(); |
104 | } | 83 | } |
84 | } | ||
105 | 85 | ||
106 | public bool HandlesRegion(Location x) | 86 | /// <summary> |
87 | /// The LLUDP server for a region. This handles incoming and outgoing | ||
88 | /// packets for all UDP connections to the region | ||
89 | /// </summary> | ||
90 | public class LLUDPServer : UDPBase | ||
91 | { | ||
92 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
93 | |||
94 | /// <summary>Handlers for incoming packets</summary> | ||
95 | //PacketEventDictionary packetEvents = new PacketEventDictionary(); | ||
96 | /// <summary>Incoming packets that are awaiting handling</summary> | ||
97 | private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>(); | ||
98 | /// <summary></summary> | ||
99 | private UDPClientCollection clients = new UDPClientCollection(); | ||
100 | /// <summary>Bandwidth throttle for this UDP server</summary> | ||
101 | private TokenBucket m_throttle; | ||
102 | /// <summary>Bandwidth throttle rates for this UDP server</summary> | ||
103 | private ThrottleRates m_throttleRates; | ||
104 | /// <summary>Manages authentication for agent circuits</summary> | ||
105 | private AgentCircuitManager m_circuitManager; | ||
106 | /// <summary>Reference to the scene this UDP server is attached to</summary> | ||
107 | private IScene m_scene; | ||
108 | /// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary> | ||
109 | private Location m_location; | ||
110 | /// <summary>The measured resolution of Environment.TickCount</summary> | ||
111 | private float m_tickCountResolution; | ||
112 | |||
113 | /// <summary>The measured resolution of Environment.TickCount</summary> | ||
114 | public float TickCountResolution { get { return m_tickCountResolution; } } | ||
115 | public Socket Server { get { return null; } } | ||
116 | |||
117 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) | ||
118 | : base((int)port) | ||
107 | { | 119 | { |
108 | //return x.RegionHandle == m_location.RegionHandle; | 120 | #region Environment.TickCount Measurement |
109 | return x == m_location; | 121 | |
122 | // Measure the resolution of Environment.TickCount | ||
123 | m_tickCountResolution = 0f; | ||
124 | for (int i = 0; i < 5; i++) | ||
125 | { | ||
126 | int start = Environment.TickCount; | ||
127 | int now = start; | ||
128 | while (now == start) | ||
129 | now = Environment.TickCount; | ||
130 | m_tickCountResolution += (float)(now - start) * 0.2f; | ||
131 | } | ||
132 | m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms"); | ||
133 | |||
134 | #endregion Environment.TickCount Measurement | ||
135 | |||
136 | m_circuitManager = circuitManager; | ||
137 | |||
138 | // TODO: Config support for throttling the entire connection | ||
139 | m_throttle = new TokenBucket(null, 0, 0); | ||
140 | m_throttleRates = new ThrottleRates(configSource); | ||
110 | } | 141 | } |
111 | 142 | ||
112 | public void AddScene(IScene x) | 143 | public new void Start() |
113 | { | 144 | { |
114 | LocalScene = x; | 145 | if (m_scene == null) |
146 | throw new InvalidOperationException("Cannot LLUDPServer.Start() without an IScene reference"); | ||
147 | |||
148 | base.Start(); | ||
149 | |||
150 | // Start the incoming packet processing thread | ||
151 | Thread incomingThread = new Thread(IncomingPacketHandler); | ||
152 | incomingThread.Name = "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")"; | ||
153 | incomingThread.Start(); | ||
154 | |||
155 | Thread outgoingThread = new Thread(OutgoingPacketHandler); | ||
156 | outgoingThread.Name = "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")"; | ||
157 | outgoingThread.Start(); | ||
115 | } | 158 | } |
116 | 159 | ||
117 | public void Start() | 160 | public new void Stop() |
118 | { | 161 | { |
119 | ServerListener(); | 162 | m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName); |
163 | base.Stop(); | ||
120 | } | 164 | } |
121 | 165 | ||
122 | public void Stop() | 166 | public void AddScene(IScene scene) |
123 | { | 167 | { |
124 | m_socket.Close(); | 168 | if (m_scene == null) |
169 | { | ||
170 | m_scene = scene; | ||
171 | m_location = new Location(m_scene.RegionInfo.RegionHandle); | ||
172 | } | ||
173 | else | ||
174 | { | ||
175 | m_log.Error("[LLUDPSERVER]: AddScene() called on an LLUDPServer that already has a scene"); | ||
176 | } | ||
125 | } | 177 | } |
126 | 178 | ||
127 | public LLUDPServer() | 179 | public bool HandlesRegion(Location x) |
128 | { | 180 | { |
181 | return x == m_location; | ||
129 | } | 182 | } |
130 | 183 | ||
131 | public LLUDPServer( | 184 | public void RemoveClient(IClientAPI client) |
132 | IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource, | ||
133 | AgentCircuitManager authenticateClass) | ||
134 | { | 185 | { |
135 | Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, authenticateClass); | 186 | m_scene.ClientManager.Remove(client.CircuitCode); |
187 | client.Close(false); | ||
188 | |||
189 | LLUDPClient udpClient; | ||
190 | if (clients.TryGetValue(client.AgentId, out udpClient)) | ||
191 | { | ||
192 | m_log.Debug("[LLUDPSERVER]: Removing LLUDPClient for " + client.Name); | ||
193 | udpClient.Shutdown(); | ||
194 | clients.Remove(client.AgentId, udpClient.RemoteEndPoint); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | m_log.Warn("[LLUDPSERVER]: Failed to remove LLUDPClient for " + client.Name); | ||
199 | } | ||
136 | } | 200 | } |
137 | 201 | ||
138 | /// <summary> | 202 | public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) |
139 | /// Initialize the server | ||
140 | /// </summary> | ||
141 | /// <param name="_listenIP"></param> | ||
142 | /// <param name="port"></param> | ||
143 | /// <param name="proxyPortOffsetParm"></param> | ||
144 | /// <param name="allow_alternate_port"></param> | ||
145 | /// <param name="configSource"></param> | ||
146 | /// <param name="assetCache"></param> | ||
147 | /// <param name="circuitManager"></param> | ||
148 | public void Initialise( | ||
149 | IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, | ||
150 | AgentCircuitManager circuitManager) | ||
151 | { | 203 | { |
152 | ClientStackUserSettings userSettings = new ClientStackUserSettings(); | 204 | // CoarseLocationUpdate packets cannot be split in an automated way |
153 | 205 | if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) | |
154 | IConfig config = configSource.Configs["ClientStack.LindenUDP"]; | 206 | allowSplitting = false; |
155 | 207 | ||
156 | if (config != null) | 208 | if (allowSplitting && packet.HasVariableBlocks) |
157 | { | 209 | { |
158 | if (config.Contains("client_throttle_max_bps")) | 210 | byte[][] datas = packet.ToBytesMultiple(); |
159 | { | 211 | int packetCount = datas.Length; |
160 | int maxBPS = config.GetInt("client_throttle_max_bps", 1500000); | ||
161 | userSettings.TotalThrottleSettings = new ThrottleSettings(0, maxBPS, | ||
162 | maxBPS > 28000 ? maxBPS : 28000); | ||
163 | } | ||
164 | 212 | ||
165 | if (config.Contains("client_throttle_multiplier")) | 213 | //if (packetCount > 1) |
166 | userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier"); | 214 | // m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); |
167 | if (config.Contains("client_socket_rcvbuf_size")) | ||
168 | m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size"); | ||
169 | } | ||
170 | |||
171 | m_log.DebugFormat("[CLIENT]: client_throttle_multiplier = {0}", userSettings.ClientThrottleMultipler); | ||
172 | m_log.DebugFormat("[CLIENT]: client_socket_rcvbuf_size = {0}", (m_clientSocketReceiveBuffer != 0 ? | ||
173 | m_clientSocketReceiveBuffer.ToString() : "OS default")); | ||
174 | |||
175 | proxyPortOffset = proxyPortOffsetParm; | ||
176 | listenPort = (uint) (port + proxyPortOffsetParm); | ||
177 | listenIP = _listenIP; | ||
178 | Allow_Alternate_Port = allow_alternate_port; | ||
179 | m_circuitManager = circuitManager; | ||
180 | CreatePacketServer(userSettings); | ||
181 | 215 | ||
182 | // Return new port | 216 | for (int i = 0; i < packetCount; i++) |
183 | // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered. | 217 | { |
184 | // So the option allow_alternate_ports="true" was added to default.xml | 218 | byte[] data = datas[i]; |
185 | port = (uint)(listenPort - proxyPortOffsetParm); | 219 | clients.ForEach( |
220 | delegate(LLUDPClient client) | ||
221 | { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); | ||
222 | } | ||
223 | } | ||
224 | else | ||
225 | { | ||
226 | byte[] data = packet.ToBytes(); | ||
227 | clients.ForEach( | ||
228 | delegate(LLUDPClient client) | ||
229 | { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); | ||
230 | } | ||
186 | } | 231 | } |
187 | 232 | ||
188 | protected virtual void CreatePacketServer(ClientStackUserSettings userSettings) | 233 | public void SendPacket(UUID agentID, Packet packet, ThrottleOutPacketType category, bool allowSplitting) |
189 | { | 234 | { |
190 | new LLPacketServer(this, userSettings); | 235 | LLUDPClient client; |
236 | if (clients.TryGetValue(agentID, out client)) | ||
237 | SendPacket(client, packet, category, allowSplitting); | ||
238 | else | ||
239 | m_log.Warn("[LLUDPSERVER]: Attempted to send a packet to unknown agentID " + agentID); | ||
191 | } | 240 | } |
192 | 241 | ||
193 | /// <summary> | 242 | public void SendPacket(LLUDPClient client, Packet packet, ThrottleOutPacketType category, bool allowSplitting) |
194 | /// This method is called every time that we receive new UDP data. | ||
195 | /// </summary> | ||
196 | /// <param name="result"></param> | ||
197 | protected virtual void OnReceivedData(IAsyncResult result) | ||
198 | { | 243 | { |
199 | Packet packet = null; | 244 | // CoarseLocationUpdate packets cannot be split in an automated way |
200 | int numBytes = 1; | 245 | if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting) |
201 | EndPoint epSender = new IPEndPoint(IPAddress.Any, 0); | 246 | allowSplitting = false; |
202 | EndPoint epProxy = null; | ||
203 | 247 | ||
204 | try | 248 | if (allowSplitting && packet.HasVariableBlocks) |
205 | { | 249 | { |
206 | if (EndReceive(out numBytes, result, ref epSender)) | 250 | byte[][] datas = packet.ToBytesMultiple(); |
207 | { | 251 | int packetCount = datas.Length; |
208 | // Make sure we are getting zeroes when running off the | 252 | |
209 | // end of grab / degrab packets from old clients | 253 | //if (packetCount > 1) |
210 | Array.Clear(RecvBuffer, numBytes, RecvBuffer.Length - numBytes); | 254 | // m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); |
211 | 255 | ||
212 | int packetEnd = numBytes - 1; | 256 | for (int i = 0; i < packetCount; i++) |
213 | if (proxyPortOffset != 0) packetEnd -= 6; | ||
214 | |||
215 | try | ||
216 | { | ||
217 | packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer); | ||
218 | } | ||
219 | catch (MalformedDataException e) | ||
220 | { | ||
221 | m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace); | ||
222 | } | ||
223 | catch (IndexOutOfRangeException e) | ||
224 | { | ||
225 | m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace); | ||
226 | } | ||
227 | catch (Exception e) | ||
228 | { | ||
229 | m_log.Debug("[CLIENT]: " + e); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | |||
234 | if (proxyPortOffset != 0) | ||
235 | { | 257 | { |
236 | // If we've received a use circuit packet, then we need to decode an endpoint proxy, if one exists, | 258 | byte[] data = datas[i]; |
237 | // before allowing the RecvBuffer to be overwritten by the next packet. | 259 | SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); |
238 | if (packet != null && packet.Type == PacketType.UseCircuitCode) | ||
239 | { | ||
240 | epProxy = epSender; | ||
241 | } | ||
242 | |||
243 | // Now decode the message from the proxy server | ||
244 | epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes); | ||
245 | } | 260 | } |
246 | } | 261 | } |
247 | catch (Exception ex) | 262 | else |
248 | { | 263 | { |
249 | m_log.ErrorFormat("[CLIENT]: Exception thrown during EndReceive(): {0}", ex); | 264 | byte[] data = packet.ToBytes(); |
265 | SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); | ||
250 | } | 266 | } |
267 | } | ||
251 | 268 | ||
252 | BeginRobustReceive(); | 269 | public void SendPacketData(LLUDPClient client, byte[] data, int dataLength, PacketType type, bool doZerocode, ThrottleOutPacketType category) |
270 | { | ||
271 | // Frequency analysis of outgoing packet sizes shows a large clump of packets at each end of the spectrum. | ||
272 | // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting | ||
273 | // there are a decent number of packets in the 1000-1140 byte range. We allocate one of two sizes of data here | ||
274 | // to accomodate for both common scenarios and provide ample room for ACK appending in both | ||
275 | int bufferSize = (dataLength > 180) ? Packet.MTU : 200; | ||
276 | |||
277 | UDPPacketBuffer buffer = new UDPPacketBuffer(client.RemoteEndPoint, bufferSize); | ||
253 | 278 | ||
254 | if (packet != null) | 279 | // Zerocode if needed |
280 | if (doZerocode) | ||
255 | { | 281 | { |
256 | if (packet.Type == PacketType.UseCircuitCode) | 282 | try { dataLength = Helpers.ZeroEncode(data, dataLength, buffer.Data); } |
257 | AddNewClient((UseCircuitCodePacket)packet, epSender, epProxy); | 283 | catch (IndexOutOfRangeException) |
258 | else | 284 | { |
259 | ProcessInPacket(packet, epSender); | 285 | // The packet grew larger than the bufferSize while zerocoding. |
286 | // Remove the MSG_ZEROCODED flag and send the unencoded data | ||
287 | // instead | ||
288 | m_log.Info("[LLUDPSERVER]: Packet exceeded buffer size during zerocoding. Removing MSG_ZEROCODED flag"); | ||
289 | data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED); | ||
290 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | ||
291 | } | ||
292 | } | ||
293 | else | ||
294 | { | ||
295 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | ||
260 | } | 296 | } |
297 | buffer.DataLength = dataLength; | ||
298 | |||
299 | #region Queue or Send | ||
300 | |||
301 | // Look up the UDPClient this is going to | ||
302 | OutgoingPacket outgoingPacket = new OutgoingPacket(client, buffer, category); | ||
303 | |||
304 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) | ||
305 | SendPacketFinal(outgoingPacket); | ||
306 | |||
307 | #endregion Queue or Send | ||
261 | } | 308 | } |
262 | 309 | ||
263 | /// <summary> | 310 | public void SendAcks(LLUDPClient client) |
264 | /// Process a successfully received packet. | ||
265 | /// </summary> | ||
266 | /// <param name="packet"></param> | ||
267 | /// <param name="epSender"></param> | ||
268 | protected virtual void ProcessInPacket(Packet packet, EndPoint epSender) | ||
269 | { | 311 | { |
270 | try | 312 | uint ack; |
313 | |||
314 | if (client.PendingAcks.Dequeue(out ack)) | ||
271 | { | 315 | { |
272 | // do we already have a circuit for this endpoint | 316 | List<PacketAckPacket.PacketsBlock> blocks = new List<PacketAckPacket.PacketsBlock>(); |
273 | uint circuit; | 317 | PacketAckPacket.PacketsBlock block = new PacketAckPacket.PacketsBlock(); |
274 | bool ret; | 318 | block.ID = ack; |
275 | 319 | blocks.Add(block); | |
276 | lock (clientCircuits) | 320 | |
321 | while (client.PendingAcks.Dequeue(out ack)) | ||
277 | { | 322 | { |
278 | ret = clientCircuits.TryGetValue(epSender, out circuit); | 323 | block = new PacketAckPacket.PacketsBlock(); |
324 | block.ID = ack; | ||
325 | blocks.Add(block); | ||
279 | } | 326 | } |
280 | 327 | ||
281 | if (ret) | 328 | PacketAckPacket packet = new PacketAckPacket(); |
282 | { | 329 | packet.Header.Reliable = false; |
283 | //if so then send packet to the packetserver | 330 | packet.Packets = blocks.ToArray(); |
284 | //m_log.DebugFormat( | ||
285 | // "[UDPSERVER]: For circuit {0} {1} got packet {2}", circuit, epSender, packet.Type); | ||
286 | 331 | ||
287 | m_packetServer.InPacket(circuit, packet); | 332 | SendPacket(client, packet, ThrottleOutPacketType.Unknown, true); |
288 | } | ||
289 | } | ||
290 | catch (Exception e) | ||
291 | { | ||
292 | m_log.Error("[CLIENT]: Exception in processing packet - ignoring: ", e); | ||
293 | } | 333 | } |
294 | } | 334 | } |
295 | 335 | ||
296 | /// <summary> | 336 | public void SendPing(LLUDPClient client) |
297 | /// Begin an asynchronous receive of the next bit of raw data | ||
298 | /// </summary> | ||
299 | protected virtual void BeginReceive() | ||
300 | { | 337 | { |
301 | m_socket.BeginReceiveFrom( | 338 | IClientAPI api = client.ClientAPI; |
302 | RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null); | 339 | if (api != null) |
340 | api.SendStartPingCheck(client.CurrentPingSequence++); | ||
303 | } | 341 | } |
304 | 342 | ||
305 | /// <summary> | 343 | public void ResendUnacked(LLUDPClient client) |
306 | /// Begin a robust asynchronous receive of the next bit of raw data. Robust means that SocketExceptions are | ||
307 | /// automatically dealt with until the next set of valid UDP data is received. | ||
308 | /// </summary> | ||
309 | private void BeginRobustReceive() | ||
310 | { | 344 | { |
311 | bool done = false; | 345 | if (client.NeedAcks.Count > 0) |
312 | |||
313 | while (!done) | ||
314 | { | 346 | { |
315 | try | 347 | List<OutgoingPacket> expiredPackets = client.NeedAcks.GetExpiredPackets(client.RTO); |
316 | { | ||
317 | BeginReceive(); | ||
318 | done = true; | ||
319 | } | ||
320 | catch (SocketException e) | ||
321 | { | ||
322 | // ENDLESS LOOP ON PURPOSE! | ||
323 | // Reset connection and get next UDP packet off the buffer | ||
324 | // If the UDP packet is part of the same stream, this will happen several hundreds of times before | ||
325 | // the next set of UDP data is for a valid client. | ||
326 | 348 | ||
327 | try | 349 | if (expiredPackets != null) |
328 | { | 350 | { |
329 | CloseCircuit(e); | 351 | // Resend packets |
330 | } | 352 | for (int i = 0; i < expiredPackets.Count; i++) |
331 | catch (Exception e2) | ||
332 | { | 353 | { |
333 | m_log.ErrorFormat( | 354 | OutgoingPacket outgoingPacket = expiredPackets[i]; |
334 | "[CLIENT]: Exception thrown when trying to close the circuit for {0} - {1}", reusedEpSender, | 355 | |
335 | e2); | 356 | // FIXME: Make this an .ini setting |
357 | if (outgoingPacket.ResendCount < 3) | ||
358 | { | ||
359 | //Logger.Debug(String.Format("Resending packet #{0} (attempt {1}), {2}ms have passed", | ||
360 | // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount)); | ||
361 | |||
362 | // Set the resent flag | ||
363 | outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); | ||
364 | outgoingPacket.Category = ThrottleOutPacketType.Resend; | ||
365 | |||
366 | // The TickCount will be set to the current time when the packet | ||
367 | // is actually sent out again | ||
368 | outgoingPacket.TickCount = 0; | ||
369 | |||
370 | // Bump up the resend count on this packet | ||
371 | Interlocked.Increment(ref outgoingPacket.ResendCount); | ||
372 | //Interlocked.Increment(ref Stats.ResentPackets); | ||
373 | |||
374 | // Queue or (re)send the packet | ||
375 | if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) | ||
376 | SendPacketFinal(outgoingPacket); | ||
377 | } | ||
378 | else | ||
379 | { | ||
380 | m_log.DebugFormat("[LLUDPSERVER]: Dropping packet #{0} for agent {1} after {2} failed attempts", | ||
381 | outgoingPacket.SequenceNumber, outgoingPacket.Client.RemoteEndPoint, outgoingPacket.ResendCount); | ||
382 | |||
383 | lock (client.NeedAcks.SyncRoot) | ||
384 | client.NeedAcks.RemoveUnsafe(outgoingPacket.SequenceNumber); | ||
385 | |||
386 | //Interlocked.Increment(ref Stats.DroppedPackets); | ||
387 | |||
388 | // Disconnect an agent if no packets are received for some time | ||
389 | //FIXME: Make 60 an .ini setting | ||
390 | if (Environment.TickCount - client.TickLastPacketReceived > 1000 * 60) | ||
391 | { | ||
392 | m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + client.ClientAPI.Name); | ||
393 | |||
394 | RemoveClient(client.ClientAPI); | ||
395 | return; | ||
396 | } | ||
397 | } | ||
336 | } | 398 | } |
337 | } | 399 | } |
338 | catch (ObjectDisposedException) | ||
339 | { | ||
340 | m_log.Info( | ||
341 | "[UDPSERVER]: UDP Object disposed. No need to worry about this if you're restarting the simulator."); | ||
342 | |||
343 | done = true; | ||
344 | } | ||
345 | catch (Exception ex) | ||
346 | { | ||
347 | m_log.ErrorFormat("[CLIENT]: Exception thrown during BeginReceive(): {0}", ex); | ||
348 | } | ||
349 | } | 400 | } |
350 | } | 401 | } |
351 | 402 | ||
352 | /// <summary> | 403 | public void Flush() |
353 | /// Close a client circuit. This is done in response to an exception on receive, and should not be called | ||
354 | /// normally. | ||
355 | /// </summary> | ||
356 | /// <param name="e">The exception that caused the close. Can be null if there was no exception</param> | ||
357 | private void CloseCircuit(Exception e) | ||
358 | { | 404 | { |
359 | uint circuit; | 405 | // FIXME: Implement? |
360 | lock (clientCircuits) | 406 | } |
407 | |||
408 | internal void SendPacketFinal(OutgoingPacket outgoingPacket) | ||
409 | { | ||
410 | UDPPacketBuffer buffer = outgoingPacket.Buffer; | ||
411 | byte flags = buffer.Data[0]; | ||
412 | bool isResend = (flags & Helpers.MSG_RESENT) != 0; | ||
413 | bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; | ||
414 | LLUDPClient client = outgoingPacket.Client; | ||
415 | |||
416 | // Keep track of when this packet was sent out (right now) | ||
417 | outgoingPacket.TickCount = Environment.TickCount; | ||
418 | |||
419 | #region ACK Appending | ||
420 | |||
421 | int dataLength = buffer.DataLength; | ||
422 | |||
423 | // Keep appending ACKs until there is no room left in the packet or there are | ||
424 | // no more ACKs to append | ||
425 | uint ackCount = 0; | ||
426 | uint ack; | ||
427 | while (dataLength + 5 < buffer.Data.Length && client.PendingAcks.Dequeue(out ack)) | ||
428 | { | ||
429 | Utils.UIntToBytesBig(ack, buffer.Data, dataLength); | ||
430 | dataLength += 4; | ||
431 | ++ackCount; | ||
432 | } | ||
433 | |||
434 | if (ackCount > 0) | ||
435 | { | ||
436 | // Set the last byte of the packet equal to the number of appended ACKs | ||
437 | buffer.Data[dataLength++] = (byte)ackCount; | ||
438 | // Set the appended ACKs flag on this packet | ||
439 | buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS); | ||
440 | } | ||
441 | |||
442 | buffer.DataLength = dataLength; | ||
443 | |||
444 | #endregion ACK Appending | ||
445 | |||
446 | if (!isResend) | ||
361 | { | 447 | { |
362 | if (clientCircuits.TryGetValue(reusedEpSender, out circuit)) | 448 | // Not a resend, assign a new sequence number |
449 | uint sequenceNumber = (uint)Interlocked.Increment(ref client.CurrentSequence); | ||
450 | Utils.UIntToBytesBig(sequenceNumber, buffer.Data, 1); | ||
451 | outgoingPacket.SequenceNumber = sequenceNumber; | ||
452 | |||
453 | if (isReliable) | ||
363 | { | 454 | { |
364 | m_packetServer.CloseCircuit(circuit); | 455 | // Add this packet to the list of ACK responses we are waiting on from the server |
365 | 456 | client.NeedAcks.Add(outgoingPacket); | |
366 | if (e != null) | ||
367 | m_log.ErrorFormat( | ||
368 | "[CLIENT]: Closed circuit {0} {1} due to exception {2}", circuit, reusedEpSender, e); | ||
369 | } | 457 | } |
370 | } | 458 | } |
459 | |||
460 | // Stats tracking | ||
461 | Interlocked.Increment(ref client.PacketsSent); | ||
462 | if (isReliable) | ||
463 | Interlocked.Add(ref client.UnackedBytes, outgoingPacket.Buffer.DataLength); | ||
464 | |||
465 | // Put the UDP payload on the wire | ||
466 | AsyncBeginSend(buffer); | ||
371 | } | 467 | } |
372 | 468 | ||
373 | /// <summary> | 469 | protected override void PacketReceived(UDPPacketBuffer buffer) |
374 | /// Finish the process of asynchronously receiving the next bit of raw data | ||
375 | /// </summary> | ||
376 | /// <param name="numBytes">The number of bytes received. Will return 0 if no bytes were recieved | ||
377 | /// <param name="result"></param> | ||
378 | /// <param name="epSender">The sender of the data</param> | ||
379 | /// <returns></returns> | ||
380 | protected virtual bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender) | ||
381 | { | 470 | { |
382 | bool hasReceivedOkay = false; | 471 | // Debugging/Profiling |
383 | numBytes = 0; | 472 | //try { Thread.CurrentThread.Name = "PacketReceived (" + scene.RegionName + ")"; } |
384 | 473 | //catch (Exception) { } | |
474 | |||
475 | LLUDPClient client = null; | ||
476 | Packet packet = null; | ||
477 | int packetEnd = buffer.DataLength - 1; | ||
478 | IPEndPoint address = (IPEndPoint)buffer.RemoteEndPoint; | ||
479 | |||
480 | #region Decoding | ||
481 | |||
385 | try | 482 | try |
386 | { | 483 | { |
387 | numBytes = m_socket.EndReceiveFrom(result, ref epSender); | 484 | packet = Packet.BuildPacket(buffer.Data, ref packetEnd, |
388 | hasReceivedOkay = true; | 485 | // Only allocate a buffer for zerodecoding if the packet is zerocoded |
486 | ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null); | ||
389 | } | 487 | } |
390 | catch (SocketException e) | 488 | catch (MalformedDataException) |
391 | { | 489 | { |
392 | // TODO : Actually only handle those states that we have control over, re-throw everything else, | 490 | m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse packet:\n{0}", |
393 | // TODO: implement cases as we encounter them. | 491 | Utils.BytesToHexString(buffer.Data, buffer.DataLength, null)); |
394 | //m_log.Error("[CLIENT]: Connection Error! - " + e.ToString()); | 492 | } |
395 | switch (e.SocketErrorCode) | 493 | |
494 | // Fail-safe check | ||
495 | if (packet == null) | ||
496 | { | ||
497 | m_log.Warn("[LLUDPSERVER]: Couldn't build a message from the incoming data"); | ||
498 | return; | ||
499 | } | ||
500 | |||
501 | //Stats.RecvBytes += (ulong)buffer.DataLength; | ||
502 | //++Stats.RecvPackets; | ||
503 | |||
504 | #endregion Decoding | ||
505 | |||
506 | #region UseCircuitCode Handling | ||
507 | |||
508 | if (packet.Type == PacketType.UseCircuitCode) | ||
509 | { | ||
510 | UseCircuitCodePacket useCircuitCode = (UseCircuitCodePacket)packet; | ||
511 | IClientAPI newuser; | ||
512 | uint circuitCode = useCircuitCode.CircuitCode.Code; | ||
513 | |||
514 | // Check if the client is already established | ||
515 | if (!m_scene.ClientManager.TryGetClient(circuitCode, out newuser)) | ||
396 | { | 516 | { |
397 | case SocketError.AlreadyInProgress: | 517 | AddNewClient(useCircuitCode, (IPEndPoint)buffer.RemoteEndPoint); |
398 | return hasReceivedOkay; | 518 | } |
519 | } | ||
520 | |||
521 | // Determine which agent this packet came from | ||
522 | if (!clients.TryGetValue(address, out client)) | ||
523 | { | ||
524 | m_log.Warn("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address); | ||
525 | return; | ||
526 | } | ||
527 | |||
528 | #endregion UseCircuitCode Handling | ||
529 | |||
530 | // Stats tracking | ||
531 | Interlocked.Increment(ref client.PacketsReceived); | ||
399 | 532 | ||
400 | case SocketError.NetworkReset: | 533 | #region ACK Receiving |
401 | case SocketError.ConnectionReset: | ||
402 | case SocketError.OperationAborted: | ||
403 | break; | ||
404 | 534 | ||
405 | default: | 535 | int now = Environment.TickCount; |
406 | throw; | 536 | client.TickLastPacketReceived = now; |
537 | |||
538 | // Handle appended ACKs | ||
539 | if (packet.Header.AppendedAcks && packet.Header.AckList != null) | ||
540 | { | ||
541 | lock (client.NeedAcks.SyncRoot) | ||
542 | { | ||
543 | for (int i = 0; i < packet.Header.AckList.Length; i++) | ||
544 | AcknowledgePacket(client, packet.Header.AckList[i], now, packet.Header.Resent); | ||
407 | } | 545 | } |
408 | } | 546 | } |
409 | catch (ObjectDisposedException e) | 547 | |
548 | // Handle PacketAck packets | ||
549 | if (packet.Type == PacketType.PacketAck) | ||
550 | { | ||
551 | PacketAckPacket ackPacket = (PacketAckPacket)packet; | ||
552 | |||
553 | lock (client.NeedAcks.SyncRoot) | ||
554 | { | ||
555 | for (int i = 0; i < ackPacket.Packets.Length; i++) | ||
556 | AcknowledgePacket(client, ackPacket.Packets[i].ID, now, packet.Header.Resent); | ||
557 | } | ||
558 | } | ||
559 | |||
560 | #endregion ACK Receiving | ||
561 | |||
562 | #region ACK Sending | ||
563 | |||
564 | if (packet.Header.Reliable) | ||
565 | client.PendingAcks.Enqueue((uint)packet.Header.Sequence); | ||
566 | |||
567 | // This is a somewhat odd sequence of steps to pull the client.BytesSinceLastACK value out, | ||
568 | // add the current received bytes to it, test if 2*MTU bytes have been sent, if so remove | ||
569 | // 2*MTU bytes from the value and send ACKs, and finally add the local value back to | ||
570 | // client.BytesSinceLastACK. Lockless thread safety | ||
571 | int bytesSinceLastACK = Interlocked.Exchange(ref client.BytesSinceLastACK, 0); | ||
572 | bytesSinceLastACK += buffer.DataLength; | ||
573 | if (bytesSinceLastACK > Packet.MTU * 2) | ||
574 | { | ||
575 | bytesSinceLastACK -= Packet.MTU * 2; | ||
576 | SendAcks(client); | ||
577 | } | ||
578 | Interlocked.Add(ref client.BytesSinceLastACK, bytesSinceLastACK); | ||
579 | |||
580 | #endregion ACK Sending | ||
581 | |||
582 | #region Incoming Packet Accounting | ||
583 | |||
584 | // Check the archive of received reliable packet IDs to see whether we already received this packet | ||
585 | if (packet.Header.Reliable && !client.PacketArchive.TryEnqueue(packet.Header.Sequence)) | ||
410 | { | 586 | { |
411 | m_log.DebugFormat("[CLIENT]: ObjectDisposedException: Object {0} disposed.", e.ObjectName); | 587 | if (packet.Header.Resent) |
412 | // Uhh, what object, and why? this needs better handling. | 588 | m_log.Debug("[LLUDPSERVER]: Received a resend of already processed packet #" + packet.Header.Sequence + ", type: " + packet.Type); |
589 | else | ||
590 | m_log.Warn("[LLUDPSERVER]: Received a duplicate (not marked as resend) of packet #" + packet.Header.Sequence + ", type: " + packet.Type); | ||
591 | |||
592 | // Avoid firing a callback twice for the same packet | ||
593 | return; | ||
594 | } | ||
595 | |||
596 | #endregion Incoming Packet Accounting | ||
597 | |||
598 | // Don't bother clogging up the queue with PacketAck packets that are already handled here | ||
599 | if (packet.Type != PacketType.PacketAck) | ||
600 | { | ||
601 | // Inbox insertion | ||
602 | packetInbox.Enqueue(new IncomingPacket(client, packet)); | ||
413 | } | 603 | } |
414 | |||
415 | return hasReceivedOkay; | ||
416 | } | 604 | } |
417 | 605 | ||
418 | /// <summary> | 606 | protected override void PacketSent(UDPPacketBuffer buffer, int bytesSent) |
419 | /// Add a new client circuit. | 607 | { |
420 | /// </summary> | 608 | } |
421 | /// <param name="packet"></param> | 609 | |
422 | /// <param name="epSender"></param> | 610 | private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) |
423 | /// <param name="epProxy"></param> | 611 | { |
424 | protected virtual void AddNewClient(UseCircuitCodePacket useCircuit, EndPoint epSender, EndPoint epProxy) | 612 | UUID agentID = useCircuitCode.CircuitCode.ID; |
613 | UUID sessionID = useCircuitCode.CircuitCode.SessionID; | ||
614 | uint circuitCode = useCircuitCode.CircuitCode.Code; | ||
615 | |||
616 | sessionInfo = m_circuitManager.AuthenticateSession(sessionID, agentID, circuitCode); | ||
617 | return sessionInfo.Authorised; | ||
618 | } | ||
619 | |||
620 | private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint) | ||
425 | { | 621 | { |
426 | //Slave regions don't accept new clients | 622 | //Slave regions don't accept new clients |
427 | if (m_localScene.RegionStatus != RegionStatus.SlaveScene) | 623 | if (m_scene.RegionStatus != RegionStatus.SlaveScene) |
428 | { | 624 | { |
429 | AuthenticateResponse sessionInfo; | 625 | AuthenticateResponse sessionInfo; |
430 | bool isNewCircuit = false; | 626 | bool isNewCircuit = !clients.ContainsKey(remoteEndPoint); |
431 | 627 | ||
432 | if (!m_packetServer.IsClientAuthorized(useCircuit, m_circuitManager, out sessionInfo)) | 628 | if (!IsClientAuthorized(useCircuitCode, out sessionInfo)) |
433 | { | 629 | { |
434 | m_log.WarnFormat( | 630 | m_log.WarnFormat( |
435 | "[CONNECTION FAILURE]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", | 631 | "[CONNECTION FAILURE]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", |
436 | useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code, epSender); | 632 | useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint); |
437 | |||
438 | return; | 633 | return; |
439 | } | 634 | } |
440 | |||
441 | lock (clientCircuits) | ||
442 | { | ||
443 | if (!clientCircuits.ContainsKey(epSender)) | ||
444 | { | ||
445 | clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); | ||
446 | isNewCircuit = true; | ||
447 | } | ||
448 | } | ||
449 | 635 | ||
450 | if (isNewCircuit) | 636 | if (isNewCircuit) |
451 | { | 637 | { |
452 | // This doesn't need locking as it's synchronized data | 638 | UUID agentID = useCircuitCode.CircuitCode.ID; |
453 | clientCircuits_reverse[useCircuit.CircuitCode.Code] = epSender; | 639 | UUID sessionID = useCircuitCode.CircuitCode.SessionID; |
640 | uint circuitCode = useCircuitCode.CircuitCode.Code; | ||
454 | 641 | ||
455 | lock (proxyCircuits) | 642 | AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo); |
456 | { | ||
457 | proxyCircuits[useCircuit.CircuitCode.Code] = epProxy; | ||
458 | } | ||
459 | |||
460 | m_packetServer.AddNewClient(epSender, useCircuit, sessionInfo, epProxy); | ||
461 | |||
462 | //m_log.DebugFormat( | ||
463 | // "[CONNECTION SUCCESS]: Incoming client {0} (circuit code {1}) received and authenticated for {2}", | ||
464 | // useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code, m_localScene.RegionInfo.RegionName); | ||
465 | } | 643 | } |
466 | } | 644 | } |
467 | |||
468 | // Ack the UseCircuitCode packet | ||
469 | PacketAckPacket ack_it = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); | ||
470 | // TODO: don't create new blocks if recycling an old packet | ||
471 | ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | ||
472 | ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | ||
473 | ack_it.Packets[0].ID = useCircuit.Header.Sequence; | ||
474 | // ((useCircuit.Header.Sequence < uint.MaxValue) ? useCircuit.Header.Sequence : 0) is just a failsafe to ensure that we don't overflow. | ||
475 | ack_it.Header.Sequence = ((useCircuit.Header.Sequence < uint.MaxValue) ? useCircuit.Header.Sequence : 0) + 1; | ||
476 | ack_it.Header.Reliable = false; | ||
477 | |||
478 | byte[] ackmsg = ack_it.ToBytes(); | ||
479 | |||
480 | // Need some extra space in case we need to add proxy | ||
481 | // information to the message later | ||
482 | byte[] msg = new byte[4096]; | ||
483 | Buffer.BlockCopy(ackmsg, 0, msg, 0, ackmsg.Length); | ||
484 | |||
485 | SendPacketTo(msg, ackmsg.Length, SocketFlags.None, useCircuit.CircuitCode.Code); | ||
486 | |||
487 | PacketPool.Instance.ReturnPacket(useCircuit); | ||
488 | } | 645 | } |
489 | 646 | ||
490 | public void ServerListener() | 647 | private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) |
491 | { | 648 | { |
492 | uint newPort = listenPort; | 649 | // Create the LLUDPClient |
493 | m_log.Info("[UDPSERVER]: Opening UDP socket on " + listenIP + " " + newPort + "."); | 650 | LLUDPClient client = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); |
494 | |||
495 | ServerIncoming = new IPEndPoint(listenIP, (int)newPort); | ||
496 | m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | ||
497 | if (0 != m_clientSocketReceiveBuffer) | ||
498 | m_socket.ReceiveBufferSize = m_clientSocketReceiveBuffer; | ||
499 | m_socket.Bind(ServerIncoming); | ||
500 | // Add flags to the UDP socket to prevent "Socket forcibly closed by host" | ||
501 | // uint IOC_IN = 0x80000000; | ||
502 | // uint IOC_VENDOR = 0x18000000; | ||
503 | // uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; | ||
504 | // TODO: this apparently works in .NET but not in Mono, need to sort out the right flags here. | ||
505 | // m_socket.IOControl((int)SIO_UDP_CONNRESET, new byte[] { Convert.ToByte(false) }, null); | ||
506 | 651 | ||
507 | listenPort = newPort; | 652 | // Create the LLClientView |
653 | LLClientView clientApi = new LLClientView(remoteEndPoint, m_scene, this, client, sessionInfo, agentID, sessionID, circuitCode); | ||
654 | clientApi.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; | ||
655 | clientApi.OnLogout += LogoutHandler; | ||
656 | clientApi.OnConnectionClosed += RemoveClient; | ||
508 | 657 | ||
509 | m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen"); | 658 | // Start the IClientAPI |
659 | m_scene.ClientManager.Add(circuitCode, clientApi); | ||
660 | clientApi.Start(); | ||
510 | 661 | ||
511 | ReceivedData = OnReceivedData; | 662 | // Give LLUDPClient a reference to IClientAPI |
512 | BeginReceive(); | 663 | client.ClientAPI = clientApi; |
513 | 664 | ||
514 | m_log.Info("[UDPSERVER]: Listening on port " + newPort); | 665 | // Add the new client to our list of tracked clients |
666 | clients.Add(agentID, client.RemoteEndPoint, client); | ||
515 | } | 667 | } |
516 | 668 | ||
517 | public virtual void RegisterPacketServer(LLPacketServer server) | 669 | private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend) |
518 | { | 670 | { |
519 | m_packetServer = server; | 671 | OutgoingPacket ackedPacket; |
672 | if (client.NeedAcks.RemoveUnsafe(ack, out ackedPacket) && !fromResend) | ||
673 | { | ||
674 | // Update stats | ||
675 | Interlocked.Add(ref client.UnackedBytes, -ackedPacket.Buffer.DataLength); | ||
676 | |||
677 | // Calculate the round-trip time for this packet and its ACK | ||
678 | int rtt = currentTime - ackedPacket.TickCount; | ||
679 | if (rtt > 0) | ||
680 | client.UpdateRoundTrip(rtt); | ||
681 | } | ||
520 | } | 682 | } |
521 | 683 | ||
522 | public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) | 684 | private void IncomingPacketHandler() |
523 | //EndPoint packetSender) | ||
524 | { | 685 | { |
525 | // find the endpoint for this circuit | 686 | // Set this culture for the thread that incoming packets are received |
526 | EndPoint sendto; | 687 | // on to en-US to avoid number parsing issues |
527 | try | 688 | Culture.SetCurrentCulture(); |
528 | { | ||
529 | sendto = (EndPoint)clientCircuits_reverse[circuitcode]; | ||
530 | } | ||
531 | catch | ||
532 | { | ||
533 | // Exceptions here mean there is no circuit | ||
534 | m_log.Warn("[CLIENT]: Circuit not found, not sending packet"); | ||
535 | return; | ||
536 | } | ||
537 | 689 | ||
538 | if (sendto != null) | 690 | IncomingPacket incomingPacket = null; |
691 | |||
692 | while (base.IsRunning) | ||
539 | { | 693 | { |
540 | //we found the endpoint so send the packet to it | 694 | if (packetInbox.Dequeue(100, ref incomingPacket)) |
541 | if (proxyPortOffset != 0) | 695 | Util.FireAndForget(ProcessInPacket, incomingPacket); |
542 | { | ||
543 | //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString()); | ||
544 | ProxyCodec.EncodeProxyMessage(buffer, ref size, sendto); | ||
545 | m_socket.SendTo(buffer, size, flags, proxyCircuits[circuitcode]); | ||
546 | } | ||
547 | else | ||
548 | { | ||
549 | //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo : client " + sendto.ToString()); | ||
550 | try | ||
551 | { | ||
552 | m_socket.SendTo(buffer, size, flags, sendto); | ||
553 | } | ||
554 | catch (SocketException SockE) | ||
555 | { | ||
556 | m_log.ErrorFormat("[UDPSERVER]: Caught Socket Error in the send buffer!. {0}",SockE.ToString()); | ||
557 | } | ||
558 | } | ||
559 | } | 696 | } |
697 | |||
698 | if (packetInbox.Count > 0) | ||
699 | m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets"); | ||
700 | packetInbox.Clear(); | ||
560 | } | 701 | } |
561 | 702 | ||
562 | public virtual void RemoveClientCircuit(uint circuitcode) | 703 | private void OutgoingPacketHandler() |
563 | { | 704 | { |
564 | EndPoint sendto; | 705 | // Set this culture for the thread that outgoing packets are sent |
565 | if (clientCircuits_reverse.Contains(circuitcode)) | 706 | // on to en-US to avoid number parsing issues |
707 | Culture.SetCurrentCulture(); | ||
708 | |||
709 | int now = Environment.TickCount; | ||
710 | int elapsedMS = 0; | ||
711 | int elapsed100MS = 0; | ||
712 | int elapsed500MS = 0; | ||
713 | |||
714 | while (base.IsRunning) | ||
566 | { | 715 | { |
567 | sendto = (EndPoint)clientCircuits_reverse[circuitcode]; | 716 | bool resendUnacked = false; |
717 | bool sendAcks = false; | ||
718 | bool sendPings = false; | ||
719 | bool packetSent = false; | ||
568 | 720 | ||
569 | clientCircuits_reverse.Remove(circuitcode); | 721 | elapsedMS += Environment.TickCount - now; |
570 | 722 | ||
571 | lock (clientCircuits) | 723 | // Check for pending outgoing resends every 100ms |
724 | if (elapsedMS >= 100) | ||
572 | { | 725 | { |
573 | if (sendto != null) | 726 | resendUnacked = true; |
574 | { | 727 | elapsedMS -= 100; |
575 | clientCircuits.Remove(sendto); | 728 | ++elapsed100MS; |
576 | } | ||
577 | else | ||
578 | { | ||
579 | m_log.DebugFormat( | ||
580 | "[CLIENT]: endpoint for circuit code {0} in RemoveClientCircuit() was unexpectedly null!", circuitcode); | ||
581 | } | ||
582 | } | 729 | } |
583 | lock (proxyCircuits) | 730 | // Check for pending outgoing ACKs every 500ms |
731 | if (elapsed100MS >= 5) | ||
584 | { | 732 | { |
585 | proxyCircuits.Remove(circuitcode); | 733 | sendAcks = true; |
734 | elapsed100MS = 0; | ||
735 | ++elapsed500MS; | ||
586 | } | 736 | } |
737 | // Send pings to clients every 5000ms | ||
738 | if (elapsed500MS >= 10) | ||
739 | { | ||
740 | sendPings = true; | ||
741 | elapsed500MS = 0; | ||
742 | } | ||
743 | |||
744 | clients.ForEach( | ||
745 | delegate(LLUDPClient client) | ||
746 | { | ||
747 | if (client.DequeueOutgoing()) | ||
748 | packetSent = true; | ||
749 | if (resendUnacked) | ||
750 | ResendUnacked(client); | ||
751 | if (sendAcks) | ||
752 | { | ||
753 | SendAcks(client); | ||
754 | client.SendPacketStats(); | ||
755 | } | ||
756 | if (sendPings) | ||
757 | SendPing(client); | ||
758 | } | ||
759 | ); | ||
760 | |||
761 | if (!packetSent) | ||
762 | Thread.Sleep(20); | ||
587 | } | 763 | } |
588 | } | 764 | } |
589 | 765 | ||
590 | public void RestoreClient(AgentCircuitData circuit, EndPoint userEP, EndPoint proxyEP) | 766 | private void ProcessInPacket(object state) |
591 | { | 767 | { |
592 | //MainLog.Instance.Verbose("UDPSERVER", "RestoreClient"); | 768 | IncomingPacket incomingPacket = (IncomingPacket)state; |
769 | Packet packet = incomingPacket.Packet; | ||
770 | LLUDPClient client = incomingPacket.Client; | ||
593 | 771 | ||
594 | UseCircuitCodePacket useCircuit = new UseCircuitCodePacket(); | 772 | // Sanity check |
595 | useCircuit.CircuitCode.Code = circuit.circuitcode; | 773 | if (packet == null || client == null || client.ClientAPI == null) |
596 | useCircuit.CircuitCode.ID = circuit.AgentID; | ||
597 | useCircuit.CircuitCode.SessionID = circuit.SessionID; | ||
598 | |||
599 | AuthenticateResponse sessionInfo; | ||
600 | |||
601 | if (!m_packetServer.IsClientAuthorized(useCircuit, m_circuitManager, out sessionInfo)) | ||
602 | { | 774 | { |
603 | m_log.WarnFormat( | 775 | m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", Client=\"{1}\", Client.ClientAPI=\"{2}\"", |
604 | "[CLIENT]: Restore request denied to avatar {0} connecting with unauthorized circuit code {1}", | 776 | packet, client, (client != null) ? client.ClientAPI : null); |
605 | useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code); | ||
606 | |||
607 | return; | ||
608 | } | 777 | } |
609 | 778 | ||
610 | lock (clientCircuits) | 779 | try |
611 | { | 780 | { |
612 | if (!clientCircuits.ContainsKey(userEP)) | 781 | // Process this packet |
613 | clientCircuits.Add(userEP, useCircuit.CircuitCode.Code); | 782 | client.ClientAPI.ProcessInPacket(packet); |
614 | else | ||
615 | m_log.Error("[CLIENT]: clientCircuits already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); | ||
616 | } | 783 | } |
617 | 784 | catch (ThreadAbortException) | |
618 | // This data structure is synchronized, so we don't need the lock | ||
619 | if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) | ||
620 | clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP); | ||
621 | else | ||
622 | m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); | ||
623 | |||
624 | lock (proxyCircuits) | ||
625 | { | 785 | { |
626 | if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) | 786 | // If something is trying to abort the packet processing thread, take that as a hint that it's time to shut down |
627 | { | 787 | m_log.Info("[LLUDPSERVER]: Caught a thread abort, shutting down the LLUDP server"); |
628 | proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP); | 788 | Stop(); |
629 | } | ||
630 | else | ||
631 | { | ||
632 | // re-set proxy endpoint | ||
633 | proxyCircuits.Remove(useCircuit.CircuitCode.Code); | ||
634 | proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP); | ||
635 | } | ||
636 | } | 789 | } |
790 | catch (Exception e) | ||
791 | { | ||
792 | // Don't let a failure in an individual client thread crash the whole sim. | ||
793 | m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", client.AgentID, packet.Type); | ||
794 | m_log.Error(e.Message, e); | ||
795 | } | ||
796 | } | ||
637 | 797 | ||
638 | m_packetServer.AddNewClient(userEP, useCircuit, sessionInfo, proxyEP); | 798 | private void LogoutHandler(IClientAPI client) |
799 | { | ||
800 | client.SendLogoutPacket(); | ||
801 | RemoveClient(client); | ||
639 | } | 802 | } |
640 | } | 803 | } |
641 | } | 804 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUtil.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs index c45d11f..1a1a1cb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUtil.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -25,27 +25,46 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using OpenSim.Framework; | ||
28 | using OpenMetaverse; | 30 | using OpenMetaverse; |
29 | 31 | ||
30 | namespace OpenSim.Region.ClientStack.LindenUDP | 32 | namespace OpenSim.Region.ClientStack.LindenUDP |
31 | { | 33 | { |
32 | public class LLUtil | 34 | /// <summary> |
35 | /// Holds a reference to the <seealso cref="LLUDPClient"/> this packet is | ||
36 | /// destined for, along with the serialized packet data, sequence number | ||
37 | /// (if this is a resend), number of times this packet has been resent, | ||
38 | /// the time of the last resend, and the throttling category for this | ||
39 | /// packet | ||
40 | /// </summary> | ||
41 | public sealed class OutgoingPacket | ||
33 | { | 42 | { |
43 | /// <summary>Client this packet is destined for</summary> | ||
44 | public LLUDPClient Client; | ||
45 | /// <summary>Packet data to send</summary> | ||
46 | public UDPPacketBuffer Buffer; | ||
47 | /// <summary>Sequence number of the wrapped packet</summary> | ||
48 | public uint SequenceNumber; | ||
49 | /// <summary>Number of times this packet has been resent</summary> | ||
50 | public int ResendCount; | ||
51 | /// <summary>Environment.TickCount when this packet was last sent over the wire</summary> | ||
52 | public int TickCount; | ||
53 | /// <summary>Category this packet belongs to</summary> | ||
54 | public ThrottleOutPacketType Category; | ||
55 | |||
34 | /// <summary> | 56 | /// <summary> |
35 | /// Convert a string to bytes suitable for use in an LL UDP packet. | 57 | /// Default constructor |
36 | /// </summary> | 58 | /// </summary> |
37 | /// <param name="s">Truncated to 254 characters if necessary</param> | 59 | /// <param name="client">Reference to the client this packet is destined for</param> |
38 | /// <returns></returns> | 60 | /// <param name="buffer">Serialized packet data. If the flags or sequence number |
39 | public static byte[] StringToPacketBytes(string s) | 61 | /// need to be updated, they will be injected directly into this binary buffer</param> |
62 | /// <param name="category">Throttling category for this packet</param> | ||
63 | public OutgoingPacket(LLUDPClient client, UDPPacketBuffer buffer, ThrottleOutPacketType category) | ||
40 | { | 64 | { |
41 | // Anything more than 254 will cause libsecondlife to barf | 65 | Client = client; |
42 | // (libsl 1550) adds an \0 on the Utils.StringToBytes conversion if it isn't present | 66 | Buffer = buffer; |
43 | if (s.Length > 254) | 67 | Category = category; |
44 | { | ||
45 | s = s.Remove(254); | ||
46 | } | ||
47 | |||
48 | return Utils.StringToBytes(s); | ||
49 | } | 68 | } |
50 | } | 69 | } |
51 | } | 70 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs index cde155b..7d0757f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
70 | 70 | ||
71 | TestClient testClient = new TestClient(agent, scene); | 71 | TestClient testClient = new TestClient(agent, scene); |
72 | 72 | ||
73 | ILLPacketHandler packetHandler | 73 | LLPacketHandler packetHandler |
74 | = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings()); | 74 | = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings()); |
75 | 75 | ||
76 | packetHandler.InPacket(new AgentAnimationPacket()); | 76 | packetHandler.InPacket(new AgentAnimationPacket()); |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs index 1fba847..e995d65 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs | |||
@@ -37,7 +37,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
37 | /// </summary> | 37 | /// </summary> |
38 | protected Dictionary<PacketType, int> m_packetsReceived = new Dictionary<PacketType, int>(); | 38 | protected Dictionary<PacketType, int> m_packetsReceived = new Dictionary<PacketType, int>(); |
39 | 39 | ||
40 | public TestLLPacketServer(ILLClientStackNetworkHandler networkHandler, ClientStackUserSettings userSettings) | 40 | public TestLLPacketServer(LLUDPServer networkHandler, ClientStackUserSettings userSettings) |
41 | : base(networkHandler, userSettings) | 41 | : base(networkHandler, userSettings) |
42 | {} | 42 | {} |
43 | 43 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs new file mode 100644 index 0000000..858a03c --- /dev/null +++ b/OpenSim/Region/ClientStack/LindenUDP/ThrottleRates.cs | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | |||
31 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
32 | { | ||
33 | /// <summary> | ||
34 | /// Holds drip rates and maximum burst rates for throttling with hierarchical | ||
35 | /// token buckets. The maximum burst rates set here are hard limits and can | ||
36 | /// not be overridden by client requests | ||
37 | /// </summary> | ||
38 | public sealed class ThrottleRates | ||
39 | { | ||
40 | /// <summary>Drip rate for resent packets</summary> | ||
41 | public int Resend; | ||
42 | /// <summary>Drip rate for terrain packets</summary> | ||
43 | public int Land; | ||
44 | /// <summary>Drip rate for wind packets</summary> | ||
45 | public int Wind; | ||
46 | /// <summary>Drip rate for cloud packets</summary> | ||
47 | public int Cloud; | ||
48 | /// <summary>Drip rate for task (state and transaction) packets</summary> | ||
49 | public int Task; | ||
50 | /// <summary>Drip rate for texture packets</summary> | ||
51 | public int Texture; | ||
52 | /// <summary>Drip rate for asset packets</summary> | ||
53 | public int Asset; | ||
54 | |||
55 | /// <summary>Maximum burst rate for resent packets</summary> | ||
56 | public int ResendLimit; | ||
57 | /// <summary>Maximum burst rate for land packets</summary> | ||
58 | public int LandLimit; | ||
59 | /// <summary>Maximum burst rate for wind packets</summary> | ||
60 | public int WindLimit; | ||
61 | /// <summary>Maximum burst rate for cloud packets</summary> | ||
62 | public int CloudLimit; | ||
63 | /// <summary>Maximum burst rate for task (state and transaction) packets</summary> | ||
64 | public int TaskLimit; | ||
65 | /// <summary>Maximum burst rate for texture packets</summary> | ||
66 | public int TextureLimit; | ||
67 | /// <summary>Maximum burst rate for asset packets</summary> | ||
68 | public int AssetLimit; | ||
69 | |||
70 | /// <summary> | ||
71 | /// Default constructor | ||
72 | /// </summary> | ||
73 | /// <param name="config">Config source to load defaults from</param> | ||
74 | public ThrottleRates(IConfigSource config) | ||
75 | { | ||
76 | try | ||
77 | { | ||
78 | IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"]; | ||
79 | |||
80 | Resend = throttleConfig.GetInt("ResendDefault", 12500); | ||
81 | Land = throttleConfig.GetInt("LandDefault", 500); | ||
82 | Wind = throttleConfig.GetInt("WindDefault", 500); | ||
83 | Cloud = throttleConfig.GetInt("CloudDefault", 500); | ||
84 | Task = throttleConfig.GetInt("TaskDefault", 500); | ||
85 | Texture = throttleConfig.GetInt("TextureDefault", 500); | ||
86 | Asset = throttleConfig.GetInt("AssetDefault", 500); | ||
87 | |||
88 | ResendLimit = throttleConfig.GetInt("ResendLimit", 18750); | ||
89 | LandLimit = throttleConfig.GetInt("LandLimit", 29750); | ||
90 | WindLimit = throttleConfig.GetInt("WindLimit", 18750); | ||
91 | CloudLimit = throttleConfig.GetInt("CloudLimit", 18750); | ||
92 | TaskLimit = throttleConfig.GetInt("TaskLimit", 55750); | ||
93 | TextureLimit = throttleConfig.GetInt("TextureLimit", 55750); | ||
94 | AssetLimit = throttleConfig.GetInt("AssetLimit", 27500); | ||
95 | } | ||
96 | catch (Exception) { } | ||
97 | } | ||
98 | } | ||
99 | } | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs new file mode 100644 index 0000000..195ca57 --- /dev/null +++ b/OpenSim/Region/ClientStack/LindenUDP/UnackedPacketCollection.cs | |||
@@ -0,0 +1,160 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Special collection that is optimized for tracking unacknowledged packets | ||
37 | /// </summary> | ||
38 | public sealed class UnackedPacketCollection | ||
39 | { | ||
40 | /// <summary>Synchronization primitive. A lock must be acquired on this | ||
41 | /// object before calling any of the unsafe methods</summary> | ||
42 | public object SyncRoot = new object(); | ||
43 | |||
44 | /// <summary>Holds the actual unacked packet data, sorted by sequence number</summary> | ||
45 | private SortedDictionary<uint, OutgoingPacket> packets = new SortedDictionary<uint, OutgoingPacket>(); | ||
46 | |||
47 | /// <summary>Gets the total number of unacked packets</summary> | ||
48 | public int Count { get { return packets.Count; } } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Default constructor | ||
52 | /// </summary> | ||
53 | public UnackedPacketCollection() | ||
54 | { | ||
55 | } | ||
56 | |||
57 | /// <summary> | ||
58 | /// Add an unacked packet to the collection | ||
59 | /// </summary> | ||
60 | /// <param name="packet">Packet that is awaiting acknowledgement</param> | ||
61 | /// <returns>True if the packet was successfully added, false if the | ||
62 | /// packet already existed in the collection</returns> | ||
63 | public bool Add(OutgoingPacket packet) | ||
64 | { | ||
65 | lock (SyncRoot) | ||
66 | { | ||
67 | if (!packets.ContainsKey(packet.SequenceNumber)) | ||
68 | { | ||
69 | packets.Add(packet.SequenceNumber, packet); | ||
70 | return true; | ||
71 | } | ||
72 | return false; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Removes a packet from the collection without attempting to obtain a | ||
78 | /// lock first | ||
79 | /// </summary> | ||
80 | /// <param name="sequenceNumber">Sequence number of the packet to remove</param> | ||
81 | /// <returns>True if the packet was found and removed, otherwise false</returns> | ||
82 | public bool RemoveUnsafe(uint sequenceNumber) | ||
83 | { | ||
84 | return packets.Remove(sequenceNumber); | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Removes a packet from the collection without attempting to obtain a | ||
89 | /// lock first | ||
90 | /// </summary> | ||
91 | /// <param name="sequenceNumber">Sequence number of the packet to remove</param> | ||
92 | /// <param name="packet">Returns the removed packet</param> | ||
93 | /// <returns>True if the packet was found and removed, otherwise false</returns> | ||
94 | public bool RemoveUnsafe(uint sequenceNumber, out OutgoingPacket packet) | ||
95 | { | ||
96 | if (packets.TryGetValue(sequenceNumber, out packet)) | ||
97 | { | ||
98 | packets.Remove(sequenceNumber); | ||
99 | return true; | ||
100 | } | ||
101 | |||
102 | return false; | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Gets the packet with the lowest sequence number | ||
107 | /// </summary> | ||
108 | /// <returns>The packet with the lowest sequence number, or null if the | ||
109 | /// collection is empty</returns> | ||
110 | public OutgoingPacket GetOldest() | ||
111 | { | ||
112 | lock (SyncRoot) | ||
113 | { | ||
114 | using (SortedDictionary<uint, OutgoingPacket>.ValueCollection.Enumerator e = packets.Values.GetEnumerator()) | ||
115 | { | ||
116 | if (e.MoveNext()) | ||
117 | return e.Current; | ||
118 | else | ||
119 | return null; | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | /// <summary> | ||
125 | /// Returns a list of all of the packets with a TickCount older than | ||
126 | /// the specified timeout | ||
127 | /// </summary> | ||
128 | /// <param name="timeoutMS">Number of ticks (milliseconds) before a | ||
129 | /// packet is considered expired</param> | ||
130 | /// <returns>A list of all expired packets according to the given | ||
131 | /// expiration timeout</returns> | ||
132 | public List<OutgoingPacket> GetExpiredPackets(int timeoutMS) | ||
133 | { | ||
134 | List<OutgoingPacket> expiredPackets = null; | ||
135 | |||
136 | lock (SyncRoot) | ||
137 | { | ||
138 | int now = Environment.TickCount; | ||
139 | foreach (OutgoingPacket packet in packets.Values) | ||
140 | { | ||
141 | if (packet.TickCount == 0) | ||
142 | continue; | ||
143 | |||
144 | if (now - packet.TickCount >= timeoutMS) | ||
145 | { | ||
146 | if (expiredPackets == null) | ||
147 | expiredPackets = new List<OutgoingPacket>(); | ||
148 | expiredPackets.Add(packet); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | break; | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | |||
157 | return expiredPackets; | ||
158 | } | ||
159 | } | ||
160 | } | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 45e724d..d78931a 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -323,7 +323,6 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
323 | httpThread.IsBackground = true; | 323 | httpThread.IsBackground = true; |
324 | _finished = false; | 324 | _finished = false; |
325 | httpThread.Start(); | 325 | httpThread.Start(); |
326 | ThreadTracker.Add(httpThread); | ||
327 | } | 326 | } |
328 | 327 | ||
329 | /* | 328 | /* |
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index 8a169f8..97899a7 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | |||
@@ -639,7 +639,6 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC | |||
639 | httpThread.IsBackground = true; | 639 | httpThread.IsBackground = true; |
640 | _finished = false; | 640 | _finished = false; |
641 | httpThread.Start(); | 641 | httpThread.Start(); |
642 | ThreadTracker.Add(httpThread); | ||
643 | } | 642 | } |
644 | 643 | ||
645 | /* | 644 | /* |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index bb9a4b2..879cc70 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset | |||
98 | 98 | ||
99 | m_log.Info("[RegionAssetService]: Starting..."); | 99 | m_log.Info("[RegionAssetService]: Starting..."); |
100 | 100 | ||
101 | Object[] args = new Object[] { m_Config, MainServer.Instance }; | 101 | Object[] args = new Object[] { m_Config, MainServer.Instance, string.Empty }; |
102 | 102 | ||
103 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); | 103 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); |
104 | } | 104 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index c326818..54c6d89 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory | |||
98 | 98 | ||
99 | m_log.Info("[RegionInventoryService]: Starting..."); | 99 | m_log.Info("[RegionInventoryService]: Starting..."); |
100 | 100 | ||
101 | Object[] args = new Object[] { m_Config, MainServer.Instance }; | 101 | Object[] args = new Object[] { m_Config, MainServer.Instance, String.Empty }; |
102 | 102 | ||
103 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:InventoryServiceInConnector", args); | 103 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:InventoryServiceInConnector", args); |
104 | } | 104 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs index 44e850b..6c89ac8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs | |||
@@ -61,6 +61,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
61 | 61 | ||
62 | private void OnRegionUp(GridRegion otherRegion) | 62 | private void OnRegionUp(GridRegion otherRegion) |
63 | { | 63 | { |
64 | // This shouldn't happen | ||
65 | if (otherRegion == null) | ||
66 | return; | ||
67 | |||
64 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", | 68 | m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", |
65 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); | 69 | m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); |
66 | 70 | ||
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 05ed70a..4fb4c51 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -345,7 +345,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
345 | mapItemReqThread.Priority = ThreadPriority.BelowNormal; | 345 | mapItemReqThread.Priority = ThreadPriority.BelowNormal; |
346 | mapItemReqThread.SetApartmentState(ApartmentState.MTA); | 346 | mapItemReqThread.SetApartmentState(ApartmentState.MTA); |
347 | mapItemReqThread.Start(); | 347 | mapItemReqThread.Start(); |
348 | ThreadTracker.Add(mapItemReqThread); | ||
349 | } | 348 | } |
350 | 349 | ||
351 | /// <summary> | 350 | /// <summary> |
@@ -447,7 +446,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
447 | // end gracefully | 446 | // end gracefully |
448 | if (st.agentID == UUID.Zero) | 447 | if (st.agentID == UUID.Zero) |
449 | { | 448 | { |
450 | ThreadTracker.Remove(mapItemReqThread); | ||
451 | break; | 449 | break; |
452 | } | 450 | } |
453 | 451 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 41141e0..9f7083f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1168,6 +1168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1168 | 1168 | ||
1169 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) | 1169 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) |
1170 | { | 1170 | { |
1171 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | ||
1171 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1172 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1172 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems); | 1173 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems); |
1173 | } | 1174 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index e561efb..4ae4dc3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -477,9 +477,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
477 | public InventoryCollection HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, | 477 | public InventoryCollection HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, |
478 | bool fetchFolders, bool fetchItems, int sortOrder, out int version) | 478 | bool fetchFolders, bool fetchItems, int sortOrder, out int version) |
479 | { | 479 | { |
480 | // m_log.DebugFormat( | 480 | m_log.DebugFormat( |
481 | // "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", | 481 | "[INVENTORY CACHE]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", |
482 | // fetchFolders, fetchItems, folderID, agentID); | 482 | fetchFolders, fetchItems, folderID, agentID); |
483 | 483 | ||
484 | // FIXME MAYBE: We're not handling sortOrder! | 484 | // FIXME MAYBE: We're not handling sortOrder! |
485 | 485 | ||
@@ -497,10 +497,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | return ret; | 497 | return ret; |
498 | } | 498 | } |
499 | 499 | ||
500 | InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID); | 500 | InventoryCollection contents = new InventoryCollection(); |
501 | 501 | ||
502 | if (folderID != UUID.Zero) | 502 | if (folderID != UUID.Zero) |
503 | { | 503 | { |
504 | contents = InventoryService.GetFolderContent(agentID, folderID); | ||
504 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 505 | InventoryFolderBase containingFolder = new InventoryFolderBase(); |
505 | containingFolder.ID = folderID; | 506 | containingFolder.ID = folderID; |
506 | containingFolder.Owner = agentID; | 507 | containingFolder.Owner = agentID; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9418e3d..9630236 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -903,7 +903,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
903 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 903 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
904 | if (HeartbeatThread != null) | 904 | if (HeartbeatThread != null) |
905 | { | 905 | { |
906 | ThreadTracker.Remove(HeartbeatThread); | ||
907 | HeartbeatThread.Abort(); | 906 | HeartbeatThread.Abort(); |
908 | HeartbeatThread = null; | 907 | HeartbeatThread = null; |
909 | } | 908 | } |
@@ -912,7 +911,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
912 | HeartbeatThread.SetApartmentState(ApartmentState.MTA); | 911 | HeartbeatThread.SetApartmentState(ApartmentState.MTA); |
913 | HeartbeatThread.Name = string.Format("Heartbeat for region {0}", RegionInfo.RegionName); | 912 | HeartbeatThread.Name = string.Format("Heartbeat for region {0}", RegionInfo.RegionName); |
914 | HeartbeatThread.Priority = ThreadPriority.AboveNormal; | 913 | HeartbeatThread.Priority = ThreadPriority.AboveNormal; |
915 | ThreadTracker.Add(HeartbeatThread); | ||
916 | HeartbeatThread.Start(); | 914 | HeartbeatThread.Start(); |
917 | } | 915 | } |
918 | 916 | ||
@@ -1448,6 +1446,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1448 | m_log.Info("[SCENE]: Loading objects from datastore"); | 1446 | m_log.Info("[SCENE]: Loading objects from datastore"); |
1449 | 1447 | ||
1450 | List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID); | 1448 | List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID); |
1449 | |||
1450 | m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count + " objects from the datastore"); | ||
1451 | |||
1451 | foreach (SceneObjectGroup group in PrimsFromDB) | 1452 | foreach (SceneObjectGroup group in PrimsFromDB) |
1452 | { | 1453 | { |
1453 | if (group.RootPart == null) | 1454 | if (group.RootPart == null) |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs index 9273fb5..cd401a6 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs | |||
@@ -360,7 +360,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat | |||
360 | m_listener.Name = "IRCConnectorListenerThread"; | 360 | m_listener.Name = "IRCConnectorListenerThread"; |
361 | m_listener.IsBackground = true; | 361 | m_listener.IsBackground = true; |
362 | m_listener.Start(); | 362 | m_listener.Start(); |
363 | ThreadTracker.Add(m_listener); | ||
364 | 363 | ||
365 | // This is the message order recommended by RFC 2812 | 364 | // This is the message order recommended by RFC 2812 |
366 | if (m_password != null) | 365 | if (m_password != null) |
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs index 7202601..16fe9e9 100644 --- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs +++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs | |||
@@ -152,7 +152,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement | |||
152 | m_thread.Name = "Content Management"; | 152 | m_thread.Name = "Content Management"; |
153 | m_thread.IsBackground = true; | 153 | m_thread.IsBackground = true; |
154 | m_thread.Start(); | 154 | m_thread.Start(); |
155 | ThreadTracker.Add(m_thread); | ||
156 | m_state = State.NONE; | 155 | m_state = State.NONE; |
157 | } | 156 | } |
158 | } | 157 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs index 0feb967..583d2ff 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs | |||
@@ -138,7 +138,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
138 | EventQueueThread.Priority = MyThreadPriority; | 138 | EventQueueThread.Priority = MyThreadPriority; |
139 | EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount; | 139 | EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount; |
140 | EventQueueThread.Start(); | 140 | EventQueueThread.Start(); |
141 | ThreadTracker.Add(EventQueueThread); | ||
142 | 141 | ||
143 | // Look at this... Don't you wish everyone did that solid | 142 | // Look at this... Don't you wish everyone did that solid |
144 | // coding everywhere? :P | 143 | // coding everywhere? :P |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs index 8bafe77..7ffdb1a 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs | |||
@@ -97,7 +97,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
97 | MaintenanceThreadThread.Name = "ScriptMaintenanceThread"; | 97 | MaintenanceThreadThread.Name = "ScriptMaintenanceThread"; |
98 | MaintenanceThreadThread.IsBackground = true; | 98 | MaintenanceThreadThread.IsBackground = true; |
99 | MaintenanceThreadThread.Start(); | 99 | MaintenanceThreadThread.Start(); |
100 | ThreadTracker.Add(MaintenanceThreadThread); | ||
101 | } | 100 | } |
102 | } | 101 | } |
103 | 102 | ||
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs index 3c91b29..9806218 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs | |||
@@ -129,10 +129,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
129 | 129 | ||
130 | public void AddRegion(Scene Sceneworld) | 130 | public void AddRegion(Scene Sceneworld) |
131 | { | 131 | { |
132 | m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing"); | ||
133 | |||
134 | m_Scene = Sceneworld; | ||
135 | |||
136 | // Make sure we have config | 132 | // Make sure we have config |
137 | if (ConfigSource.Configs[ScriptEngineName] == null) | 133 | if (ConfigSource.Configs[ScriptEngineName] == null) |
138 | ConfigSource.AddConfig(ScriptEngineName); | 134 | ConfigSource.AddConfig(ScriptEngineName); |
@@ -143,6 +139,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
143 | if (!m_enabled) | 139 | if (!m_enabled) |
144 | return; | 140 | return; |
145 | 141 | ||
142 | m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing"); | ||
143 | |||
144 | m_Scene = Sceneworld; | ||
145 | |||
146 | // Create all objects we'll be using | 146 | // Create all objects we'll be using |
147 | m_EventQueueManager = new EventQueueManager(this); | 147 | m_EventQueueManager = new EventQueueManager(this); |
148 | m_EventManager = new EventManager(this, true); | 148 | m_EventManager = new EventManager(this, true); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index e454524..1607d34 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -142,7 +142,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
142 | cmdHandlerThread.Priority = ThreadPriority.BelowNormal; | 142 | cmdHandlerThread.Priority = ThreadPriority.BelowNormal; |
143 | cmdHandlerThread.IsBackground = true; | 143 | cmdHandlerThread.IsBackground = true; |
144 | cmdHandlerThread.Start(); | 144 | cmdHandlerThread.Start(); |
145 | ThreadTracker.Add(cmdHandlerThread); | ||
146 | } | 145 | } |
147 | } | 146 | } |
148 | 147 | ||
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 9d9735e..0964caa 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -260,7 +260,7 @@ namespace OpenSim.Server.Base | |||
260 | 260 | ||
261 | public static Dictionary<string, object> ParseXmlResponse(string data) | 261 | public static Dictionary<string, object> ParseXmlResponse(string data) |
262 | { | 262 | { |
263 | m_log.DebugFormat("[XXX]: received xml string: {0}", data); | 263 | //m_log.DebugFormat("[XXX]: received xml string: {0}", data); |
264 | 264 | ||
265 | Dictionary<string, object> ret = new Dictionary<string, object>(); | 265 | Dictionary<string, object> ret = new Dictionary<string, object>(); |
266 | 266 | ||
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs index ca45263..3c92209 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs | |||
@@ -77,6 +77,7 @@ namespace OpenSim.Server.Handlers.Inventory | |||
77 | m_doLookup = serverConfig.GetBoolean("SessionAuthentication", false); | 77 | m_doLookup = serverConfig.GetBoolean("SessionAuthentication", false); |
78 | 78 | ||
79 | AddHttpHandlers(server); | 79 | AddHttpHandlers(server); |
80 | m_log.Debug("[INVENTORY HANDLER]: handlers initialized"); | ||
80 | } | 81 | } |
81 | 82 | ||
82 | protected virtual void AddHttpHandlers(IHttpServer m_httpServer) | 83 | protected virtual void AddHttpHandlers(IHttpServer m_httpServer) |
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs index acdf558..02f2b79 100644 --- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs | |||
@@ -99,7 +99,7 @@ namespace OpenSim.Services.Connectors | |||
99 | sendData["METHOD"] = "register"; | 99 | sendData["METHOD"] = "register"; |
100 | 100 | ||
101 | string reqString = ServerUtils.BuildQueryString(sendData); | 101 | string reqString = ServerUtils.BuildQueryString(sendData); |
102 | //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); | 102 | // m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString); |
103 | try | 103 | try |
104 | { | 104 | { |
105 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | 105 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", |
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5443891..e047f71 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs | |||
@@ -416,13 +416,6 @@ namespace OpenSim.Services.Connectors | |||
416 | e.Source, e.Message); | 416 | e.Source, e.Message); |
417 | } | 417 | } |
418 | 418 | ||
419 | foreach (InventoryItemBase item in items) | ||
420 | { | ||
421 | InventoryItemBase itm = this.QueryItem(userID, item, sessionID); | ||
422 | itm.Name = item.Name; | ||
423 | itm.Folder = item.Folder; | ||
424 | this.UpdateItem(userID, itm, sessionID); | ||
425 | } | ||
426 | } | 419 | } |
427 | 420 | ||
428 | private void MoveItemsCompleted(IAsyncResult iar) | 421 | private void MoveItemsCompleted(IAsyncResult iar) |
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs index 145f212..0a982f8 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs | |||
@@ -76,10 +76,12 @@ namespace OpenSim.Services.Connectors | |||
76 | // Don't remote-call this instance; that's a startup hickup | 76 | // Don't remote-call this instance; that's a startup hickup |
77 | !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) | 77 | !((regInfo.ExternalHostName == thisRegion.ExternalHostName) && (regInfo.HttpPort == thisRegion.HttpPort))) |
78 | { | 78 | { |
79 | DoHelloNeighbourCall(regInfo, thisRegion); | 79 | if (!DoHelloNeighbourCall(regInfo, thisRegion)) |
80 | return null; | ||
80 | } | 81 | } |
81 | //else | 82 | else |
82 | // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); | 83 | return null; |
84 | |||
83 | return regInfo; | 85 | return regInfo; |
84 | } | 86 | } |
85 | 87 | ||
@@ -102,6 +104,7 @@ namespace OpenSim.Services.Connectors | |||
102 | catch (Exception e) | 104 | catch (Exception e) |
103 | { | 105 | { |
104 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); | 106 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); |
107 | return false; | ||
105 | } | 108 | } |
106 | // Add the regionhandle of the destination region | 109 | // Add the regionhandle of the destination region |
107 | args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString()); | 110 | args["destination_handle"] = OSD.FromString(region.RegionHandle.ToString()); |
@@ -118,7 +121,7 @@ namespace OpenSim.Services.Connectors | |||
118 | catch (Exception e) | 121 | catch (Exception e) |
119 | { | 122 | { |
120 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); | 123 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); |
121 | // ignore. buffer will be empty, caller should check. | 124 | return false; |
122 | } | 125 | } |
123 | 126 | ||
124 | Stream os = null; | 127 | Stream os = null; |
@@ -127,20 +130,23 @@ namespace OpenSim.Services.Connectors | |||
127 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send | 130 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send |
128 | os = HelloNeighbourRequest.GetRequestStream(); | 131 | os = HelloNeighbourRequest.GetRequestStream(); |
129 | os.Write(buffer, 0, strBuffer.Length); //Send it | 132 | os.Write(buffer, 0, strBuffer.Length); //Send it |
130 | os.Close(); | ||
131 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); | 133 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); |
132 | } | 134 | } |
133 | //catch (WebException ex) | 135 | catch (Exception ex) |
134 | catch | ||
135 | { | 136 | { |
136 | //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); | 137 | m_log.InfoFormat("[REST COMMS]: Unable to send HelloNeighbour to {0}: {1}", region.RegionName, ex.Message); |
137 | |||
138 | return false; | 138 | return false; |
139 | } | 139 | } |
140 | finally | ||
141 | { | ||
142 | if (os != null) | ||
143 | os.Close(); | ||
144 | } | ||
140 | 145 | ||
141 | // Let's wait for the response | 146 | // Let's wait for the response |
142 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); | 147 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); |
143 | 148 | ||
149 | StreamReader sr = null; | ||
144 | try | 150 | try |
145 | { | 151 | { |
146 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); | 152 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); |
@@ -149,17 +155,21 @@ namespace OpenSim.Services.Connectors | |||
149 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); | 155 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); |
150 | } | 156 | } |
151 | 157 | ||
152 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | 158 | sr = new StreamReader(webResponse.GetResponseStream()); |
153 | //reply = sr.ReadToEnd().Trim(); | 159 | //reply = sr.ReadToEnd().Trim(); |
154 | sr.ReadToEnd().Trim(); | 160 | sr.ReadToEnd().Trim(); |
155 | sr.Close(); | ||
156 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); | 161 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); |
157 | 162 | ||
158 | } | 163 | } |
159 | catch (WebException ex) | 164 | catch (Exception ex) |
160 | { | 165 | { |
161 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); | 166 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); |
162 | // ignore, really | 167 | return false; |
168 | } | ||
169 | finally | ||
170 | { | ||
171 | if (sr != null) | ||
172 | sr.Close(); | ||
163 | } | 173 | } |
164 | 174 | ||
165 | return true; | 175 | return true; |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a2e4771..86815e5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -200,6 +200,7 @@ namespace OpenSim.Services.GridService | |||
200 | rdata.RegionName = rinfo.RegionName; | 200 | rdata.RegionName = rinfo.RegionName; |
201 | rdata.Data = rinfo.ToKeyValuePairs(); | 201 | rdata.Data = rinfo.ToKeyValuePairs(); |
202 | rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); | 202 | rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); |
203 | rdata.Data["owner_uuid"] = rinfo.EstateOwner.ToString(); | ||
203 | return rdata; | 204 | return rdata; |
204 | } | 205 | } |
205 | 206 | ||
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs index 2290530..14560b1 100644 --- a/OpenSim/Services/Interfaces/IGridService.cs +++ b/OpenSim/Services/Interfaces/IGridService.cs | |||
@@ -140,6 +140,14 @@ namespace OpenSim.Services.Interfaces | |||
140 | } | 140 | } |
141 | protected int m_regionLocY; | 141 | protected int m_regionLocY; |
142 | 142 | ||
143 | protected UUID m_estateOwner; | ||
144 | |||
145 | public UUID EstateOwner | ||
146 | { | ||
147 | get { return m_estateOwner; } | ||
148 | set { m_estateOwner = value; } | ||
149 | } | ||
150 | |||
143 | public UUID RegionID = UUID.Zero; | 151 | public UUID RegionID = UUID.Zero; |
144 | public UUID ScopeID = UUID.Zero; | 152 | public UUID ScopeID = UUID.Zero; |
145 | 153 | ||
@@ -191,6 +199,7 @@ namespace OpenSim.Services.Interfaces | |||
191 | Access = ConvertFrom.AccessLevel; | 199 | Access = ConvertFrom.AccessLevel; |
192 | Maturity = ConvertFrom.RegionSettings.Maturity; | 200 | Maturity = ConvertFrom.RegionSettings.Maturity; |
193 | RegionSecret = ConvertFrom.regionSecret; | 201 | RegionSecret = ConvertFrom.regionSecret; |
202 | EstateOwner = ConvertFrom.EstateSettings.EstateOwner; | ||
194 | } | 203 | } |
195 | 204 | ||
196 | public GridRegion(GridRegion ConvertFrom) | 205 | public GridRegion(GridRegion ConvertFrom) |
@@ -207,6 +216,7 @@ namespace OpenSim.Services.Interfaces | |||
207 | Access = ConvertFrom.Access; | 216 | Access = ConvertFrom.Access; |
208 | Maturity = ConvertFrom.Maturity; | 217 | Maturity = ConvertFrom.Maturity; |
209 | RegionSecret = ConvertFrom.RegionSecret; | 218 | RegionSecret = ConvertFrom.RegionSecret; |
219 | EstateOwner = ConvertFrom.EstateOwner; | ||
210 | } | 220 | } |
211 | 221 | ||
212 | /// <value> | 222 | /// <value> |
@@ -291,6 +301,7 @@ namespace OpenSim.Services.Interfaces | |||
291 | kvp["regionMapTexture"] = TerrainImage.ToString(); | 301 | kvp["regionMapTexture"] = TerrainImage.ToString(); |
292 | kvp["access"] = Access.ToString(); | 302 | kvp["access"] = Access.ToString(); |
293 | kvp["regionSecret"] = RegionSecret; | 303 | kvp["regionSecret"] = RegionSecret; |
304 | kvp["owner_uuid"] = EstateOwner.ToString(); | ||
294 | // Maturity doesn't seem to exist in the DB | 305 | // Maturity doesn't seem to exist in the DB |
295 | return kvp; | 306 | return kvp; |
296 | } | 307 | } |
@@ -345,6 +356,9 @@ namespace OpenSim.Services.Interfaces | |||
345 | if (kvp.ContainsKey("regionSecret")) | 356 | if (kvp.ContainsKey("regionSecret")) |
346 | RegionSecret =(string)kvp["regionSecret"]; | 357 | RegionSecret =(string)kvp["regionSecret"]; |
347 | 358 | ||
359 | if (kvp.ContainsKey("owner_uuid")) | ||
360 | EstateOwner = new UUID(kvp["owner_uuid"].ToString()); | ||
361 | |||
348 | } | 362 | } |
349 | } | 363 | } |
350 | 364 | ||
diff --git a/OpenSim/TestSuite/BotManager.cs b/OpenSim/TestSuite/BotManager.cs index 62e0ec7..55ba687 100644 --- a/OpenSim/TestSuite/BotManager.cs +++ b/OpenSim/TestSuite/BotManager.cs | |||
@@ -115,7 +115,6 @@ namespace OpenSim.TestSuite | |||
115 | m_td[pos].IsBackground = true; | 115 | m_td[pos].IsBackground = true; |
116 | m_td[pos].Start(); | 116 | m_td[pos].Start(); |
117 | m_lBot.Add(pb); | 117 | m_lBot.Add(pb); |
118 | ThreadTracker.Add(m_td[pos]); | ||
119 | } | 118 | } |
120 | 119 | ||
121 | /// <summary> | 120 | /// <summary> |
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 3f4e6ed..614b350 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -149,7 +149,6 @@ namespace pCampBot | |||
149 | m_td[pos].IsBackground = true; | 149 | m_td[pos].IsBackground = true; |
150 | m_td[pos].Start(); | 150 | m_td[pos].Start(); |
151 | m_lBot.Add(pb); | 151 | m_lBot.Add(pb); |
152 | ThreadTracker.Add(m_td[pos]); | ||
153 | } | 152 | } |
154 | 153 | ||
155 | /// <summary> | 154 | /// <summary> |
diff --git a/prebuild.xml b/prebuild.xml index f863ab6..bba54f3 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -131,6 +131,7 @@ | |||
131 | 131 | ||
132 | <ReferencePath>../../bin/</ReferencePath> | 132 | <ReferencePath>../../bin/</ReferencePath> |
133 | <Reference name="System"/> | 133 | <Reference name="System"/> |
134 | <Reference name="System.Core"/> | ||
134 | <Reference name="System.Xml"/> | 135 | <Reference name="System.Xml"/> |
135 | <Reference name="System.Data"/> | 136 | <Reference name="System.Data"/> |
136 | <Reference name="System.Drawing"/> | 137 | <Reference name="System.Drawing"/> |
@@ -724,7 +725,6 @@ | |||
724 | <Reference name="System"/> | 725 | <Reference name="System"/> |
725 | <Reference name="System.Xml"/> | 726 | <Reference name="System.Xml"/> |
726 | <Reference name="System.Drawing"/> | 727 | <Reference name="System.Drawing"/> |
727 | <Reference name="System.Runtime.Remoting"/> | ||
728 | <Reference name="System.Web"/> | 728 | <Reference name="System.Web"/> |
729 | <Reference name="OpenMetaverseTypes.dll"/> | 729 | <Reference name="OpenMetaverseTypes.dll"/> |
730 | <Reference name="OpenMetaverse.StructuredData.dll"/> | 730 | <Reference name="OpenMetaverse.StructuredData.dll"/> |
@@ -805,7 +805,6 @@ | |||
805 | <Reference name="System"/> | 805 | <Reference name="System"/> |
806 | <Reference name="System.Xml"/> | 806 | <Reference name="System.Xml"/> |
807 | <Reference name="System.Data"/> | 807 | <Reference name="System.Data"/> |
808 | <Reference name="System.Runtime.Remoting"/> | ||
809 | <Reference name="OpenSim.Framework"/> | 808 | <Reference name="OpenSim.Framework"/> |
810 | <Reference name="OpenSim.Data" /> | 809 | <Reference name="OpenSim.Data" /> |
811 | <Reference name="OpenSim.Framework.Communications" /> | 810 | <Reference name="OpenSim.Framework.Communications" /> |
@@ -1539,7 +1538,6 @@ | |||
1539 | <Reference name="System"/> | 1538 | <Reference name="System"/> |
1540 | <Reference name="System.Xml"/> | 1539 | <Reference name="System.Xml"/> |
1541 | <Reference name="System.Drawing"/> | 1540 | <Reference name="System.Drawing"/> |
1542 | <Reference name="System.Runtime.Remoting"/> | ||
1543 | <Reference name="System.Web"/> | 1541 | <Reference name="System.Web"/> |
1544 | <Reference name="OpenMetaverseTypes.dll"/> | 1542 | <Reference name="OpenMetaverseTypes.dll"/> |
1545 | <Reference name="OpenMetaverse.StructuredData.dll"/> | 1543 | <Reference name="OpenMetaverse.StructuredData.dll"/> |
@@ -1624,7 +1622,6 @@ | |||
1624 | <Reference name="System"/> | 1622 | <Reference name="System"/> |
1625 | <Reference name="System.Xml"/> | 1623 | <Reference name="System.Xml"/> |
1626 | <Reference name="System.Drawing"/> | 1624 | <Reference name="System.Drawing"/> |
1627 | <Reference name="System.Runtime.Remoting"/> | ||
1628 | <Reference name="System.Web"/> | 1625 | <Reference name="System.Web"/> |
1629 | <Reference name="OpenMetaverseTypes.dll"/> | 1626 | <Reference name="OpenMetaverseTypes.dll"/> |
1630 | <Reference name="OpenMetaverse.StructuredData.dll"/> | 1627 | <Reference name="OpenMetaverse.StructuredData.dll"/> |
@@ -1682,7 +1679,6 @@ | |||
1682 | <ReferencePath>../../../../bin/</ReferencePath> | 1679 | <ReferencePath>../../../../bin/</ReferencePath> |
1683 | <Reference name="System"/> | 1680 | <Reference name="System"/> |
1684 | <Reference name="System.Drawing"/> | 1681 | <Reference name="System.Drawing"/> |
1685 | <Reference name="System.Runtime.Remoting"/> | ||
1686 | <Reference name="System.Xml"/> | 1682 | <Reference name="System.Xml"/> |
1687 | <Reference name="OpenSim.Data"/> | 1683 | <Reference name="OpenSim.Data"/> |
1688 | <Reference name="OpenSim.Framework"/> | 1684 | <Reference name="OpenSim.Framework"/> |
@@ -1755,6 +1751,7 @@ | |||
1755 | 1751 | ||
1756 | <ReferencePath>../../../../bin/</ReferencePath> | 1752 | <ReferencePath>../../../../bin/</ReferencePath> |
1757 | <Reference name="System"/> | 1753 | <Reference name="System"/> |
1754 | <Reference name="System.Core"/> | ||
1758 | <Reference name="System.Xml"/> | 1755 | <Reference name="System.Xml"/> |
1759 | <Reference name="OpenMetaverseTypes.dll"/> | 1756 | <Reference name="OpenMetaverseTypes.dll"/> |
1760 | <Reference name="OpenMetaverse.StructuredData.dll"/> | 1757 | <Reference name="OpenMetaverse.StructuredData.dll"/> |
@@ -3590,7 +3587,6 @@ | |||
3590 | <Reference name="System"/> | 3587 | <Reference name="System"/> |
3591 | <Reference name="System.Xml"/> | 3588 | <Reference name="System.Xml"/> |
3592 | <Reference name="System.Drawing"/> | 3589 | <Reference name="System.Drawing"/> |
3593 | <Reference name="System.Runtime.Remoting"/> | ||
3594 | <Reference name="OpenMetaverseTypes.dll"/> | 3590 | <Reference name="OpenMetaverseTypes.dll"/> |
3595 | <Reference name="OpenMetaverse.dll"/> | 3591 | <Reference name="OpenMetaverse.dll"/> |
3596 | <Reference name="OpenSim.Data"/> | 3592 | <Reference name="OpenSim.Data"/> |
@@ -3695,6 +3691,7 @@ | |||
3695 | </Files> | 3691 | </Files> |
3696 | </Project> | 3692 | </Project> |
3697 | 3693 | ||
3694 | <!-- Commented for now until new unit tests are written for the new LLUDP implementation | ||
3698 | <Project frameworkVersion="v3_5" name="OpenSim.Region.ClientStack.LindenUDP.Tests" path="OpenSim/Region/ClientStack/LindenUDP/Tests" type="Library"> | 3695 | <Project frameworkVersion="v3_5" name="OpenSim.Region.ClientStack.LindenUDP.Tests" path="OpenSim/Region/ClientStack/LindenUDP/Tests" type="Library"> |
3699 | <Configuration name="Debug"> | 3696 | <Configuration name="Debug"> |
3700 | <Options> | 3697 | <Options> |
@@ -3728,6 +3725,7 @@ | |||
3728 | <Match pattern="*.cs" recurse="false"/> | 3725 | <Match pattern="*.cs" recurse="false"/> |
3729 | </Files> | 3726 | </Files> |
3730 | </Project> | 3727 | </Project> |
3728 | --> | ||
3731 | 3729 | ||
3732 | <Project frameworkVersion="v3_5" name="OpenSim.Region.ScriptEngine.Tests" path="OpenSim/Region/ScriptEngine" type="Library"> | 3730 | <Project frameworkVersion="v3_5" name="OpenSim.Region.ScriptEngine.Tests" path="OpenSim/Region/ScriptEngine" type="Library"> |
3733 | <Configuration name="Debug"> | 3731 | <Configuration name="Debug"> |