corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) 2006-2014, openmetaverse.org
3 * All rights reserved.
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 *
8 * - Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 * - Neither the name of the openmetaverse.org nor the names
11 * of its contributors may be used to endorse or promote products derived from
12 * this software without specific prior written permission.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26  
27 using System;
28 using System.Collections.Generic;
29 using System.Net;
30 using System.IO;
31 using ComponentAce.Compression.Libs.zlib;
32 using OpenMetaverse.StructuredData;
33 using OpenMetaverse.Interfaces;
34  
35 namespace OpenMetaverse.Messages.Linden
36 {
37 #region Teleport/Region/Movement Messages
38  
39 /// <summary>
40 /// Sent to the client to indicate a teleport request has completed
41 /// </summary>
42 public class TeleportFinishMessage : IMessage
43 {
44 /// <summary>The <see cref="UUID"/> of the agent</summary>
45 public UUID AgentID;
46 /// <summary></summary>
47 public int LocationID;
48 /// <summary>The simulators handle the agent teleported to</summary>
49 public ulong RegionHandle;
50 /// <summary>A Uri which contains a list of Capabilities the simulator supports</summary>
51 public Uri SeedCapability;
52 /// <summary>Indicates the level of access required
53 /// to access the simulator, or the content rating, or the simulators
54 /// map status</summary>
55 public SimAccess SimAccess;
56 /// <summary>The IP Address of the simulator</summary>
57 public IPAddress IP;
58 /// <summary>The UDP Port the simulator will listen for UDP traffic on</summary>
59 public int Port;
60 /// <summary>Status flags indicating the state of the Agent upon arrival, Flying, etc.</summary>
61 public TeleportFlags Flags;
62  
63 /// <summary>
64 /// Serialize the object
65 /// </summary>
66 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
67 public OSDMap Serialize()
68 {
69 OSDMap map = new OSDMap(1);
70  
71 OSDArray infoArray = new OSDArray(1);
72  
73 OSDMap info = new OSDMap(8);
74 info.Add("AgentID", OSD.FromUUID(AgentID));
75 info.Add("LocationID", OSD.FromInteger(LocationID)); // Unused by the client
76 info.Add("RegionHandle", OSD.FromULong(RegionHandle));
77 info.Add("SeedCapability", OSD.FromUri(SeedCapability));
78 info.Add("SimAccess", OSD.FromInteger((byte)SimAccess));
79 info.Add("SimIP", MessageUtils.FromIP(IP));
80 info.Add("SimPort", OSD.FromInteger(Port));
81 info.Add("TeleportFlags", OSD.FromUInteger((uint)Flags));
82  
83 infoArray.Add(info);
84  
85 map.Add("Info", infoArray);
86  
87 return map;
88 }
89  
90 /// <summary>
91 /// Deserialize the message
92 /// </summary>
93 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
94 public void Deserialize(OSDMap map)
95 {
96 OSDArray array = (OSDArray)map["Info"];
97 OSDMap blockMap = (OSDMap)array[0];
98  
99 AgentID = blockMap["AgentID"].AsUUID();
100 LocationID = blockMap["LocationID"].AsInteger();
101 RegionHandle = blockMap["RegionHandle"].AsULong();
102 SeedCapability = blockMap["SeedCapability"].AsUri();
103 SimAccess = (SimAccess)blockMap["SimAccess"].AsInteger();
104 IP = MessageUtils.ToIP(blockMap["SimIP"]);
105 Port = blockMap["SimPort"].AsInteger();
106 Flags = (TeleportFlags)blockMap["TeleportFlags"].AsUInteger();
107 }
108 }
109  
110 /// <summary>
111 /// Sent to the viewer when a neighboring simulator is requesting the agent make a connection to it.
112 /// </summary>
113 public class EstablishAgentCommunicationMessage : IMessage
114 {
115 public UUID AgentID;
116 public IPAddress Address;
117 public int Port;
118 public Uri SeedCapability;
119  
120 /// <summary>
121 /// Serialize the object
122 /// </summary>
123 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
124 public OSDMap Serialize()
125 {
126 OSDMap map = new OSDMap(3);
127 map["agent-id"] = OSD.FromUUID(AgentID);
128 map["sim-ip-and-port"] = OSD.FromString(String.Format("{0}:{1}", Address, Port));
129 map["seed-capability"] = OSD.FromUri(SeedCapability);
130 return map;
131 }
132  
133 /// <summary>
134 /// Deserialize the message
135 /// </summary>
136 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
137 public void Deserialize(OSDMap map)
138 {
139 string ipAndPort = map["sim-ip-and-port"].AsString();
140 int i = ipAndPort.IndexOf(':');
141  
142 AgentID = map["agent-id"].AsUUID();
143 Address = IPAddress.Parse(ipAndPort.Substring(0, i));
144 Port = Int32.Parse(ipAndPort.Substring(i + 1));
145 SeedCapability = map["seed-capability"].AsUri();
146 }
147 }
148  
149 public class CrossedRegionMessage : IMessage
150 {
151 public Vector3 LookAt;
152 public Vector3 Position;
153 public UUID AgentID;
154 public UUID SessionID;
155 public ulong RegionHandle;
156 public Uri SeedCapability;
157 public IPAddress IP;
158 public int Port;
159  
160 /// <summary>
161 /// Serialize the object
162 /// </summary>
163 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
164 public OSDMap Serialize()
165 {
166 OSDMap map = new OSDMap(3);
167  
168 OSDArray infoArray = new OSDArray(1);
169 OSDMap infoMap = new OSDMap(2);
170 infoMap["LookAt"] = OSD.FromVector3(LookAt);
171 infoMap["Position"] = OSD.FromVector3(Position);
172 infoArray.Add(infoMap);
173 map["Info"] = infoArray;
174  
175 OSDArray agentDataArray = new OSDArray(1);
176 OSDMap agentDataMap = new OSDMap(2);
177 agentDataMap["AgentID"] = OSD.FromUUID(AgentID);
178 agentDataMap["SessionID"] = OSD.FromUUID(SessionID);
179 agentDataArray.Add(agentDataMap);
180 map["AgentData"] = agentDataArray;
181  
182 OSDArray regionDataArray = new OSDArray(1);
183 OSDMap regionDataMap = new OSDMap(4);
184 regionDataMap["RegionHandle"] = OSD.FromULong(RegionHandle);
185 regionDataMap["SeedCapability"] = OSD.FromUri(SeedCapability);
186 regionDataMap["SimIP"] = MessageUtils.FromIP(IP);
187 regionDataMap["SimPort"] = OSD.FromInteger(Port);
188 regionDataArray.Add(regionDataMap);
189 map["RegionData"] = regionDataArray;
190  
191 return map;
192 }
193  
194 /// <summary>
195 /// Deserialize the message
196 /// </summary>
197 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
198 public void Deserialize(OSDMap map)
199 {
200 OSDMap infoMap = (OSDMap)((OSDArray)map["Info"])[0];
201 LookAt = infoMap["LookAt"].AsVector3();
202 Position = infoMap["Position"].AsVector3();
203  
204 OSDMap agentDataMap = (OSDMap)((OSDArray)map["AgentData"])[0];
205 AgentID = agentDataMap["AgentID"].AsUUID();
206 SessionID = agentDataMap["SessionID"].AsUUID();
207  
208 OSDMap regionDataMap = (OSDMap)((OSDArray)map["RegionData"])[0];
209 RegionHandle = regionDataMap["RegionHandle"].AsULong();
210 SeedCapability = regionDataMap["SeedCapability"].AsUri();
211 IP = MessageUtils.ToIP(regionDataMap["SimIP"]);
212 Port = regionDataMap["SimPort"].AsInteger();
213 }
214 }
215  
216 public class EnableSimulatorMessage : IMessage
217 {
218 public class SimulatorInfoBlock
219 {
220 public ulong RegionHandle;
221 public IPAddress IP;
222 public int Port;
223 }
224  
225 public SimulatorInfoBlock[] Simulators;
226  
227 /// <summary>
228 /// Serialize the object
229 /// </summary>
230 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
231 public OSDMap Serialize()
232 {
233 OSDMap map = new OSDMap(1);
234  
235 OSDArray array = new OSDArray(Simulators.Length);
236 for (int i = 0; i < Simulators.Length; i++)
237 {
238 SimulatorInfoBlock block = Simulators[i];
239  
240 OSDMap blockMap = new OSDMap(3);
241 blockMap["Handle"] = OSD.FromULong(block.RegionHandle);
242 blockMap["IP"] = MessageUtils.FromIP(block.IP);
243 blockMap["Port"] = OSD.FromInteger(block.Port);
244 array.Add(blockMap);
245 }
246  
247 map["SimulatorInfo"] = array;
248 return map;
249 }
250  
251 /// <summary>
252 /// Deserialize the message
253 /// </summary>
254 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
255 public void Deserialize(OSDMap map)
256 {
257 OSDArray array = (OSDArray)map["SimulatorInfo"];
258 Simulators = new SimulatorInfoBlock[array.Count];
259  
260 for (int i = 0; i < array.Count; i++)
261 {
262 OSDMap blockMap = (OSDMap)array[i];
263  
264 SimulatorInfoBlock block = new SimulatorInfoBlock();
265 block.RegionHandle = blockMap["Handle"].AsULong();
266 block.IP = MessageUtils.ToIP(blockMap["IP"]);
267 block.Port = blockMap["Port"].AsInteger();
268 Simulators[i] = block;
269 }
270 }
271 }
272  
273 /// <summary>
274 /// A message sent to the client which indicates a teleport request has failed
275 /// and contains some information on why it failed
276 /// </summary>
277 public class TeleportFailedMessage : IMessage
278 {
279 /// <summary></summary>
280 public string ExtraParams;
281 /// <summary>A string key of the reason the teleport failed e.g. CouldntTPCloser
282 /// Which could be used to look up a value in a dictionary or enum</summary>
283 public string MessageKey;
284 /// <summary>The <see cref="UUID"/> of the Agent</summary>
285 public UUID AgentID;
286 /// <summary>A string human readable message containing the reason </summary>
287 /// <remarks>An example: Could not teleport closer to destination</remarks>
288 public string Reason;
289  
290 /// <summary>
291 /// Serialize the object
292 /// </summary>
293 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
294 public OSDMap Serialize()
295 {
296 OSDMap map = new OSDMap(2);
297  
298 OSDMap alertInfoMap = new OSDMap(2);
299  
300 alertInfoMap["ExtraParams"] = OSD.FromString(ExtraParams);
301 alertInfoMap["Message"] = OSD.FromString(MessageKey);
302 OSDArray alertArray = new OSDArray();
303 alertArray.Add(alertInfoMap);
304 map["AlertInfo"] = alertArray;
305  
306 OSDMap infoMap = new OSDMap(2);
307 infoMap["AgentID"] = OSD.FromUUID(AgentID);
308 infoMap["Reason"] = OSD.FromString(Reason);
309 OSDArray infoArray = new OSDArray();
310 infoArray.Add(infoMap);
311 map["Info"] = infoArray;
312  
313 return map;
314 }
315  
316 /// <summary>
317 /// Deserialize the message
318 /// </summary>
319 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
320 public void Deserialize(OSDMap map)
321 {
322  
323 OSDArray alertInfoArray = (OSDArray)map["AlertInfo"];
324  
325 OSDMap alertInfoMap = (OSDMap)alertInfoArray[0];
326 ExtraParams = alertInfoMap["ExtraParams"].AsString();
327 MessageKey = alertInfoMap["Message"].AsString();
328  
329 OSDArray infoArray = (OSDArray)map["Info"];
330 OSDMap infoMap = (OSDMap)infoArray[0];
331 AgentID = infoMap["AgentID"].AsUUID();
332 Reason = infoMap["Reason"].AsString();
333 }
334 }
335  
336 public class LandStatReplyMessage : IMessage
337 {
338 public uint ReportType;
339 public uint RequestFlags;
340 public uint TotalObjectCount;
341  
342 public class ReportDataBlock
343 {
344 public Vector3 Location;
345 public string OwnerName;
346 public float Score;
347 public UUID TaskID;
348 public uint TaskLocalID;
349 public string TaskName;
350 public float MonoScore;
351 public DateTime TimeStamp;
352 }
353  
354 public ReportDataBlock[] ReportDataBlocks;
355  
356 /// <summary>
357 /// Serialize the object
358 /// </summary>
359 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
360 public OSDMap Serialize()
361 {
362 OSDMap map = new OSDMap(3);
363  
364 OSDMap requestDataMap = new OSDMap(3);
365 requestDataMap["ReportType"] = OSD.FromUInteger(this.ReportType);
366 requestDataMap["RequestFlags"] = OSD.FromUInteger(this.RequestFlags);
367 requestDataMap["TotalObjectCount"] = OSD.FromUInteger(this.TotalObjectCount);
368  
369 OSDArray requestDatArray = new OSDArray();
370 requestDatArray.Add(requestDataMap);
371 map["RequestData"] = requestDatArray;
372  
373 OSDArray reportDataArray = new OSDArray();
374 OSDArray dataExtendedArray = new OSDArray();
375 for (int i = 0; i < ReportDataBlocks.Length; i++)
376 {
377 OSDMap reportMap = new OSDMap(8);
378 reportMap["LocationX"] = OSD.FromReal(ReportDataBlocks[i].Location.X);
379 reportMap["LocationY"] = OSD.FromReal(ReportDataBlocks[i].Location.Y);
380 reportMap["LocationZ"] = OSD.FromReal(ReportDataBlocks[i].Location.Z);
381 reportMap["OwnerName"] = OSD.FromString(ReportDataBlocks[i].OwnerName);
382 reportMap["Score"] = OSD.FromReal(ReportDataBlocks[i].Score);
383 reportMap["TaskID"] = OSD.FromUUID(ReportDataBlocks[i].TaskID);
384 reportMap["TaskLocalID"] = OSD.FromReal(ReportDataBlocks[i].TaskLocalID);
385 reportMap["TaskName"] = OSD.FromString(ReportDataBlocks[i].TaskName);
386 reportDataArray.Add(reportMap);
387  
388 OSDMap extendedMap = new OSDMap(2);
389 extendedMap["MonoScore"] = OSD.FromReal(ReportDataBlocks[i].MonoScore);
390 extendedMap["TimeStamp"] = OSD.FromDate(ReportDataBlocks[i].TimeStamp);
391 dataExtendedArray.Add(extendedMap);
392 }
393  
394 map["ReportData"] = reportDataArray;
395 map["DataExtended"] = dataExtendedArray;
396  
397 return map;
398 }
399  
400 /// <summary>
401 /// Deserialize the message
402 /// </summary>
403 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
404 public void Deserialize(OSDMap map)
405 {
406  
407 OSDArray requestDataArray = (OSDArray)map["RequestData"];
408 OSDMap requestMap = (OSDMap)requestDataArray[0];
409  
410 this.ReportType = requestMap["ReportType"].AsUInteger();
411 this.RequestFlags = requestMap["RequestFlags"].AsUInteger();
412 this.TotalObjectCount = requestMap["TotalObjectCount"].AsUInteger();
413  
414 if (TotalObjectCount < 1)
415 {
416 ReportDataBlocks = new ReportDataBlock[0];
417 return;
418 }
419  
420 OSDArray dataArray = (OSDArray)map["ReportData"];
421 OSDArray dataExtendedArray = (OSDArray)map["DataExtended"];
422  
423 ReportDataBlocks = new ReportDataBlock[dataArray.Count];
424 for (int i = 0; i < dataArray.Count; i++)
425 {
426 OSDMap blockMap = (OSDMap)dataArray[i];
427 OSDMap extMap = (OSDMap)dataExtendedArray[i];
428 ReportDataBlock block = new ReportDataBlock();
429 block.Location = new Vector3(
430 (float)blockMap["LocationX"].AsReal(),
431 (float)blockMap["LocationY"].AsReal(),
432 (float)blockMap["LocationZ"].AsReal());
433 block.OwnerName = blockMap["OwnerName"].AsString();
434 block.Score = (float)blockMap["Score"].AsReal();
435 block.TaskID = blockMap["TaskID"].AsUUID();
436 block.TaskLocalID = blockMap["TaskLocalID"].AsUInteger();
437 block.TaskName = blockMap["TaskName"].AsString();
438 block.MonoScore = (float)extMap["MonoScore"].AsReal();
439 block.TimeStamp = Utils.UnixTimeToDateTime(extMap["TimeStamp"].AsUInteger());
440  
441 ReportDataBlocks[i] = block;
442 }
443 }
444 }
445  
446 #endregion
447  
448 #region Parcel Messages
449  
450 /// <summary>
451 /// Contains a list of prim owner information for a specific parcel in a simulator
452 /// </summary>
453 /// <remarks>
454 /// A Simulator will always return at least 1 entry
455 /// If agent does not have proper permission the OwnerID will be UUID.Zero
456 /// If agent does not have proper permission OR there are no primitives on parcel
457 /// the DataBlocksExtended map will not be sent from the simulator
458 /// </remarks>
459 public class ParcelObjectOwnersReplyMessage : IMessage
460 {
461 /// <summary>
462 /// Prim ownership information for a specified owner on a single parcel
463 /// </summary>
464 public class PrimOwner
465 {
466 /// <summary>The <see cref="UUID"/> of the prim owner,
467 /// UUID.Zero if agent has no permission to view prim owner information</summary>
468 public UUID OwnerID;
469 /// <summary>The total number of prims</summary>
470 public int Count;
471 /// <summary>True if the OwnerID is a <see cref="Group"/></summary>
472 public bool IsGroupOwned;
473 /// <summary>True if the owner is online
474 /// <remarks>This is no longer used by the LL Simulators</remarks></summary>
475 public bool OnlineStatus;
476 /// <summary>The date the most recent prim was rezzed</summary>
477 public DateTime TimeStamp;
478 }
479  
480 /// <summary>An Array of <see cref="PrimOwner"/> objects</summary>
481 public PrimOwner[] PrimOwnersBlock;
482  
483 /// <summary>
484 /// Serialize the object
485 /// </summary>
486 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
487 public OSDMap Serialize()
488 {
489 OSDArray dataArray = new OSDArray(PrimOwnersBlock.Length);
490 OSDArray dataExtendedArray = new OSDArray();
491  
492 for (int i = 0; i < PrimOwnersBlock.Length; i++)
493 {
494 OSDMap dataMap = new OSDMap(4);
495 dataMap["OwnerID"] = OSD.FromUUID(PrimOwnersBlock[i].OwnerID);
496 dataMap["Count"] = OSD.FromInteger(PrimOwnersBlock[i].Count);
497 dataMap["IsGroupOwned"] = OSD.FromBoolean(PrimOwnersBlock[i].IsGroupOwned);
498 dataMap["OnlineStatus"] = OSD.FromBoolean(PrimOwnersBlock[i].OnlineStatus);
499 dataArray.Add(dataMap);
500  
501 OSDMap dataExtendedMap = new OSDMap(1);
502 dataExtendedMap["TimeStamp"] = OSD.FromDate(PrimOwnersBlock[i].TimeStamp);
503 dataExtendedArray.Add(dataExtendedMap);
504 }
505  
506 OSDMap map = new OSDMap();
507 map.Add("Data", dataArray);
508 if (dataExtendedArray.Count > 0)
509 map.Add("DataExtended", dataExtendedArray);
510  
511 return map;
512 }
513  
514 /// <summary>
515 /// Deserialize the message
516 /// </summary>
517 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
518 public void Deserialize(OSDMap map)
519 {
520 OSDArray dataArray = (OSDArray)map["Data"];
521  
522 // DataExtended is optional, will not exist of parcel contains zero prims
523 OSDArray dataExtendedArray;
524 if (map.ContainsKey("DataExtended"))
525 {
526 dataExtendedArray = (OSDArray)map["DataExtended"];
527 }
528 else
529 {
530 dataExtendedArray = new OSDArray();
531 }
532  
533 PrimOwnersBlock = new PrimOwner[dataArray.Count];
534  
535 for (int i = 0; i < dataArray.Count; i++)
536 {
537 OSDMap dataMap = (OSDMap)dataArray[i];
538 PrimOwner block = new PrimOwner();
539 block.OwnerID = dataMap["OwnerID"].AsUUID();
540 block.Count = dataMap["Count"].AsInteger();
541 block.IsGroupOwned = dataMap["IsGroupOwned"].AsBoolean();
542 block.OnlineStatus = dataMap["OnlineStatus"].AsBoolean(); // deprecated
543  
544 /* if the agent has no permissions, or there are no prims, the counts
545 * should not match up, so we don't decode the DataExtended map */
546 if (dataExtendedArray.Count == dataArray.Count)
547 {
548 OSDMap dataExtendedMap = (OSDMap)dataExtendedArray[i];
549 block.TimeStamp = Utils.UnixTimeToDateTime(dataExtendedMap["TimeStamp"].AsUInteger());
550 }
551  
552 PrimOwnersBlock[i] = block;
553 }
554 }
555 }
556  
557 /// <summary>
558 /// The details of a single parcel in a region, also contains some regionwide globals
559 /// </summary>
560 [Serializable]
561 public class ParcelPropertiesMessage : IMessage
562 {
563 /// <summary>Simulator-local ID of this parcel</summary>
564 public int LocalID;
565 /// <summary>Maximum corner of the axis-aligned bounding box for this
566 /// parcel</summary>
567 public Vector3 AABBMax;
568 /// <summary>Minimum corner of the axis-aligned bounding box for this
569 /// parcel</summary>
570 public Vector3 AABBMin;
571 /// <summary>Total parcel land area</summary>
572 public int Area;
573 /// <summary></summary>
574 public uint AuctionID;
575 /// <summary>Key of authorized buyer</summary>
576 public UUID AuthBuyerID;
577 /// <summary>Bitmap describing land layout in 4x4m squares across the
578 /// entire region</summary>
579 public byte[] Bitmap;
580 /// <summary></summary>
581 public ParcelCategory Category;
582 /// <summary>Date land was claimed</summary>
583 public DateTime ClaimDate;
584 /// <summary>Appears to always be zero</summary>
585 public int ClaimPrice;
586 /// <summary>Parcel Description</summary>
587 public string Desc;
588 /// <summary></summary>
589 public ParcelFlags ParcelFlags;
590 /// <summary></summary>
591 public UUID GroupID;
592 /// <summary>Total number of primitives owned by the parcel group on
593 /// this parcel</summary>
594 public int GroupPrims;
595 /// <summary>Whether the land is deeded to a group or not</summary>
596 public bool IsGroupOwned;
597 /// <summary></summary>
598 public LandingType LandingType;
599 /// <summary>Maximum number of primitives this parcel supports</summary>
600 public int MaxPrims;
601 /// <summary>The Asset UUID of the Texture which when applied to a
602 /// primitive will display the media</summary>
603 public UUID MediaID;
604 /// <summary>A URL which points to any Quicktime supported media type</summary>
605 public string MediaURL;
606 /// <summary>A byte, if 0x1 viewer should auto scale media to fit object</summary>
607 public bool MediaAutoScale;
608 /// <summary>URL For Music Stream</summary>
609 public string MusicURL;
610 /// <summary>Parcel Name</summary>
611 public string Name;
612 /// <summary>Autoreturn value in minutes for others' objects</summary>
613 public int OtherCleanTime;
614 /// <summary></summary>
615 public int OtherCount;
616 /// <summary>Total number of other primitives on this parcel</summary>
617 public int OtherPrims;
618 /// <summary>UUID of the owner of this parcel</summary>
619 public UUID OwnerID;
620 /// <summary>Total number of primitives owned by the parcel owner on
621 /// this parcel</summary>
622 public int OwnerPrims;
623 /// <summary></summary>
624 public float ParcelPrimBonus;
625 /// <summary>How long is pass valid for</summary>
626 public float PassHours;
627 /// <summary>Price for a temporary pass</summary>
628 public int PassPrice;
629 /// <summary></summary>
630 public int PublicCount;
631 /// <summary>Disallows people outside the parcel from being able to see in</summary>
632 public bool Privacy;
633 /// <summary></summary>
634 public bool RegionDenyAnonymous;
635 /// <summary></summary>
636 public bool RegionDenyIdentified;
637 /// <summary></summary>
638 public bool RegionDenyTransacted;
639 /// <summary>True if the region denies access to age unverified users</summary>
640 public bool RegionDenyAgeUnverified;
641 /// <summary></summary>
642 public bool RegionPushOverride;
643 /// <summary>This field is no longer used</summary>
644 public int RentPrice;
645 /// The result of a request for parcel properties
646 public ParcelResult RequestResult;
647 /// <summary>Sale price of the parcel, only useful if ForSale is set</summary>
648 /// <remarks>The SalePrice will remain the same after an ownership
649 /// transfer (sale), so it can be used to see the purchase price after
650 /// a sale if the new owner has not changed it</remarks>
651 public int SalePrice;
652 /// <summary>
653 /// Number of primitives your avatar is currently
654 /// selecting and sitting on in this parcel
655 /// </summary>
656 public int SelectedPrims;
657 /// <summary></summary>
658 public int SelfCount;
659 /// <summary>
660 /// A number which increments by 1, starting at 0 for each ParcelProperties request.
661 /// Can be overriden by specifying the sequenceID with the ParcelPropertiesRequest being sent.
662 /// a Negative number indicates the action in <seealso cref="ParcelPropertiesStatus"/> has occurred.
663 /// </summary>
664 public int SequenceID;
665 /// <summary>Maximum primitives across the entire simulator</summary>
666 public int SimWideMaxPrims;
667 /// <summary>Total primitives across the entire simulator</summary>
668 public int SimWideTotalPrims;
669 /// <summary></summary>
670 public bool SnapSelection;
671 /// <summary>Key of parcel snapshot</summary>
672 public UUID SnapshotID;
673 /// <summary>Parcel ownership status</summary>
674 public ParcelStatus Status;
675 /// <summary>Total number of primitives on this parcel</summary>
676 public int TotalPrims;
677 /// <summary></summary>
678 public Vector3 UserLocation;
679 /// <summary></summary>
680 public Vector3 UserLookAt;
681 /// <summary>A description of the media</summary>
682 public string MediaDesc;
683 /// <summary>An Integer which represents the height of the media</summary>
684 public int MediaHeight;
685 /// <summary>An integer which represents the width of the media</summary>
686 public int MediaWidth;
687 /// <summary>A boolean, if true the viewer should loop the media</summary>
688 public bool MediaLoop;
689 /// <summary>A string which contains the mime type of the media</summary>
690 public string MediaType;
691 /// <summary>true to obscure (hide) media url</summary>
692 public bool ObscureMedia;
693 /// <summary>true to obscure (hide) music url</summary>
694 public bool ObscureMusic;
695 /// <summary> true if avatars in this parcel should be invisible to people outside</summary>
696 public bool SeeAVs;
697 /// <summary> true if avatars outside can hear any sounds avatars inside play</summary>
698 public bool AnyAVSounds;
699 /// <summary> true if group members outside can hear any sounds avatars inside play</summary>
700 public bool GroupAVSounds;
701  
702 /// <summary>
703 /// Serialize the object
704 /// </summary>
705 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
706 public OSDMap Serialize()
707 {
708 OSDMap map = new OSDMap(3);
709  
710 OSDArray dataArray = new OSDArray(1);
711 OSDMap parcelDataMap = new OSDMap(47);
712 parcelDataMap["LocalID"] = OSD.FromInteger(LocalID);
713 parcelDataMap["AABBMax"] = OSD.FromVector3(AABBMax);
714 parcelDataMap["AABBMin"] = OSD.FromVector3(AABBMin);
715 parcelDataMap["Area"] = OSD.FromInteger(Area);
716 parcelDataMap["AuctionID"] = OSD.FromInteger(AuctionID);
717 parcelDataMap["AuthBuyerID"] = OSD.FromUUID(AuthBuyerID);
718 parcelDataMap["Bitmap"] = OSD.FromBinary(Bitmap);
719 parcelDataMap["Category"] = OSD.FromInteger((int)Category);
720 parcelDataMap["ClaimDate"] = OSD.FromDate(ClaimDate);
721 parcelDataMap["ClaimPrice"] = OSD.FromInteger(ClaimPrice);
722 parcelDataMap["Desc"] = OSD.FromString(Desc);
723 parcelDataMap["ParcelFlags"] = OSD.FromUInteger((uint)ParcelFlags);
724 parcelDataMap["GroupID"] = OSD.FromUUID(GroupID);
725 parcelDataMap["GroupPrims"] = OSD.FromInteger(GroupPrims);
726 parcelDataMap["IsGroupOwned"] = OSD.FromBoolean(IsGroupOwned);
727 parcelDataMap["LandingType"] = OSD.FromInteger((int)LandingType);
728 parcelDataMap["MaxPrims"] = OSD.FromInteger(MaxPrims);
729 parcelDataMap["MediaID"] = OSD.FromUUID(MediaID);
730 parcelDataMap["MediaURL"] = OSD.FromString(MediaURL);
731 parcelDataMap["MediaAutoScale"] = OSD.FromBoolean(MediaAutoScale);
732 parcelDataMap["MusicURL"] = OSD.FromString(MusicURL);
733 parcelDataMap["Name"] = OSD.FromString(Name);
734 parcelDataMap["OtherCleanTime"] = OSD.FromInteger(OtherCleanTime);
735 parcelDataMap["OtherCount"] = OSD.FromInteger(OtherCount);
736 parcelDataMap["OtherPrims"] = OSD.FromInteger(OtherPrims);
737 parcelDataMap["OwnerID"] = OSD.FromUUID(OwnerID);
738 parcelDataMap["OwnerPrims"] = OSD.FromInteger(OwnerPrims);
739 parcelDataMap["ParcelPrimBonus"] = OSD.FromReal((float)ParcelPrimBonus);
740 parcelDataMap["PassHours"] = OSD.FromReal((float)PassHours);
741 parcelDataMap["PassPrice"] = OSD.FromInteger(PassPrice);
742 parcelDataMap["PublicCount"] = OSD.FromInteger(PublicCount);
743 parcelDataMap["Privacy"] = OSD.FromBoolean(Privacy);
744 parcelDataMap["RegionDenyAnonymous"] = OSD.FromBoolean(RegionDenyAnonymous);
745 parcelDataMap["RegionDenyIdentified"] = OSD.FromBoolean(RegionDenyIdentified);
746 parcelDataMap["RegionDenyTransacted"] = OSD.FromBoolean(RegionDenyTransacted);
747 parcelDataMap["RegionPushOverride"] = OSD.FromBoolean(RegionPushOverride);
748 parcelDataMap["RentPrice"] = OSD.FromInteger(RentPrice);
749 parcelDataMap["RequestResult"] = OSD.FromInteger((int)RequestResult);
750 parcelDataMap["SalePrice"] = OSD.FromInteger(SalePrice);
751 parcelDataMap["SelectedPrims"] = OSD.FromInteger(SelectedPrims);
752 parcelDataMap["SelfCount"] = OSD.FromInteger(SelfCount);
753 parcelDataMap["SequenceID"] = OSD.FromInteger(SequenceID);
754 parcelDataMap["SimWideMaxPrims"] = OSD.FromInteger(SimWideMaxPrims);
755 parcelDataMap["SimWideTotalPrims"] = OSD.FromInteger(SimWideTotalPrims);
756 parcelDataMap["SnapSelection"] = OSD.FromBoolean(SnapSelection);
757 parcelDataMap["SnapshotID"] = OSD.FromUUID(SnapshotID);
758 parcelDataMap["Status"] = OSD.FromInteger((int)Status);
759 parcelDataMap["TotalPrims"] = OSD.FromInteger(TotalPrims);
760 parcelDataMap["UserLocation"] = OSD.FromVector3(UserLocation);
761 parcelDataMap["UserLookAt"] = OSD.FromVector3(UserLookAt);
762 parcelDataMap["SeeAVs"] = OSD.FromBoolean(SeeAVs);
763 parcelDataMap["AnyAVSounds"] = OSD.FromBoolean(AnyAVSounds);
764 parcelDataMap["GroupAVSounds"] = OSD.FromBoolean(GroupAVSounds);
765 dataArray.Add(parcelDataMap);
766 map["ParcelData"] = dataArray;
767  
768 OSDArray mediaDataArray = new OSDArray(1);
769 OSDMap mediaDataMap = new OSDMap(7);
770 mediaDataMap["MediaDesc"] = OSD.FromString(MediaDesc);
771 mediaDataMap["MediaHeight"] = OSD.FromInteger(MediaHeight);
772 mediaDataMap["MediaWidth"] = OSD.FromInteger(MediaWidth);
773 mediaDataMap["MediaLoop"] = OSD.FromBoolean(MediaLoop);
774 mediaDataMap["MediaType"] = OSD.FromString(MediaType);
775 mediaDataMap["ObscureMedia"] = OSD.FromBoolean(ObscureMedia);
776 mediaDataMap["ObscureMusic"] = OSD.FromBoolean(ObscureMusic);
777 mediaDataArray.Add(mediaDataMap);
778 map["MediaData"] = mediaDataArray;
779  
780 OSDArray ageVerificationBlockArray = new OSDArray(1);
781 OSDMap ageVerificationBlockMap = new OSDMap(1);
782 ageVerificationBlockMap["RegionDenyAgeUnverified"] = OSD.FromBoolean(RegionDenyAgeUnverified);
783 ageVerificationBlockArray.Add(ageVerificationBlockMap);
784 map["AgeVerificationBlock"] = ageVerificationBlockArray;
785  
786 return map;
787 }
788  
789 /// <summary>
790 /// Deserialize the message
791 /// </summary>
792 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
793 public void Deserialize(OSDMap map)
794 {
795 OSDMap parcelDataMap = (OSDMap)((OSDArray)map["ParcelData"])[0];
796 LocalID = parcelDataMap["LocalID"].AsInteger();
797 AABBMax = parcelDataMap["AABBMax"].AsVector3();
798 AABBMin = parcelDataMap["AABBMin"].AsVector3();
799 Area = parcelDataMap["Area"].AsInteger();
800 AuctionID = (uint)parcelDataMap["AuctionID"].AsInteger();
801 AuthBuyerID = parcelDataMap["AuthBuyerID"].AsUUID();
802 Bitmap = parcelDataMap["Bitmap"].AsBinary();
803 Category = (ParcelCategory)parcelDataMap["Category"].AsInteger();
804 ClaimDate = Utils.UnixTimeToDateTime((uint)parcelDataMap["ClaimDate"].AsInteger());
805 ClaimPrice = parcelDataMap["ClaimPrice"].AsInteger();
806 Desc = parcelDataMap["Desc"].AsString();
807  
808 // LL sends this as binary, we'll convert it here
809 if (parcelDataMap["ParcelFlags"].Type == OSDType.Binary)
810 {
811 byte[] bytes = parcelDataMap["ParcelFlags"].AsBinary();
812 if (BitConverter.IsLittleEndian)
813 Array.Reverse(bytes);
814 ParcelFlags = (ParcelFlags)BitConverter.ToUInt32(bytes, 0);
815 }
816 else
817 {
818 ParcelFlags = (ParcelFlags)parcelDataMap["ParcelFlags"].AsUInteger();
819 }
820 GroupID = parcelDataMap["GroupID"].AsUUID();
821 GroupPrims = parcelDataMap["GroupPrims"].AsInteger();
822 IsGroupOwned = parcelDataMap["IsGroupOwned"].AsBoolean();
823 LandingType = (LandingType)parcelDataMap["LandingType"].AsInteger();
824 MaxPrims = parcelDataMap["MaxPrims"].AsInteger();
825 MediaID = parcelDataMap["MediaID"].AsUUID();
826 MediaURL = parcelDataMap["MediaURL"].AsString();
827 MediaAutoScale = parcelDataMap["MediaAutoScale"].AsBoolean(); // 0x1 = yes
828 MusicURL = parcelDataMap["MusicURL"].AsString();
829 Name = parcelDataMap["Name"].AsString();
830 OtherCleanTime = parcelDataMap["OtherCleanTime"].AsInteger();
831 OtherCount = parcelDataMap["OtherCount"].AsInteger();
832 OtherPrims = parcelDataMap["OtherPrims"].AsInteger();
833 OwnerID = parcelDataMap["OwnerID"].AsUUID();
834 OwnerPrims = parcelDataMap["OwnerPrims"].AsInteger();
835 ParcelPrimBonus = (float)parcelDataMap["ParcelPrimBonus"].AsReal();
836 PassHours = (float)parcelDataMap["PassHours"].AsReal();
837 PassPrice = parcelDataMap["PassPrice"].AsInteger();
838 PublicCount = parcelDataMap["PublicCount"].AsInteger();
839 Privacy = parcelDataMap["Privacy"].AsBoolean();
840 RegionDenyAnonymous = parcelDataMap["RegionDenyAnonymous"].AsBoolean();
841 RegionDenyIdentified = parcelDataMap["RegionDenyIdentified"].AsBoolean();
842 RegionDenyTransacted = parcelDataMap["RegionDenyTransacted"].AsBoolean();
843 RegionPushOverride = parcelDataMap["RegionPushOverride"].AsBoolean();
844 RentPrice = parcelDataMap["RentPrice"].AsInteger();
845 RequestResult = (ParcelResult)parcelDataMap["RequestResult"].AsInteger();
846 SalePrice = parcelDataMap["SalePrice"].AsInteger();
847 SelectedPrims = parcelDataMap["SelectedPrims"].AsInteger();
848 SelfCount = parcelDataMap["SelfCount"].AsInteger();
849 SequenceID = parcelDataMap["SequenceID"].AsInteger();
850 SimWideMaxPrims = parcelDataMap["SimWideMaxPrims"].AsInteger();
851 SimWideTotalPrims = parcelDataMap["SimWideTotalPrims"].AsInteger();
852 SnapSelection = parcelDataMap["SnapSelection"].AsBoolean();
853 SnapshotID = parcelDataMap["SnapshotID"].AsUUID();
854 Status = (ParcelStatus)parcelDataMap["Status"].AsInteger();
855 TotalPrims = parcelDataMap["TotalPrims"].AsInteger();
856 UserLocation = parcelDataMap["UserLocation"].AsVector3();
857 UserLookAt = parcelDataMap["UserLookAt"].AsVector3();
858 SeeAVs = parcelDataMap["SeeAVs"].AsBoolean();
859 AnyAVSounds = parcelDataMap["AnyAVSounds"].AsBoolean();
860 GroupAVSounds = parcelDataMap["GroupAVSounds"].AsBoolean();
861  
862 if (map.ContainsKey("MediaData")) // temporary, OpenSim doesn't send this block
863 {
864 OSDMap mediaDataMap = (OSDMap)((OSDArray)map["MediaData"])[0];
865 MediaDesc = mediaDataMap["MediaDesc"].AsString();
866 MediaHeight = mediaDataMap["MediaHeight"].AsInteger();
867 MediaWidth = mediaDataMap["MediaWidth"].AsInteger();
868 MediaLoop = mediaDataMap["MediaLoop"].AsBoolean();
869 MediaType = mediaDataMap["MediaType"].AsString();
870 ObscureMedia = mediaDataMap["ObscureMedia"].AsBoolean();
871 ObscureMusic = mediaDataMap["ObscureMusic"].AsBoolean();
872 }
873  
874 OSDMap ageVerificationBlockMap = (OSDMap)((OSDArray)map["AgeVerificationBlock"])[0];
875 RegionDenyAgeUnverified = ageVerificationBlockMap["RegionDenyAgeUnverified"].AsBoolean();
876 }
877 }
878  
879 /// <summary>A message sent from the viewer to the simulator to updated a specific parcels settings</summary>
880 public class ParcelPropertiesUpdateMessage : IMessage
881 {
882 /// <summary>The <seealso cref="UUID"/> of the agent authorized to purchase this
883 /// parcel of land or a NULL <seealso cref="UUID"/> if the sale is authorized to anyone</summary>
884 public UUID AuthBuyerID;
885 /// <summary>true to enable auto scaling of the parcel media</summary>
886 public bool MediaAutoScale;
887 /// <summary>The category of this parcel used when search is enabled to restrict
888 /// search results</summary>
889 public ParcelCategory Category;
890 /// <summary>A string containing the description to set</summary>
891 public string Desc;
892 /// <summary>The <seealso cref="UUID"/> of the <seealso cref="Group"/> which allows for additional
893 /// powers and restrictions.</summary>
894 public UUID GroupID;
895 /// <summary>The <seealso cref="LandingType"/> which specifies how avatars which teleport
896 /// to this parcel are handled</summary>
897 public LandingType Landing;
898 /// <summary>The LocalID of the parcel to update settings on</summary>
899 public int LocalID;
900 /// <summary>A string containing the description of the media which can be played
901 /// to visitors</summary>
902 public string MediaDesc;
903 /// <summary></summary>
904 public int MediaHeight;
905 /// <summary></summary>
906 public bool MediaLoop;
907 /// <summary></summary>
908 public UUID MediaID;
909 /// <summary></summary>
910 public string MediaType;
911 /// <summary></summary>
912 public string MediaURL;
913 /// <summary></summary>
914 public int MediaWidth;
915 /// <summary></summary>
916 public string MusicURL;
917 /// <summary></summary>
918 public string Name;
919 /// <summary></summary>
920 public bool ObscureMedia;
921 /// <summary></summary>
922 public bool ObscureMusic;
923 /// <summary></summary>
924 public ParcelFlags ParcelFlags;
925 /// <summary></summary>
926 public float PassHours;
927 /// <summary></summary>
928 public uint PassPrice;
929 /// <summary></summary>
930 public bool Privacy;
931 /// <summary></summary>
932 public uint SalePrice;
933 /// <summary></summary>
934 public UUID SnapshotID;
935 /// <summary></summary>
936 public Vector3 UserLocation;
937 /// <summary></summary>
938 public Vector3 UserLookAt;
939 /// <summary> true if avatars in this parcel should be invisible to people outside</summary>
940 public bool SeeAVs;
941 /// <summary> true if avatars outside can hear any sounds avatars inside play</summary>
942 public bool AnyAVSounds;
943 /// <summary> true if group members outside can hear any sounds avatars inside play</summary>
944 public bool GroupAVSounds;
945  
946 /// <summary>
947 /// Deserialize the message
948 /// </summary>
949 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
950 public void Deserialize(OSDMap map)
951 {
952 AuthBuyerID = map["auth_buyer_id"].AsUUID();
953 MediaAutoScale = map["auto_scale"].AsBoolean();
954 Category = (ParcelCategory)map["category"].AsInteger();
955 Desc = map["description"].AsString();
956 GroupID = map["group_id"].AsUUID();
957 Landing = (LandingType)map["landing_type"].AsUInteger();
958 LocalID = map["local_id"].AsInteger();
959 MediaDesc = map["media_desc"].AsString();
960 MediaHeight = map["media_height"].AsInteger();
961 MediaLoop = map["media_loop"].AsBoolean();
962 MediaID = map["media_id"].AsUUID();
963 MediaType = map["media_type"].AsString();
964 MediaURL = map["media_url"].AsString();
965 MediaWidth = map["media_width"].AsInteger();
966 MusicURL = map["music_url"].AsString();
967 Name = map["name"].AsString();
968 ObscureMedia = map["obscure_media"].AsBoolean();
969 ObscureMusic = map["obscure_music"].AsBoolean();
970 ParcelFlags = (ParcelFlags)map["parcel_flags"].AsUInteger();
971 PassHours = (float)map["pass_hours"].AsReal();
972 PassPrice = map["pass_price"].AsUInteger();
973 Privacy = map["privacy"].AsBoolean();
974 SalePrice = map["sale_price"].AsUInteger();
975 SnapshotID = map["snapshot_id"].AsUUID();
976 UserLocation = map["user_location"].AsVector3();
977 UserLookAt = map["user_look_at"].AsVector3();
978 if (map.ContainsKey("see_avs"))
979 {
980 SeeAVs = map["see_avs"].AsBoolean();
981 AnyAVSounds = map["any_av_sounds"].AsBoolean();
982 GroupAVSounds = map["group_av_sounds"].AsBoolean();
983 }
984 else
985 {
986 SeeAVs = true;
987 AnyAVSounds = true;
988 GroupAVSounds = true;
989 }
990 }
991  
992 /// <summary>
993 /// Serialize the object
994 /// </summary>
995 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
996 public OSDMap Serialize()
997 {
998 OSDMap map = new OSDMap();
999 map["auth_buyer_id"] = OSD.FromUUID(AuthBuyerID);
1000 map["auto_scale"] = OSD.FromBoolean(MediaAutoScale);
1001 map["category"] = OSD.FromInteger((byte)Category);
1002 map["description"] = OSD.FromString(Desc);
1003 map["flags"] = OSD.FromBinary(Utils.EmptyBytes);
1004 map["group_id"] = OSD.FromUUID(GroupID);
1005 map["landing_type"] = OSD.FromInteger((byte)Landing);
1006 map["local_id"] = OSD.FromInteger(LocalID);
1007 map["media_desc"] = OSD.FromString(MediaDesc);
1008 map["media_height"] = OSD.FromInteger(MediaHeight);
1009 map["media_id"] = OSD.FromUUID(MediaID);
1010 map["media_loop"] = OSD.FromBoolean(MediaLoop);
1011 map["media_type"] = OSD.FromString(MediaType);
1012 map["media_url"] = OSD.FromString(MediaURL);
1013 map["media_width"] = OSD.FromInteger(MediaWidth);
1014 map["music_url"] = OSD.FromString(MusicURL);
1015 map["name"] = OSD.FromString(Name);
1016 map["obscure_media"] = OSD.FromBoolean(ObscureMedia);
1017 map["obscure_music"] = OSD.FromBoolean(ObscureMusic);
1018 map["parcel_flags"] = OSD.FromUInteger((uint)ParcelFlags);
1019 map["pass_hours"] = OSD.FromReal(PassHours);
1020 map["privacy"] = OSD.FromBoolean(Privacy);
1021 map["pass_price"] = OSD.FromInteger(PassPrice);
1022 map["sale_price"] = OSD.FromInteger(SalePrice);
1023 map["snapshot_id"] = OSD.FromUUID(SnapshotID);
1024 map["user_location"] = OSD.FromVector3(UserLocation);
1025 map["user_look_at"] = OSD.FromVector3(UserLookAt);
1026 map["see_avs"] = OSD.FromBoolean(SeeAVs);
1027 map["any_av_sounds"] = OSD.FromBoolean(AnyAVSounds);
1028 map["group_av_sounds"] = OSD.FromBoolean(GroupAVSounds);
1029  
1030 return map;
1031 }
1032 }
1033  
1034 /// <summary>Base class used for the RemoteParcelRequest message</summary>
1035 [Serializable]
1036 public abstract class RemoteParcelRequestBlock
1037 {
1038 public abstract OSDMap Serialize();
1039 public abstract void Deserialize(OSDMap map);
1040 }
1041  
1042 /// <summary>
1043 /// A message sent from the viewer to the simulator to request information
1044 /// on a remote parcel
1045 /// </summary>
1046 public class RemoteParcelRequestRequest : RemoteParcelRequestBlock
1047 {
1048 /// <summary>Local sim position of the parcel we are looking up</summary>
1049 public Vector3 Location;
1050 /// <summary>Region handle of the parcel we are looking up</summary>
1051 public ulong RegionHandle;
1052 /// <summary>Region <see cref="UUID"/> of the parcel we are looking up</summary>
1053 public UUID RegionID;
1054  
1055 /// <summary>
1056 /// Serialize the object
1057 /// </summary>
1058 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1059 public override OSDMap Serialize()
1060 {
1061 OSDMap map = new OSDMap(3);
1062 map["location"] = OSD.FromVector3(Location);
1063 map["region_handle"] = OSD.FromULong(RegionHandle);
1064 map["region_id"] = OSD.FromUUID(RegionID);
1065 return map;
1066 }
1067  
1068 /// <summary>
1069 /// Deserialize the message
1070 /// </summary>
1071 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1072 public override void Deserialize(OSDMap map)
1073 {
1074 Location = map["location"].AsVector3();
1075 RegionHandle = map["region_handle"].AsULong();
1076 RegionID = map["region_id"].AsUUID();
1077 }
1078 }
1079  
1080 /// <summary>
1081 /// A message sent from the simulator to the viewer in response to a <see cref="RemoteParcelRequestRequest"/>
1082 /// which will contain parcel information
1083 /// </summary>
1084 [Serializable]
1085 public class RemoteParcelRequestReply : RemoteParcelRequestBlock
1086 {
1087 /// <summary>The grid-wide unique parcel ID</summary>
1088 public UUID ParcelID;
1089  
1090 /// <summary>
1091 /// Serialize the object
1092 /// </summary>
1093 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1094 public override OSDMap Serialize()
1095 {
1096 OSDMap map = new OSDMap(1);
1097 map["parcel_id"] = OSD.FromUUID(ParcelID);
1098 return map;
1099 }
1100  
1101 /// <summary>
1102 /// Deserialize the message
1103 /// </summary>
1104 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1105 public override void Deserialize(OSDMap map)
1106 {
1107 if (map == null || !map.ContainsKey("parcel_id"))
1108 ParcelID = UUID.Zero;
1109 else
1110 ParcelID = map["parcel_id"].AsUUID();
1111 }
1112 }
1113  
1114 /// <summary>
1115 /// A message containing a request for a remote parcel from a viewer, or a response
1116 /// from the simulator to that request
1117 /// </summary>
1118 [Serializable]
1119 public class RemoteParcelRequestMessage : IMessage
1120 {
1121 /// <summary>The request or response details block</summary>
1122 public RemoteParcelRequestBlock Request;
1123  
1124 /// <summary>
1125 /// Serialize the object
1126 /// </summary>
1127 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1128 public OSDMap Serialize()
1129 {
1130 return Request.Serialize();
1131 }
1132  
1133 /// <summary>
1134 /// Deserialize the message
1135 /// </summary>
1136 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1137 public void Deserialize(OSDMap map)
1138 {
1139 if (map.ContainsKey("parcel_id"))
1140 Request = new RemoteParcelRequestReply();
1141 else if (map.ContainsKey("location"))
1142 Request = new RemoteParcelRequestRequest();
1143 else
1144 Logger.Log("Unable to deserialize RemoteParcelRequest: No message handler exists for method: " + map.AsString(), Helpers.LogLevel.Warning);
1145  
1146 if (Request != null)
1147 Request.Deserialize(map);
1148 }
1149 }
1150 #endregion
1151  
1152 #region Inventory Messages
1153  
1154 public class NewFileAgentInventoryMessage : IMessage
1155 {
1156 public UUID FolderID;
1157 public AssetType AssetType;
1158 public InventoryType InventoryType;
1159 public string Name;
1160 public string Description;
1161 public PermissionMask EveryoneMask;
1162 public PermissionMask GroupMask;
1163 public PermissionMask NextOwnerMask;
1164  
1165 /// <summary>
1166 /// Serialize the object
1167 /// </summary>
1168 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1169 public OSDMap Serialize()
1170 {
1171 OSDMap map = new OSDMap(5);
1172 map["folder_id"] = OSD.FromUUID(FolderID);
1173 map["asset_type"] = OSD.FromString(Utils.AssetTypeToString(AssetType));
1174 map["inventory_type"] = OSD.FromString(Utils.InventoryTypeToString(InventoryType));
1175 map["name"] = OSD.FromString(Name);
1176 map["description"] = OSD.FromString(Description);
1177 map["everyone_mask"] = OSD.FromInteger((int)EveryoneMask);
1178 map["group_mask"] = OSD.FromInteger((int)GroupMask);
1179 map["next_owner_mask"] = OSD.FromInteger((int)NextOwnerMask);
1180  
1181 return map;
1182 }
1183  
1184 /// <summary>
1185 /// Deserialize the message
1186 /// </summary>
1187 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1188 public void Deserialize(OSDMap map)
1189 {
1190 FolderID = map["folder_id"].AsUUID();
1191 AssetType = Utils.StringToAssetType(map["asset_type"].AsString());
1192 InventoryType = Utils.StringToInventoryType(map["inventory_type"].AsString());
1193 Name = map["name"].AsString();
1194 Description = map["description"].AsString();
1195 EveryoneMask = (PermissionMask)map["everyone_mask"].AsInteger();
1196 GroupMask = (PermissionMask)map["group_mask"].AsInteger();
1197 NextOwnerMask = (PermissionMask)map["next_owner_mask"].AsInteger();
1198 }
1199 }
1200  
1201 public class NewFileAgentInventoryReplyMessage : IMessage
1202 {
1203 public string State;
1204 public Uri Uploader;
1205  
1206 public NewFileAgentInventoryReplyMessage()
1207 {
1208 State = "upload";
1209 }
1210  
1211 public OSDMap Serialize()
1212 {
1213 OSDMap map = new OSDMap();
1214 map["state"] = OSD.FromString(State);
1215 map["uploader"] = OSD.FromUri(Uploader);
1216  
1217 return map;
1218 }
1219  
1220 public void Deserialize(OSDMap map)
1221 {
1222 State = map["state"].AsString();
1223 Uploader = map["uploader"].AsUri();
1224 }
1225 }
1226  
1227 public class NewFileAgentInventoryVariablePriceMessage : IMessage
1228 {
1229 public UUID FolderID;
1230 public AssetType AssetType;
1231 public InventoryType InventoryType;
1232 public string Name;
1233 public string Description;
1234 public PermissionMask EveryoneMask;
1235 public PermissionMask GroupMask;
1236 public PermissionMask NextOwnerMask;
1237 // TODO: asset_resources?
1238  
1239 /// <summary>
1240 /// Serialize the object
1241 /// </summary>
1242 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1243 public OSDMap Serialize()
1244 {
1245 OSDMap map = new OSDMap();
1246 map["folder_id"] = OSD.FromUUID(FolderID);
1247 map["asset_type"] = OSD.FromString(Utils.AssetTypeToString(AssetType));
1248 map["inventory_type"] = OSD.FromString(Utils.InventoryTypeToString(InventoryType));
1249 map["name"] = OSD.FromString(Name);
1250 map["description"] = OSD.FromString(Description);
1251 map["everyone_mask"] = OSD.FromInteger((int)EveryoneMask);
1252 map["group_mask"] = OSD.FromInteger((int)GroupMask);
1253 map["next_owner_mask"] = OSD.FromInteger((int)NextOwnerMask);
1254  
1255 return map;
1256 }
1257  
1258 /// <summary>
1259 /// Deserialize the message
1260 /// </summary>
1261 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1262 public void Deserialize(OSDMap map)
1263 {
1264 FolderID = map["folder_id"].AsUUID();
1265 AssetType = Utils.StringToAssetType(map["asset_type"].AsString());
1266 InventoryType = Utils.StringToInventoryType(map["inventory_type"].AsString());
1267 Name = map["name"].AsString();
1268 Description = map["description"].AsString();
1269 EveryoneMask = (PermissionMask)map["everyone_mask"].AsInteger();
1270 GroupMask = (PermissionMask)map["group_mask"].AsInteger();
1271 NextOwnerMask = (PermissionMask)map["next_owner_mask"].AsInteger();
1272 }
1273 }
1274  
1275 public class NewFileAgentInventoryVariablePriceReplyMessage : IMessage
1276 {
1277 public int ResourceCost;
1278 public string State;
1279 public int UploadPrice;
1280 public Uri Rsvp;
1281  
1282 public NewFileAgentInventoryVariablePriceReplyMessage()
1283 {
1284 State = "confirm_upload";
1285 }
1286  
1287 public OSDMap Serialize()
1288 {
1289 OSDMap map = new OSDMap();
1290 map["resource_cost"] = OSD.FromInteger(ResourceCost);
1291 map["state"] = OSD.FromString(State);
1292 map["upload_price"] = OSD.FromInteger(UploadPrice);
1293 map["rsvp"] = OSD.FromUri(Rsvp);
1294  
1295 return map;
1296 }
1297  
1298 public void Deserialize(OSDMap map)
1299 {
1300 ResourceCost = map["resource_cost"].AsInteger();
1301 State = map["state"].AsString();
1302 UploadPrice = map["upload_price"].AsInteger();
1303 Rsvp = map["rsvp"].AsUri();
1304 }
1305 }
1306  
1307 public class NewFileAgentInventoryUploadReplyMessage : IMessage
1308 {
1309 public UUID NewInventoryItem;
1310 public UUID NewAsset;
1311 public string State;
1312 public PermissionMask NewBaseMask;
1313 public PermissionMask NewEveryoneMask;
1314 public PermissionMask NewOwnerMask;
1315 public PermissionMask NewNextOwnerMask;
1316  
1317 public NewFileAgentInventoryUploadReplyMessage()
1318 {
1319 State = "complete";
1320 }
1321  
1322 public OSDMap Serialize()
1323 {
1324 OSDMap map = new OSDMap();
1325 map["new_inventory_item"] = OSD.FromUUID(NewInventoryItem);
1326 map["new_asset"] = OSD.FromUUID(NewAsset);
1327 map["state"] = OSD.FromString(State);
1328 map["new_base_mask"] = OSD.FromInteger((int)NewBaseMask);
1329 map["new_everyone_mask"] = OSD.FromInteger((int)NewEveryoneMask);
1330 map["new_owner_mask"] = OSD.FromInteger((int)NewOwnerMask);
1331 map["new_next_owner_mask"] = OSD.FromInteger((int)NewNextOwnerMask);
1332  
1333 return map;
1334 }
1335  
1336 public void Deserialize(OSDMap map)
1337 {
1338 NewInventoryItem = map["new_inventory_item"].AsUUID();
1339 NewAsset = map["new_asset"].AsUUID();
1340 State = map["state"].AsString();
1341 NewBaseMask = (PermissionMask)map["new_base_mask"].AsInteger();
1342 NewEveryoneMask = (PermissionMask)map["new_everyone_mask"].AsInteger();
1343 NewOwnerMask = (PermissionMask)map["new_owner_mask"].AsInteger();
1344 NewNextOwnerMask = (PermissionMask)map["new_next_owner_mask"].AsInteger();
1345 }
1346 }
1347  
1348 public class BulkUpdateInventoryMessage : IMessage
1349 {
1350 public class FolderDataInfo
1351 {
1352 public UUID FolderID;
1353 public UUID ParentID;
1354 public string Name;
1355 public AssetType Type;
1356  
1357 public static FolderDataInfo FromOSD(OSD data)
1358 {
1359 FolderDataInfo ret = new FolderDataInfo();
1360  
1361 if (!(data is OSDMap)) return ret;
1362  
1363 OSDMap map = (OSDMap)data;
1364  
1365 ret.FolderID = map["FolderID"];
1366 ret.ParentID = map["ParentID"];
1367 ret.Name = map["Name"];
1368 ret.Type = (AssetType)map["Type"].AsInteger();
1369 return ret;
1370 }
1371 }
1372  
1373 public class ItemDataInfo
1374 {
1375 public UUID ItemID;
1376 public uint CallbackID;
1377 public UUID FolderID;
1378 public UUID CreatorID;
1379 public UUID OwnerID;
1380 public UUID GroupID;
1381 public PermissionMask BaseMask;
1382 public PermissionMask OwnerMask;
1383 public PermissionMask GroupMask;
1384 public PermissionMask EveryoneMask;
1385 public PermissionMask NextOwnerMask;
1386 public bool GroupOwned;
1387 public UUID AssetID;
1388 public AssetType Type;
1389 public InventoryType InvType;
1390 public uint Flags;
1391 public SaleType SaleType;
1392 public int SalePrice;
1393 public string Name;
1394 public string Description;
1395 public DateTime CreationDate;
1396 public uint CRC;
1397  
1398 public static ItemDataInfo FromOSD(OSD data)
1399 {
1400 ItemDataInfo ret = new ItemDataInfo();
1401  
1402 if (!(data is OSDMap)) return ret;
1403  
1404 OSDMap map = (OSDMap)data;
1405  
1406 ret.ItemID = map["ItemID"];
1407 ret.CallbackID = map["CallbackID"];
1408 ret.FolderID = map["FolderID"];
1409 ret.CreatorID = map["CreatorID"];
1410 ret.OwnerID = map["OwnerID"];
1411 ret.GroupID = map["GroupID"];
1412 ret.BaseMask = (PermissionMask)map["BaseMask"].AsUInteger();
1413 ret.OwnerMask = (PermissionMask)map["OwnerMask"].AsUInteger();
1414 ret.GroupMask = (PermissionMask)map["GroupMask"].AsUInteger();
1415 ret.EveryoneMask = (PermissionMask)map["EveryoneMask"].AsUInteger();
1416 ret.NextOwnerMask = (PermissionMask)map["NextOwnerMask"].AsUInteger();
1417 ret.GroupOwned = map["GroupOwned"];
1418 ret.AssetID = map["AssetID"];
1419 ret.Type = (AssetType)map["Type"].AsInteger();
1420 ret.InvType = (InventoryType)map["InvType"].AsInteger();
1421 ret.Flags = map["Flags"];
1422 ret.SaleType = (SaleType)map["SaleType"].AsInteger();
1423 ret.SalePrice = map["SaleType"];
1424 ret.Name = map["Name"];
1425 ret.Description = map["Description"];
1426 ret.CreationDate = Utils.UnixTimeToDateTime(map["CreationDate"]);
1427 ret.CRC = map["CRC"];
1428  
1429 return ret;
1430 }
1431 }
1432  
1433 public UUID AgentID;
1434 public UUID TransactionID;
1435 public FolderDataInfo[] FolderData;
1436 public ItemDataInfo[] ItemData;
1437  
1438 public OSDMap Serialize()
1439 {
1440 throw new NotImplementedException();
1441 }
1442  
1443 public void Deserialize(OSDMap map)
1444 {
1445 if (map["AgentData"] is OSDArray)
1446 {
1447 OSDArray array = (OSDArray)map["AgentData"];
1448 if (array.Count > 0)
1449 {
1450 OSDMap adata = (OSDMap)array[0];
1451 AgentID = adata["AgentID"];
1452 TransactionID = adata["TransactionID"];
1453 }
1454 }
1455  
1456 if (map["FolderData"] is OSDArray)
1457 {
1458 OSDArray array = (OSDArray)map["FolderData"];
1459 FolderData = new FolderDataInfo[array.Count];
1460 for (int i = 0; i < array.Count; i++)
1461 {
1462 FolderData[i] = FolderDataInfo.FromOSD(array[i]);
1463 }
1464 }
1465 else
1466 {
1467 FolderData = new FolderDataInfo[0];
1468 }
1469  
1470 if (map["ItemData"] is OSDArray)
1471 {
1472 OSDArray array = (OSDArray)map["ItemData"];
1473 ItemData = new ItemDataInfo[array.Count];
1474 for (int i = 0; i < array.Count; i++)
1475 {
1476 ItemData[i] = ItemDataInfo.FromOSD(array[i]);
1477 }
1478 }
1479 else
1480 {
1481 ItemData = new ItemDataInfo[0];
1482 }
1483 }
1484 }
1485  
1486 #endregion
1487  
1488 #region Agent Messages
1489  
1490 /// <summary>
1491 /// A message sent from the simulator to an agent which contains
1492 /// the groups the agent is in
1493 /// </summary>
1494 public class AgentGroupDataUpdateMessage : IMessage
1495 {
1496 /// <summary>The Agent receiving the message</summary>
1497 public UUID AgentID;
1498  
1499 /// <summary>Group Details specific to the agent</summary>
1500 public class GroupData
1501 {
1502 /// <summary>true of the agent accepts group notices</summary>
1503 public bool AcceptNotices;
1504 /// <summary>The agents tier contribution to the group</summary>
1505 public int Contribution;
1506 /// <summary>The Groups <seealso cref="UUID"/></summary>
1507 public UUID GroupID;
1508 /// <summary>The <seealso cref="UUID"/> of the groups insignia</summary>
1509 public UUID GroupInsigniaID;
1510 /// <summary>The name of the group</summary>
1511 public string GroupName;
1512 /// <summary>The aggregate permissions the agent has in the group for all roles the agent
1513 /// is assigned</summary>
1514 public GroupPowers GroupPowers;
1515 }
1516  
1517 /// <summary>An optional block containing additional agent specific information</summary>
1518 public class NewGroupData
1519 {
1520 /// <summary>true of the agent allows this group to be
1521 /// listed in their profile</summary>
1522 public bool ListInProfile;
1523 }
1524  
1525 /// <summary>An array containing <seealso cref="GroupData"/> information
1526 /// for each <see cref="Group"/> the agent is a member of</summary>
1527 public GroupData[] GroupDataBlock;
1528 /// <summary>An array containing <seealso cref="NewGroupData"/> information
1529 /// for each <see cref="Group"/> the agent is a member of</summary>
1530 public NewGroupData[] NewGroupDataBlock;
1531  
1532 /// <summary>
1533 /// Serialize the object
1534 /// </summary>
1535 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1536 public OSDMap Serialize()
1537 {
1538 OSDMap map = new OSDMap(3);
1539  
1540 OSDMap agent = new OSDMap(1);
1541 agent["AgentID"] = OSD.FromUUID(AgentID);
1542  
1543 OSDArray agentArray = new OSDArray();
1544 agentArray.Add(agent);
1545  
1546 map["AgentData"] = agentArray;
1547  
1548 OSDArray groupDataArray = new OSDArray(GroupDataBlock.Length);
1549  
1550 for (int i = 0; i < GroupDataBlock.Length; i++)
1551 {
1552 OSDMap group = new OSDMap(6);
1553 group["AcceptNotices"] = OSD.FromBoolean(GroupDataBlock[i].AcceptNotices);
1554 group["Contribution"] = OSD.FromInteger(GroupDataBlock[i].Contribution);
1555 group["GroupID"] = OSD.FromUUID(GroupDataBlock[i].GroupID);
1556 group["GroupInsigniaID"] = OSD.FromUUID(GroupDataBlock[i].GroupInsigniaID);
1557 group["GroupName"] = OSD.FromString(GroupDataBlock[i].GroupName);
1558 group["GroupPowers"] = OSD.FromLong((long)GroupDataBlock[i].GroupPowers);
1559 groupDataArray.Add(group);
1560 }
1561  
1562 map["GroupData"] = groupDataArray;
1563  
1564 OSDArray newGroupDataArray = new OSDArray(NewGroupDataBlock.Length);
1565  
1566 for (int i = 0; i < NewGroupDataBlock.Length; i++)
1567 {
1568 OSDMap group = new OSDMap(1);
1569 group["ListInProfile"] = OSD.FromBoolean(NewGroupDataBlock[i].ListInProfile);
1570 newGroupDataArray.Add(group);
1571 }
1572  
1573 map["NewGroupData"] = newGroupDataArray;
1574  
1575 return map;
1576 }
1577  
1578 /// <summary>
1579 /// Deserialize the message
1580 /// </summary>
1581 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1582 public void Deserialize(OSDMap map)
1583 {
1584 OSDArray agentArray = (OSDArray)map["AgentData"];
1585 OSDMap agentMap = (OSDMap)agentArray[0];
1586 AgentID = agentMap["AgentID"].AsUUID();
1587  
1588 OSDArray groupArray = (OSDArray)map["GroupData"];
1589  
1590 GroupDataBlock = new GroupData[groupArray.Count];
1591  
1592 for (int i = 0; i < groupArray.Count; i++)
1593 {
1594 OSDMap groupMap = (OSDMap)groupArray[i];
1595  
1596 GroupData groupData = new GroupData();
1597  
1598 groupData.GroupID = groupMap["GroupID"].AsUUID();
1599 groupData.Contribution = groupMap["Contribution"].AsInteger();
1600 groupData.GroupInsigniaID = groupMap["GroupInsigniaID"].AsUUID();
1601 groupData.GroupName = groupMap["GroupName"].AsString();
1602 groupData.GroupPowers = (GroupPowers)groupMap["GroupPowers"].AsLong();
1603 groupData.AcceptNotices = groupMap["AcceptNotices"].AsBoolean();
1604 GroupDataBlock[i] = groupData;
1605 }
1606  
1607 // If request for current groups came very close to login
1608 // the Linden sim will not include the NewGroupData block, but
1609 // it will instead set all ListInProfile fields to false
1610 if (map.ContainsKey("NewGroupData"))
1611 {
1612 OSDArray newGroupArray = (OSDArray)map["NewGroupData"];
1613  
1614 NewGroupDataBlock = new NewGroupData[newGroupArray.Count];
1615  
1616 for (int i = 0; i < newGroupArray.Count; i++)
1617 {
1618 OSDMap newGroupMap = (OSDMap)newGroupArray[i];
1619 NewGroupData newGroupData = new NewGroupData();
1620 newGroupData.ListInProfile = newGroupMap["ListInProfile"].AsBoolean();
1621 NewGroupDataBlock[i] = newGroupData;
1622 }
1623 }
1624 else
1625 {
1626 NewGroupDataBlock = new NewGroupData[GroupDataBlock.Length];
1627 for (int i = 0; i < NewGroupDataBlock.Length; i++)
1628 {
1629 NewGroupData newGroupData = new NewGroupData();
1630 newGroupData.ListInProfile = false;
1631 NewGroupDataBlock[i] = newGroupData;
1632 }
1633 }
1634 }
1635 }
1636  
1637 /// <summary>
1638 /// A message sent from the viewer to the simulator which
1639 /// specifies the language and permissions for others to detect
1640 /// the language specified
1641 /// </summary>
1642 public class UpdateAgentLanguageMessage : IMessage
1643 {
1644 /// <summary>A string containng the default language
1645 /// to use for the agent</summary>
1646 public string Language;
1647 /// <summary>true of others are allowed to
1648 /// know the language setting</summary>
1649 public bool LanguagePublic;
1650  
1651 /// <summary>
1652 /// Serialize the object
1653 /// </summary>
1654 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1655 public OSDMap Serialize()
1656 {
1657 OSDMap map = new OSDMap(2);
1658  
1659 map["language"] = OSD.FromString(Language);
1660 map["language_is_public"] = OSD.FromBoolean(LanguagePublic);
1661  
1662 return map;
1663 }
1664  
1665 /// <summary>
1666 /// Deserialize the message
1667 /// </summary>
1668 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1669 public void Deserialize(OSDMap map)
1670 {
1671 LanguagePublic = map["language_is_public"].AsBoolean();
1672 Language = map["language"].AsString();
1673 }
1674 }
1675  
1676 /// <summary>
1677 /// An EventQueue message sent from the simulator to an agent when the agent
1678 /// leaves a group
1679 /// </summary>
1680 public class AgentDropGroupMessage : IMessage
1681 {
1682 /// <summary>An object containing the Agents UUID, and the Groups UUID</summary>
1683 public class AgentData
1684 {
1685 /// <summary>The ID of the Agent leaving the group</summary>
1686 public UUID AgentID;
1687 /// <summary>The GroupID the Agent is leaving</summary>
1688 public UUID GroupID;
1689 }
1690  
1691 /// <summary>
1692 /// An Array containing the AgentID and GroupID
1693 /// </summary>
1694 public AgentData[] AgentDataBlock;
1695  
1696 /// <summary>
1697 /// Serialize the object
1698 /// </summary>
1699 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1700 public OSDMap Serialize()
1701 {
1702 OSDMap map = new OSDMap(1);
1703  
1704 OSDArray agentDataArray = new OSDArray(AgentDataBlock.Length);
1705  
1706 for (int i = 0; i < AgentDataBlock.Length; i++)
1707 {
1708 OSDMap agentMap = new OSDMap(2);
1709 agentMap["AgentID"] = OSD.FromUUID(AgentDataBlock[i].AgentID);
1710 agentMap["GroupID"] = OSD.FromUUID(AgentDataBlock[i].GroupID);
1711 agentDataArray.Add(agentMap);
1712 }
1713 map["AgentData"] = agentDataArray;
1714  
1715 return map;
1716 }
1717  
1718 /// <summary>
1719 /// Deserialize the message
1720 /// </summary>
1721 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1722 public void Deserialize(OSDMap map)
1723 {
1724 OSDArray agentDataArray = (OSDArray)map["AgentData"];
1725  
1726 AgentDataBlock = new AgentData[agentDataArray.Count];
1727  
1728 for (int i = 0; i < agentDataArray.Count; i++)
1729 {
1730 OSDMap agentMap = (OSDMap)agentDataArray[i];
1731 AgentData agentData = new AgentData();
1732  
1733 agentData.AgentID = agentMap["AgentID"].AsUUID();
1734 agentData.GroupID = agentMap["GroupID"].AsUUID();
1735  
1736 AgentDataBlock[i] = agentData;
1737 }
1738 }
1739 }
1740  
1741 public class AgentStateUpdateMessage : IMessage
1742 {
1743 public OSDMap RawData;
1744 public bool CanModifyNavmesh;
1745 public bool HasModifiedNavmesh;
1746 public string MaxAccess; // PG, M, A
1747 public bool AlterNavmeshObjects;
1748 public bool AlterPermanentObjects;
1749 public int GodLevel;
1750 public string Language;
1751 public bool LanguageIsPublic;
1752  
1753 public void Deserialize(OSDMap map)
1754 {
1755 RawData = map;
1756 CanModifyNavmesh = map["can_modify_navmesh"];
1757 HasModifiedNavmesh = map["has_modified_navmesh"];
1758 if (map["preferences"] is OSDMap)
1759 {
1760 OSDMap prefs = (OSDMap)map["preferences"];
1761 AlterNavmeshObjects = prefs["alter_navmesh_objects"];
1762 AlterPermanentObjects = prefs["alter_permanent_objects"];
1763 GodLevel = prefs["god_level"];
1764 Language = prefs["language"];
1765 LanguageIsPublic = prefs["language_is_public"];
1766 if (prefs["access_prefs"] is OSDMap)
1767 {
1768 OSDMap access = (OSDMap)prefs["access_prefs"];
1769 MaxAccess = access["max"];
1770 }
1771 }
1772 }
1773  
1774 public OSDMap Serialize()
1775 {
1776 RawData = new OSDMap();
1777 RawData["can_modify_navmesh"] = CanModifyNavmesh;
1778 RawData["has_modified_navmesh"] = HasModifiedNavmesh;
1779  
1780 OSDMap prefs = new OSDMap();
1781 {
1782 OSDMap access = new OSDMap();
1783 {
1784 access["max"] = MaxAccess;
1785 }
1786 prefs["access_prefs"] = access;
1787 prefs["alter_navmesh_objects"] = AlterNavmeshObjects;
1788 prefs["alter_permanent_objects"] = AlterPermanentObjects;
1789 prefs["god_level"] = GodLevel;
1790 prefs["language"] = Language;
1791 prefs["language_is_public"] = LanguageIsPublic;
1792 }
1793 RawData["preferences"] = prefs;
1794 return RawData;
1795 }
1796  
1797 }
1798  
1799 /// <summary>Base class for Asset uploads/results via Capabilities</summary>
1800 public abstract class AssetUploaderBlock
1801 {
1802 /// <summary>
1803 /// The request state
1804 /// </summary>
1805 public string State;
1806  
1807 /// <summary>
1808 /// Serialize the object
1809 /// </summary>
1810 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1811 public abstract OSDMap Serialize();
1812  
1813 /// <summary>
1814 /// Deserialize the message
1815 /// </summary>
1816 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1817 public abstract void Deserialize(OSDMap map);
1818 }
1819  
1820 /// <summary>
1821 /// A message sent from the viewer to the simulator to request a temporary upload capability
1822 /// which allows an asset to be uploaded
1823 /// </summary>
1824 public class UploaderRequestUpload : AssetUploaderBlock
1825 {
1826 /// <summary>The Capability URL sent by the simulator to upload the baked texture to</summary>
1827 public Uri Url;
1828  
1829 public UploaderRequestUpload()
1830 {
1831 State = "upload";
1832 }
1833  
1834 public override OSDMap Serialize()
1835 {
1836 OSDMap map = new OSDMap(2);
1837 map["state"] = OSD.FromString(State);
1838 map["uploader"] = OSD.FromUri(Url);
1839  
1840 return map;
1841 }
1842  
1843 public override void Deserialize(OSDMap map)
1844 {
1845 Url = map["uploader"].AsUri();
1846 State = map["state"].AsString();
1847 }
1848 }
1849  
1850 /// <summary>
1851 /// A message sent from the simulator that will inform the agent the upload is complete,
1852 /// and the UUID of the uploaded asset
1853 /// </summary>
1854 public class UploaderRequestComplete : AssetUploaderBlock
1855 {
1856 /// <summary>The uploaded texture asset ID</summary>
1857 public UUID AssetID;
1858  
1859 public UploaderRequestComplete()
1860 {
1861 State = "complete";
1862 }
1863  
1864 public override OSDMap Serialize()
1865 {
1866 OSDMap map = new OSDMap(2);
1867 map["state"] = OSD.FromString(State);
1868 map["new_asset"] = OSD.FromUUID(AssetID);
1869  
1870 return map;
1871 }
1872  
1873 public override void Deserialize(OSDMap map)
1874 {
1875 AssetID = map["new_asset"].AsUUID();
1876 State = map["state"].AsString();
1877 }
1878 }
1879  
1880 /// <summary>
1881 /// A message sent from the viewer to the simulator to request a temporary
1882 /// capability URI which is used to upload an agents baked appearance textures
1883 /// </summary>
1884 public class UploadBakedTextureMessage : IMessage
1885 {
1886 /// <summary>Object containing request or response</summary>
1887 public AssetUploaderBlock Request;
1888  
1889 /// <summary>
1890 /// Serialize the object
1891 /// </summary>
1892 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1893 public OSDMap Serialize()
1894 {
1895 return Request.Serialize();
1896 }
1897  
1898 /// <summary>
1899 /// Deserialize the message
1900 /// </summary>
1901 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1902 public void Deserialize(OSDMap map)
1903 {
1904 if (map.ContainsKey("state") && map["state"].AsString().Equals("upload"))
1905 Request = new UploaderRequestUpload();
1906 else if (map.ContainsKey("state") && map["state"].AsString().Equals("complete"))
1907 Request = new UploaderRequestComplete();
1908 else
1909 Logger.Log("Unable to deserialize UploadBakedTexture: No message handler exists for state " + map["state"].AsString(), Helpers.LogLevel.Warning);
1910  
1911 if (Request != null)
1912 Request.Deserialize(map);
1913 }
1914 }
1915 #endregion
1916  
1917 #region Voice Messages
1918 /// <summary>
1919 /// A message sent from the simulator which indicates the minimum version required for
1920 /// using voice chat
1921 /// </summary>
1922 public class RequiredVoiceVersionMessage : IMessage
1923 {
1924 /// <summary>Major Version Required</summary>
1925 public int MajorVersion;
1926 /// <summary>Minor version required</summary>
1927 public int MinorVersion;
1928 /// <summary>The name of the region sending the version requrements</summary>
1929 public string RegionName;
1930  
1931 /// <summary>
1932 /// Serialize the object
1933 /// </summary>
1934 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1935 public OSDMap Serialize()
1936 {
1937 OSDMap map = new OSDMap(4);
1938 map["major_version"] = OSD.FromInteger(MajorVersion);
1939 map["minor_version"] = OSD.FromInteger(MinorVersion);
1940 map["region_name"] = OSD.FromString(RegionName);
1941  
1942 return map;
1943 }
1944  
1945 /// <summary>
1946 /// Deserialize the message
1947 /// </summary>
1948 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1949 public void Deserialize(OSDMap map)
1950 {
1951 MajorVersion = map["major_version"].AsInteger();
1952 MinorVersion = map["minor_version"].AsInteger();
1953 RegionName = map["region_name"].AsString();
1954 }
1955 }
1956  
1957 /// <summary>
1958 /// A message sent from the simulator to the viewer containing the
1959 /// voice server URI
1960 /// </summary>
1961 public class ParcelVoiceInfoRequestMessage : IMessage
1962 {
1963 /// <summary>The Parcel ID which the voice server URI applies</summary>
1964 public int ParcelID;
1965 /// <summary>The name of the region</summary>
1966 public string RegionName;
1967 /// <summary>A uri containing the server/channel information
1968 /// which the viewer can utilize to participate in voice conversations</summary>
1969 public Uri SipChannelUri;
1970  
1971 /// <summary>
1972 /// Serialize the object
1973 /// </summary>
1974 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
1975 public OSDMap Serialize()
1976 {
1977 OSDMap map = new OSDMap(3);
1978 map["parcel_local_id"] = OSD.FromInteger(ParcelID);
1979 map["region_name"] = OSD.FromString(RegionName);
1980  
1981 OSDMap vcMap = new OSDMap(1);
1982 vcMap["channel_uri"] = OSD.FromUri(SipChannelUri);
1983  
1984 map["voice_credentials"] = vcMap;
1985  
1986 return map;
1987 }
1988  
1989 /// <summary>
1990 /// Deserialize the message
1991 /// </summary>
1992 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
1993 public void Deserialize(OSDMap map)
1994 {
1995 ParcelID = map["parcel_local_id"].AsInteger();
1996 RegionName = map["region_name"].AsString();
1997  
1998 OSDMap vcMap = (OSDMap)map["voice_credentials"];
1999 SipChannelUri = vcMap["channel_uri"].AsUri();
2000 }
2001 }
2002  
2003 /// <summary>
2004 ///
2005 /// </summary>
2006 public class ProvisionVoiceAccountRequestMessage : IMessage
2007 {
2008 /// <summary></summary>
2009 public string Password;
2010 /// <summary></summary>
2011 public string Username;
2012  
2013 /// <summary>
2014 /// Serialize the object
2015 /// </summary>
2016 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2017 public OSDMap Serialize()
2018 {
2019 OSDMap map = new OSDMap(2);
2020  
2021 map["username"] = OSD.FromString(Username);
2022 map["password"] = OSD.FromString(Password);
2023  
2024 return map;
2025 }
2026  
2027 /// <summary>
2028 /// Deserialize the message
2029 /// </summary>
2030 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2031 public void Deserialize(OSDMap map)
2032 {
2033 Username = map["username"].AsString();
2034 Password = map["password"].AsString();
2035 }
2036 }
2037  
2038 #endregion
2039  
2040 #region Script/Notecards Messages
2041 /// <summary>
2042 /// A message sent by the viewer to the simulator to request a temporary
2043 /// capability for a script contained with in a Tasks inventory to be updated
2044 /// </summary>
2045 public class UploadScriptTaskMessage : IMessage
2046 {
2047 /// <summary>Object containing request or response</summary>
2048 public AssetUploaderBlock Request;
2049  
2050 /// <summary>
2051 /// Serialize the object
2052 /// </summary>
2053 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2054 public OSDMap Serialize()
2055 {
2056 return Request.Serialize();
2057 }
2058  
2059 /// <summary>
2060 /// Deserialize the message
2061 /// </summary>
2062 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2063 public void Deserialize(OSDMap map)
2064 {
2065 if (map.ContainsKey("state") && map["state"].Equals("upload"))
2066 Request = new UploaderRequestUpload();
2067 else if (map.ContainsKey("state") && map["state"].Equals("complete"))
2068 Request = new UploaderRequestComplete();
2069 else
2070 Logger.Log("Unable to deserialize UploadScriptTask: No message handler exists for state " + map["state"].AsString(), Helpers.LogLevel.Warning);
2071  
2072 Request.Deserialize(map);
2073 }
2074 }
2075  
2076 /// <summary>
2077 /// A message sent from the simulator to the viewer to indicate
2078 /// a Tasks scripts status.
2079 /// </summary>
2080 public class ScriptRunningReplyMessage : IMessage
2081 {
2082 /// <summary>The Asset ID of the script</summary>
2083 public UUID ItemID;
2084 /// <summary>True of the script is compiled/ran using the mono interpreter, false indicates it
2085 /// uses the older less efficient lsl2 interprter</summary>
2086 public bool Mono;
2087 /// <summary>The Task containing the scripts <seealso cref="UUID"/></summary>
2088 public UUID ObjectID;
2089 /// <summary>true of the script is in a running state</summary>
2090 public bool Running;
2091  
2092 /// <summary>
2093 /// Serialize the object
2094 /// </summary>
2095 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2096 public OSDMap Serialize()
2097 {
2098 OSDMap map = new OSDMap(2);
2099  
2100 OSDMap scriptMap = new OSDMap(4);
2101 scriptMap["ItemID"] = OSD.FromUUID(ItemID);
2102 scriptMap["Mono"] = OSD.FromBoolean(Mono);
2103 scriptMap["ObjectID"] = OSD.FromUUID(ObjectID);
2104 scriptMap["Running"] = OSD.FromBoolean(Running);
2105  
2106 OSDArray scriptArray = new OSDArray(1);
2107 scriptArray.Add((OSD)scriptMap);
2108  
2109 map["Script"] = scriptArray;
2110  
2111 return map;
2112 }
2113  
2114 /// <summary>
2115 /// Deserialize the message
2116 /// </summary>
2117 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2118 public void Deserialize(OSDMap map)
2119 {
2120 OSDArray scriptArray = (OSDArray)map["Script"];
2121  
2122 OSDMap scriptMap = (OSDMap)scriptArray[0];
2123  
2124 ItemID = scriptMap["ItemID"].AsUUID();
2125 Mono = scriptMap["Mono"].AsBoolean();
2126 ObjectID = scriptMap["ObjectID"].AsUUID();
2127 Running = scriptMap["Running"].AsBoolean();
2128 }
2129 }
2130  
2131 /// <summary>
2132 /// A message containing the request/response used for updating a gesture
2133 /// contained with an agents inventory
2134 /// </summary>
2135 public class UpdateGestureAgentInventoryMessage : IMessage
2136 {
2137 /// <summary>Object containing request or response</summary>
2138 public AssetUploaderBlock Request;
2139  
2140 /// <summary>
2141 /// Serialize the object
2142 /// </summary>
2143 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2144 public OSDMap Serialize()
2145 {
2146 return Request.Serialize();
2147 }
2148  
2149 /// <summary>
2150 /// Deserialize the message
2151 /// </summary>
2152 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2153 public void Deserialize(OSDMap map)
2154 {
2155 if (map.ContainsKey("item_id"))
2156 Request = new UpdateAgentInventoryRequestMessage();
2157 else if (map.ContainsKey("state") && map["state"].AsString().Equals("upload"))
2158 Request = new UploaderRequestUpload();
2159 else if (map.ContainsKey("state") && map["state"].AsString().Equals("complete"))
2160 Request = new UploaderRequestComplete();
2161 else
2162 Logger.Log("Unable to deserialize UpdateGestureAgentInventory: No message handler exists: " + map.AsString(), Helpers.LogLevel.Warning);
2163  
2164 if (Request != null)
2165 Request.Deserialize(map);
2166 }
2167 }
2168  
2169 /// <summary>
2170 /// A message request/response which is used to update a notecard contained within
2171 /// a tasks inventory
2172 /// </summary>
2173 public class UpdateNotecardTaskInventoryMessage : IMessage
2174 {
2175 /// <summary>The <seealso cref="UUID"/> of the Task containing the notecard asset to update</summary>
2176 public UUID TaskID;
2177 /// <summary>The notecard assets <seealso cref="UUID"/> contained in the tasks inventory</summary>
2178 public UUID ItemID;
2179  
2180 /// <summary>
2181 /// Serialize the object
2182 /// </summary>
2183 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2184 public OSDMap Serialize()
2185 {
2186 OSDMap map = new OSDMap(1);
2187 map["task_id"] = OSD.FromUUID(TaskID);
2188 map["item_id"] = OSD.FromUUID(ItemID);
2189  
2190 return map;
2191 }
2192  
2193 /// <summary>
2194 /// Deserialize the message
2195 /// </summary>
2196 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2197 public void Deserialize(OSDMap map)
2198 {
2199 TaskID = map["task_id"].AsUUID();
2200 ItemID = map["item_id"].AsUUID();
2201 }
2202 }
2203  
2204 // TODO: Add Test
2205 /// <summary>
2206 /// A reusable class containing a message sent from the viewer to the simulator to request a temporary uploader capability
2207 /// which is used to update an asset in an agents inventory
2208 /// </summary>
2209 public class UpdateAgentInventoryRequestMessage : AssetUploaderBlock
2210 {
2211 /// <summary>
2212 /// The Notecard AssetID to replace
2213 /// </summary>
2214 public UUID ItemID;
2215  
2216 /// <summary>
2217 /// Serialize the object
2218 /// </summary>
2219 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2220 public override OSDMap Serialize()
2221 {
2222 OSDMap map = new OSDMap(1);
2223 map["item_id"] = OSD.FromUUID(ItemID);
2224  
2225 return map;
2226 }
2227  
2228 /// <summary>
2229 /// Deserialize the message
2230 /// </summary>
2231 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2232 public override void Deserialize(OSDMap map)
2233 {
2234 ItemID = map["item_id"].AsUUID();
2235 }
2236 }
2237  
2238 /// <summary>
2239 /// A message containing the request/response used for updating a notecard
2240 /// contained with an agents inventory
2241 /// </summary>
2242 public class UpdateNotecardAgentInventoryMessage : IMessage
2243 {
2244 /// <summary>Object containing request or response</summary>
2245 public AssetUploaderBlock Request;
2246  
2247 /// <summary>
2248 /// Serialize the object
2249 /// </summary>
2250 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2251 public OSDMap Serialize()
2252 {
2253 return Request.Serialize();
2254 }
2255  
2256 /// <summary>
2257 /// Deserialize the message
2258 /// </summary>
2259 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2260 public void Deserialize(OSDMap map)
2261 {
2262 if (map.ContainsKey("item_id"))
2263 Request = new UpdateAgentInventoryRequestMessage();
2264 else if (map.ContainsKey("state") && map["state"].AsString().Equals("upload"))
2265 Request = new UploaderRequestUpload();
2266 else if (map.ContainsKey("state") && map["state"].AsString().Equals("complete"))
2267 Request = new UploaderRequestComplete();
2268 else
2269 Logger.Log("Unable to deserialize UpdateNotecardAgentInventory: No message handler exists for state " + map["state"].AsString(), Helpers.LogLevel.Warning);
2270  
2271 if (Request != null)
2272 Request.Deserialize(map);
2273 }
2274 }
2275  
2276 public class CopyInventoryFromNotecardMessage : IMessage
2277 {
2278 public int CallbackID;
2279 public UUID FolderID;
2280 public UUID ItemID;
2281 public UUID NotecardID;
2282 public UUID ObjectID;
2283  
2284 /// <summary>
2285 /// Serialize the object
2286 /// </summary>
2287 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2288 public OSDMap Serialize()
2289 {
2290 OSDMap map = new OSDMap(5);
2291 map["callback-id"] = OSD.FromInteger(CallbackID);
2292 map["folder-id"] = OSD.FromUUID(FolderID);
2293 map["item-id"] = OSD.FromUUID(ItemID);
2294 map["notecard-id"] = OSD.FromUUID(NotecardID);
2295 map["object-id"] = OSD.FromUUID(ObjectID);
2296  
2297 return map;
2298 }
2299  
2300 /// <summary>
2301 /// Deserialize the message
2302 /// </summary>
2303 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2304 public void Deserialize(OSDMap map)
2305 {
2306 CallbackID = map["callback-id"].AsInteger();
2307 FolderID = map["folder-id"].AsUUID();
2308 ItemID = map["item-id"].AsUUID();
2309 NotecardID = map["notecard-id"].AsUUID();
2310 ObjectID = map["object-id"].AsUUID();
2311 }
2312 }
2313  
2314 /// <summary>
2315 /// A message sent from the simulator to the viewer which indicates
2316 /// an error occurred while attempting to update a script in an agents or tasks
2317 /// inventory
2318 /// </summary>
2319 public class UploaderScriptRequestError : AssetUploaderBlock
2320 {
2321 /// <summary>true of the script was successfully compiled by the simulator</summary>
2322 public bool Compiled;
2323 /// <summary>A string containing the error which occured while trying
2324 /// to update the script</summary>
2325 public string Error;
2326 /// <summary>A new AssetID assigned to the script</summary>
2327 public UUID AssetID;
2328  
2329 public override OSDMap Serialize()
2330 {
2331 OSDMap map = new OSDMap(4);
2332 map["state"] = OSD.FromString(State);
2333 map["new_asset"] = OSD.FromUUID(AssetID);
2334 map["compiled"] = OSD.FromBoolean(Compiled);
2335  
2336 OSDArray errorsArray = new OSDArray();
2337 errorsArray.Add(Error);
2338  
2339  
2340 map["errors"] = errorsArray;
2341 return map;
2342 }
2343  
2344 public override void Deserialize(OSDMap map)
2345 {
2346 AssetID = map["new_asset"].AsUUID();
2347 Compiled = map["compiled"].AsBoolean();
2348 State = map["state"].AsString();
2349  
2350 OSDArray errorsArray = (OSDArray)map["errors"];
2351 Error = errorsArray[0].AsString();
2352 }
2353 }
2354  
2355 /// <summary>
2356 /// A message sent from the viewer to the simulator
2357 /// requesting the update of an existing script contained
2358 /// within a tasks inventory
2359 /// </summary>
2360 public class UpdateScriptTaskUpdateMessage : AssetUploaderBlock
2361 {
2362 /// <summary>if true, set the script mode to running</summary>
2363 public bool ScriptRunning;
2364 /// <summary>The scripts InventoryItem ItemID to update</summary>
2365 public UUID ItemID;
2366 /// <summary>A lowercase string containing either "mono" or "lsl2" which
2367 /// specifies the script is compiled and ran on the mono runtime, or the older
2368 /// lsl runtime</summary>
2369 public string Target; // mono or lsl2
2370 /// <summary>The tasks <see cref="UUID"/> which contains the script to update</summary>
2371 public UUID TaskID;
2372  
2373 /// <summary>
2374 /// Serialize the object
2375 /// </summary>
2376 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2377 public override OSDMap Serialize()
2378 {
2379 OSDMap map = new OSDMap(4);
2380 map["is_script_running"] = OSD.FromBoolean(ScriptRunning);
2381 map["item_id"] = OSD.FromUUID(ItemID);
2382 map["target"] = OSD.FromString(Target);
2383 map["task_id"] = OSD.FromUUID(TaskID);
2384 return map;
2385 }
2386  
2387 /// <summary>
2388 /// Deserialize the message
2389 /// </summary>
2390 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2391 public override void Deserialize(OSDMap map)
2392 {
2393 ScriptRunning = map["is_script_running"].AsBoolean();
2394 ItemID = map["item_id"].AsUUID();
2395 Target = map["target"].AsString();
2396 TaskID = map["task_id"].AsUUID();
2397 }
2398 }
2399  
2400 /// <summary>
2401 /// A message containing either the request or response used in updating a script inside
2402 /// a tasks inventory
2403 /// </summary>
2404 public class UpdateScriptTaskMessage : IMessage
2405 {
2406 /// <summary>Object containing request or response</summary>
2407 public AssetUploaderBlock Request;
2408  
2409 /// <summary>
2410 /// Serialize the object
2411 /// </summary>
2412 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2413 public OSDMap Serialize()
2414 {
2415 return Request.Serialize();
2416 }
2417  
2418 /// <summary>
2419 /// Deserialize the message
2420 /// </summary>
2421 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2422 public void Deserialize(OSDMap map)
2423 {
2424 if (map.ContainsKey("task_id"))
2425 Request = new UpdateScriptTaskUpdateMessage();
2426 else if (map.ContainsKey("state") && map["state"].AsString().Equals("upload"))
2427 Request = new UploaderRequestUpload();
2428 else if (map.ContainsKey("state") && map["state"].AsString().Equals("complete")
2429 && map.ContainsKey("errors"))
2430 Request = new UploaderScriptRequestError();
2431 else if (map.ContainsKey("state") && map["state"].AsString().Equals("complete"))
2432 Request = new UploaderRequestScriptComplete();
2433 else
2434 Logger.Log("Unable to deserialize UpdateScriptTaskMessage: No message handler exists for state " + map["state"].AsString(), Helpers.LogLevel.Warning);
2435  
2436 if (Request != null)
2437 Request.Deserialize(map);
2438 }
2439 }
2440  
2441 /// <summary>
2442 /// Response from the simulator to notify the viewer the upload is completed, and
2443 /// the UUID of the script asset and its compiled status
2444 /// </summary>
2445 public class UploaderRequestScriptComplete : AssetUploaderBlock
2446 {
2447 /// <summary>The uploaded texture asset ID</summary>
2448 public UUID AssetID;
2449 /// <summary>true of the script was compiled successfully</summary>
2450 public bool Compiled;
2451  
2452 public UploaderRequestScriptComplete()
2453 {
2454 State = "complete";
2455 }
2456  
2457 public override OSDMap Serialize()
2458 {
2459 OSDMap map = new OSDMap(2);
2460 map["state"] = OSD.FromString(State);
2461 map["new_asset"] = OSD.FromUUID(AssetID);
2462 map["compiled"] = OSD.FromBoolean(Compiled);
2463 return map;
2464 }
2465  
2466 public override void Deserialize(OSDMap map)
2467 {
2468 AssetID = map["new_asset"].AsUUID();
2469 Compiled = map["compiled"].AsBoolean();
2470 }
2471 }
2472  
2473 /// <summary>
2474 /// A message sent from a viewer to the simulator requesting a temporary uploader capability
2475 /// used to update a script contained in an agents inventory
2476 /// </summary>
2477 public class UpdateScriptAgentRequestMessage : AssetUploaderBlock
2478 {
2479 /// <summary>The existing asset if of the script in the agents inventory to replace</summary>
2480 public UUID ItemID;
2481 /// <summary>The language of the script</summary>
2482 /// <remarks>Defaults to lsl version 2, "mono" might be another possible option</remarks>
2483 public string Target = "lsl2"; // lsl2
2484  
2485 /// <summary>
2486 /// Serialize the object
2487 /// </summary>
2488 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2489 public override OSDMap Serialize()
2490 {
2491 OSDMap map = new OSDMap(2);
2492 map["item_id"] = OSD.FromUUID(ItemID);
2493 map["target"] = OSD.FromString(Target);
2494 return map;
2495 }
2496  
2497 /// <summary>
2498 /// Deserialize the message
2499 /// </summary>
2500 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2501 public override void Deserialize(OSDMap map)
2502 {
2503 ItemID = map["item_id"].AsUUID();
2504 Target = map["target"].AsString();
2505 }
2506 }
2507  
2508 /// <summary>
2509 /// A message containing either the request or response used in updating a script inside
2510 /// an agents inventory
2511 /// </summary>
2512 public class UpdateScriptAgentMessage : IMessage
2513 {
2514 /// <summary>Object containing request or response</summary>
2515 public AssetUploaderBlock Request;
2516  
2517 /// <summary>
2518 /// Serialize the object
2519 /// </summary>
2520 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2521 public OSDMap Serialize()
2522 {
2523 return Request.Serialize();
2524 }
2525  
2526 /// <summary>
2527 /// Deserialize the message
2528 /// </summary>
2529 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2530 public void Deserialize(OSDMap map)
2531 {
2532 if (map.ContainsKey("item_id"))
2533 Request = new UpdateScriptAgentRequestMessage();
2534 else if (map.ContainsKey("errors"))
2535 Request = new UploaderScriptRequestError();
2536 else if (map.ContainsKey("state") && map["state"].AsString().Equals("upload"))
2537 Request = new UploaderRequestUpload();
2538 else if (map.ContainsKey("state") && map["state"].AsString().Equals("complete"))
2539 Request = new UploaderRequestScriptComplete();
2540 else
2541 Logger.Log("Unable to deserialize UpdateScriptAgent: No message handler exists for state " + map["state"].AsString(), Helpers.LogLevel.Warning);
2542  
2543 if (Request != null)
2544 Request.Deserialize(map);
2545 }
2546 }
2547  
2548  
2549 public class SendPostcardMessage : IMessage
2550 {
2551 public string FromEmail;
2552 public string Message;
2553 public string FromName;
2554 public Vector3 GlobalPosition;
2555 public string Subject;
2556 public string ToEmail;
2557  
2558 /// <summary>
2559 /// Serialize the object
2560 /// </summary>
2561 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2562 public OSDMap Serialize()
2563 {
2564 OSDMap map = new OSDMap(6);
2565 map["from"] = OSD.FromString(FromEmail);
2566 map["msg"] = OSD.FromString(Message);
2567 map["name"] = OSD.FromString(FromName);
2568 map["pos-global"] = OSD.FromVector3(GlobalPosition);
2569 map["subject"] = OSD.FromString(Subject);
2570 map["to"] = OSD.FromString(ToEmail);
2571 return map;
2572 }
2573  
2574 /// <summary>
2575 /// Deserialize the message
2576 /// </summary>
2577 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2578 public void Deserialize(OSDMap map)
2579 {
2580 FromEmail = map["from"].AsString();
2581 Message = map["msg"].AsString();
2582 FromName = map["name"].AsString();
2583 GlobalPosition = map["pos-global"].AsVector3();
2584 Subject = map["subject"].AsString();
2585 ToEmail = map["to"].AsString();
2586 }
2587 }
2588  
2589 #endregion
2590  
2591 #region Grid/Maps
2592  
2593 /// <summary>Base class for Map Layers via Capabilities</summary>
2594 public abstract class MapLayerMessageBase
2595 {
2596 /// <summary></summary>
2597 public int Flags;
2598  
2599 /// <summary>
2600 /// Serialize the object
2601 /// </summary>
2602 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2603 public abstract OSDMap Serialize();
2604  
2605 /// <summary>
2606 /// Deserialize the message
2607 /// </summary>
2608 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2609 public abstract void Deserialize(OSDMap map);
2610 }
2611  
2612 /// <summary>
2613 /// Sent by an agent to the capabilities server to request map layers
2614 /// </summary>
2615 public class MapLayerRequestVariant : MapLayerMessageBase
2616 {
2617 public override OSDMap Serialize()
2618 {
2619 OSDMap map = new OSDMap(1);
2620 map["Flags"] = OSD.FromInteger(Flags);
2621 return map;
2622 }
2623  
2624 public override void Deserialize(OSDMap map)
2625 {
2626 Flags = map["Flags"].AsInteger();
2627 }
2628 }
2629  
2630 /// <summary>
2631 /// A message sent from the simulator to the viewer which contains an array of map images and their grid coordinates
2632 /// </summary>
2633 public class MapLayerReplyVariant : MapLayerMessageBase
2634 {
2635 /// <summary>
2636 /// An object containing map location details
2637 /// </summary>
2638 public class LayerData
2639 {
2640 /// <summary>The Asset ID of the regions tile overlay</summary>
2641 public UUID ImageID;
2642 /// <summary>The grid location of the southern border of the map tile</summary>
2643 public int Bottom;
2644 /// <summary>The grid location of the western border of the map tile</summary>
2645 public int Left;
2646 /// <summary>The grid location of the eastern border of the map tile</summary>
2647 public int Right;
2648 /// <summary>The grid location of the northern border of the map tile</summary>
2649 public int Top;
2650 }
2651  
2652 /// <summary>An array containing LayerData items</summary>
2653 public LayerData[] LayerDataBlocks;
2654  
2655 /// <summary>
2656 /// Serialize the object
2657 /// </summary>
2658 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2659 public override OSDMap Serialize()
2660 {
2661 OSDMap map = new OSDMap(2);
2662 OSDMap agentMap = new OSDMap(1);
2663 agentMap["Flags"] = OSD.FromInteger(Flags);
2664 map["AgentData"] = agentMap;
2665  
2666 OSDArray layerArray = new OSDArray(LayerDataBlocks.Length);
2667  
2668 for (int i = 0; i < LayerDataBlocks.Length; i++)
2669 {
2670 OSDMap layerMap = new OSDMap(5);
2671 layerMap["ImageID"] = OSD.FromUUID(LayerDataBlocks[i].ImageID);
2672 layerMap["Bottom"] = OSD.FromInteger(LayerDataBlocks[i].Bottom);
2673 layerMap["Left"] = OSD.FromInteger(LayerDataBlocks[i].Left);
2674 layerMap["Top"] = OSD.FromInteger(LayerDataBlocks[i].Top);
2675 layerMap["Right"] = OSD.FromInteger(LayerDataBlocks[i].Right);
2676  
2677 layerArray.Add(layerMap);
2678 }
2679  
2680 map["LayerData"] = layerArray;
2681  
2682 return map;
2683 }
2684  
2685 /// <summary>
2686 /// Deserialize the message
2687 /// </summary>
2688 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2689 public override void Deserialize(OSDMap map)
2690 {
2691 OSDMap agentMap = (OSDMap)map["AgentData"];
2692 Flags = agentMap["Flags"].AsInteger();
2693  
2694 OSDArray layerArray = (OSDArray)map["LayerData"];
2695  
2696 LayerDataBlocks = new LayerData[layerArray.Count];
2697  
2698 for (int i = 0; i < LayerDataBlocks.Length; i++)
2699 {
2700 OSDMap layerMap = (OSDMap)layerArray[i];
2701  
2702 LayerData layer = new LayerData();
2703 layer.ImageID = layerMap["ImageID"].AsUUID();
2704 layer.Top = layerMap["Top"].AsInteger();
2705 layer.Right = layerMap["Right"].AsInteger();
2706 layer.Left = layerMap["Left"].AsInteger();
2707 layer.Bottom = layerMap["Bottom"].AsInteger();
2708  
2709 LayerDataBlocks[i] = layer;
2710 }
2711 }
2712 }
2713  
2714 public class MapLayerMessage : IMessage
2715 {
2716 /// <summary>Object containing request or response</summary>
2717 public MapLayerMessageBase Request;
2718  
2719 /// <summary>
2720 /// Serialize the object
2721 /// </summary>
2722 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2723 public OSDMap Serialize()
2724 {
2725 return Request.Serialize();
2726 }
2727  
2728 /// <summary>
2729 /// Deserialize the message
2730 /// </summary>
2731 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2732 public void Deserialize(OSDMap map)
2733 {
2734 if (map.ContainsKey("LayerData"))
2735 Request = new MapLayerReplyVariant();
2736 else if (map.ContainsKey("Flags"))
2737 Request = new MapLayerRequestVariant();
2738 else
2739 Logger.Log("Unable to deserialize MapLayerMessage: No message handler exists", Helpers.LogLevel.Warning);
2740  
2741 if (Request != null)
2742 Request.Deserialize(map);
2743 }
2744 }
2745  
2746 #endregion
2747  
2748 #region Session/Communication
2749  
2750 /// <summary>
2751 /// New as of 1.23 RC1, no details yet.
2752 /// </summary>
2753 public class ProductInfoRequestMessage : IMessage
2754 {
2755 /// <summary>
2756 /// Serialize the object
2757 /// </summary>
2758 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2759 public OSDMap Serialize()
2760 {
2761 throw new NotImplementedException();
2762 }
2763  
2764 /// <summary>
2765 /// Deserialize the message
2766 /// </summary>
2767 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2768 public void Deserialize(OSDMap map)
2769 {
2770 throw new NotImplementedException();
2771 }
2772 }
2773  
2774 #region ChatSessionRequestMessage
2775  
2776  
2777 public abstract class SearchStatRequestBlock
2778 {
2779 public abstract OSDMap Serialize();
2780 public abstract void Deserialize(OSDMap map);
2781 }
2782  
2783 // variant A - the request to the simulator
2784 public class SearchStatRequestRequest : SearchStatRequestBlock
2785 {
2786 public UUID ClassifiedID;
2787  
2788 public override OSDMap Serialize()
2789 {
2790 OSDMap map = new OSDMap(1);
2791 map["classified_id"] = OSD.FromUUID(ClassifiedID);
2792 return map;
2793 }
2794  
2795 public override void Deserialize(OSDMap map)
2796 {
2797 ClassifiedID = map["classified_id"].AsUUID();
2798 }
2799 }
2800  
2801 public class SearchStatRequestReply : SearchStatRequestBlock
2802 {
2803 public int MapClicks;
2804 public int ProfileClicks;
2805 public int SearchMapClicks;
2806 public int SearchProfileClicks;
2807 public int SearchTeleportClicks;
2808 public int TeleportClicks;
2809  
2810 public override OSDMap Serialize()
2811 {
2812 OSDMap map = new OSDMap(6);
2813 map["map_clicks"] = OSD.FromInteger(MapClicks);
2814 map["profile_clicks"] = OSD.FromInteger(ProfileClicks);
2815 map["search_map_clicks"] = OSD.FromInteger(SearchMapClicks);
2816 map["search_profile_clicks"] = OSD.FromInteger(SearchProfileClicks);
2817 map["search_teleport_clicks"] = OSD.FromInteger(SearchTeleportClicks);
2818 map["teleport_clicks"] = OSD.FromInteger(TeleportClicks);
2819 return map;
2820 }
2821  
2822 public override void Deserialize(OSDMap map)
2823 {
2824 MapClicks = map["map_clicks"].AsInteger();
2825 ProfileClicks = map["profile_clicks"].AsInteger();
2826 SearchMapClicks = map["search_map_clicks"].AsInteger();
2827 SearchProfileClicks = map["search_profile_clicks"].AsInteger();
2828 SearchTeleportClicks = map["search_teleport_clicks"].AsInteger();
2829 TeleportClicks = map["teleport_clicks"].AsInteger();
2830 }
2831 }
2832  
2833 public class SearchStatRequestMessage : IMessage
2834 {
2835 public SearchStatRequestBlock Request;
2836  
2837 /// <summary>
2838 /// Serialize the object
2839 /// </summary>
2840 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2841 public OSDMap Serialize()
2842 {
2843 return Request.Serialize();
2844 }
2845  
2846 /// <summary>
2847 /// Deserialize the message
2848 /// </summary>
2849 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2850 public void Deserialize(OSDMap map)
2851 {
2852 if (map.ContainsKey("map_clicks"))
2853 Request = new SearchStatRequestReply();
2854 else if (map.ContainsKey("classified_id"))
2855 Request = new SearchStatRequestRequest();
2856 else
2857 Logger.Log("Unable to deserialize SearchStatRequest: No message handler exists for method " + map["method"].AsString(), Helpers.LogLevel.Warning);
2858  
2859 Request.Deserialize(map);
2860 }
2861 }
2862  
2863 public abstract class ChatSessionRequestBlock
2864 {
2865 /// <summary>A string containing the method used</summary>
2866 public string Method;
2867  
2868 public abstract OSDMap Serialize();
2869 public abstract void Deserialize(OSDMap map);
2870 }
2871  
2872 /// <summary>
2873 /// A request sent from an agent to the Simulator to begin a new conference.
2874 /// Contains a list of Agents which will be included in the conference
2875 /// </summary>
2876 public class ChatSessionRequestStartConference : ChatSessionRequestBlock
2877 {
2878 /// <summary>An array containing the <see cref="UUID"/> of the agents invited to this conference</summary>
2879 public UUID[] AgentsBlock;
2880 /// <summary>The conferences Session ID</summary>
2881 public UUID SessionID;
2882  
2883 public ChatSessionRequestStartConference()
2884 {
2885 Method = "start conference";
2886 }
2887  
2888 /// <summary>
2889 /// Serialize the object
2890 /// </summary>
2891 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2892 public override OSDMap Serialize()
2893 {
2894 OSDMap map = new OSDMap(3);
2895 map["method"] = OSD.FromString(Method);
2896 OSDArray agentsArray = new OSDArray();
2897 for (int i = 0; i < AgentsBlock.Length; i++)
2898 {
2899 agentsArray.Add(OSD.FromUUID(AgentsBlock[i]));
2900 }
2901 map["params"] = agentsArray;
2902 map["session-id"] = OSD.FromUUID(SessionID);
2903  
2904 return map;
2905 }
2906  
2907 /// <summary>
2908 /// Deserialize the message
2909 /// </summary>
2910 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2911 public override void Deserialize(OSDMap map)
2912 {
2913 Method = map["method"].AsString();
2914 OSDArray agentsArray = (OSDArray)map["params"];
2915  
2916 AgentsBlock = new UUID[agentsArray.Count];
2917  
2918 for (int i = 0; i < agentsArray.Count; i++)
2919 {
2920 AgentsBlock[i] = agentsArray[i].AsUUID();
2921 }
2922  
2923 SessionID = map["session-id"].AsUUID();
2924 }
2925 }
2926  
2927 /// <summary>
2928 /// A moderation request sent from a conference moderator
2929 /// Contains an agent and an optional action to take
2930 /// </summary>
2931 public class ChatSessionRequestMuteUpdate : ChatSessionRequestBlock
2932 {
2933 /// <summary>The Session ID</summary>
2934 public UUID SessionID;
2935 /// <summary></summary>
2936 public UUID AgentID;
2937 /// <summary>A list containing Key/Value pairs, known valid values:
2938 /// key: text value: true/false - allow/disallow specified agents ability to use text in session
2939 /// key: voice value: true/false - allow/disallow specified agents ability to use voice in session
2940 /// </summary>
2941 /// <remarks>"text" or "voice"</remarks>
2942 public string RequestKey;
2943 /// <summary></summary>
2944 public bool RequestValue;
2945  
2946 public ChatSessionRequestMuteUpdate()
2947 {
2948 Method = "mute update";
2949 }
2950  
2951 /// <summary>
2952 /// Serialize the object
2953 /// </summary>
2954 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
2955 public override OSDMap Serialize()
2956 {
2957 OSDMap map = new OSDMap(3);
2958 map["method"] = OSD.FromString(Method);
2959  
2960 OSDMap muteMap = new OSDMap(1);
2961 muteMap[RequestKey] = OSD.FromBoolean(RequestValue);
2962  
2963 OSDMap paramMap = new OSDMap(2);
2964 paramMap["agent_id"] = OSD.FromUUID(AgentID);
2965 paramMap["mute_info"] = muteMap;
2966  
2967 map["params"] = paramMap;
2968 map["session-id"] = OSD.FromUUID(SessionID);
2969  
2970 return map;
2971 }
2972  
2973 /// <summary>
2974 /// Deserialize the message
2975 /// </summary>
2976 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
2977 public override void Deserialize(OSDMap map)
2978 {
2979 Method = map["method"].AsString();
2980 SessionID = map["session-id"].AsUUID();
2981  
2982 OSDMap paramsMap = (OSDMap)map["params"];
2983 OSDMap muteMap = (OSDMap)paramsMap["mute_info"];
2984  
2985 AgentID = paramsMap["agent_id"].AsUUID();
2986  
2987 if (muteMap.ContainsKey("text"))
2988 RequestKey = "text";
2989 else if (muteMap.ContainsKey("voice"))
2990 RequestKey = "voice";
2991  
2992 RequestValue = muteMap[RequestKey].AsBoolean();
2993 }
2994 }
2995  
2996 /// <summary>
2997 /// A message sent from the agent to the simulator which tells the
2998 /// simulator we've accepted a conference invitation
2999 /// </summary>
3000 public class ChatSessionAcceptInvitation : ChatSessionRequestBlock
3001 {
3002 /// <summary>The conference SessionID</summary>
3003 public UUID SessionID;
3004  
3005 public ChatSessionAcceptInvitation()
3006 {
3007 Method = "accept invitation";
3008 }
3009  
3010 /// <summary>
3011 /// Serialize the object
3012 /// </summary>
3013 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3014 public override OSDMap Serialize()
3015 {
3016 OSDMap map = new OSDMap(2);
3017 map["method"] = OSD.FromString(Method);
3018 map["session-id"] = OSD.FromUUID(SessionID);
3019 return map;
3020 }
3021  
3022 /// <summary>
3023 /// Deserialize the message
3024 /// </summary>
3025 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3026 public override void Deserialize(OSDMap map)
3027 {
3028 Method = map["method"].AsString();
3029 SessionID = map["session-id"].AsUUID();
3030 }
3031 }
3032  
3033 public class ChatSessionRequestMessage : IMessage
3034 {
3035 public ChatSessionRequestBlock Request;
3036  
3037 /// <summary>
3038 /// Serialize the object
3039 /// </summary>
3040 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3041 public OSDMap Serialize()
3042 {
3043 return Request.Serialize();
3044 }
3045  
3046 /// <summary>
3047 /// Deserialize the message
3048 /// </summary>
3049 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3050 public void Deserialize(OSDMap map)
3051 {
3052 if (map.ContainsKey("method") && map["method"].AsString().Equals("start conference"))
3053 Request = new ChatSessionRequestStartConference();
3054 else if (map.ContainsKey("method") && map["method"].AsString().Equals("mute update"))
3055 Request = new ChatSessionRequestMuteUpdate();
3056 else if (map.ContainsKey("method") && map["method"].AsString().Equals("accept invitation"))
3057 Request = new ChatSessionAcceptInvitation();
3058 else
3059 Logger.Log("Unable to deserialize ChatSessionRequest: No message handler exists for method " + map["method"].AsString(), Helpers.LogLevel.Warning);
3060  
3061 Request.Deserialize(map);
3062 }
3063 }
3064  
3065 #endregion
3066  
3067 public class ChatterboxSessionEventReplyMessage : IMessage
3068 {
3069 public UUID SessionID;
3070 public bool Success;
3071  
3072 /// <summary>
3073 /// Serialize the object
3074 /// </summary>
3075 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3076 public OSDMap Serialize()
3077 {
3078 OSDMap map = new OSDMap(2);
3079 map["success"] = OSD.FromBoolean(Success);
3080 map["session_id"] = OSD.FromUUID(SessionID); // FIXME: Verify this is correct map name
3081  
3082 return map;
3083 }
3084  
3085 /// <summary>
3086 /// Deserialize the message
3087 /// </summary>
3088 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3089 public void Deserialize(OSDMap map)
3090 {
3091 Success = map["success"].AsBoolean();
3092 SessionID = map["session_id"].AsUUID();
3093 }
3094 }
3095  
3096 public class ChatterBoxSessionStartReplyMessage : IMessage
3097 {
3098 public UUID SessionID;
3099 public UUID TempSessionID;
3100 public bool Success;
3101  
3102 public string SessionName;
3103 // FIXME: Replace int with an enum
3104 public int Type;
3105 public bool VoiceEnabled;
3106 public bool ModeratedVoice;
3107  
3108 /* Is Text moderation possible? */
3109  
3110 /// <summary>
3111 /// Serialize the object
3112 /// </summary>
3113 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3114 public OSDMap Serialize()
3115 {
3116 OSDMap moderatedMap = new OSDMap(1);
3117 moderatedMap["voice"] = OSD.FromBoolean(ModeratedVoice);
3118  
3119 OSDMap sessionMap = new OSDMap(4);
3120 sessionMap["type"] = OSD.FromInteger(Type);
3121 sessionMap["session_name"] = OSD.FromString(SessionName);
3122 sessionMap["voice_enabled"] = OSD.FromBoolean(VoiceEnabled);
3123 sessionMap["moderated_mode"] = moderatedMap;
3124  
3125 OSDMap map = new OSDMap(4);
3126 map["session_id"] = OSD.FromUUID(SessionID);
3127 map["temp_session_id"] = OSD.FromUUID(TempSessionID);
3128 map["success"] = OSD.FromBoolean(Success);
3129 map["session_info"] = sessionMap;
3130  
3131 return map;
3132 }
3133  
3134 /// <summary>
3135 /// Deserialize the message
3136 /// </summary>
3137 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3138 public void Deserialize(OSDMap map)
3139 {
3140 SessionID = map["session_id"].AsUUID();
3141 TempSessionID = map["temp_session_id"].AsUUID();
3142 Success = map["success"].AsBoolean();
3143  
3144 if (Success)
3145 {
3146 OSDMap sessionMap = (OSDMap)map["session_info"];
3147 SessionName = sessionMap["session_name"].AsString();
3148 Type = sessionMap["type"].AsInteger();
3149 VoiceEnabled = sessionMap["voice_enabled"].AsBoolean();
3150  
3151 OSDMap moderatedModeMap = (OSDMap)sessionMap["moderated_mode"];
3152 ModeratedVoice = moderatedModeMap["voice"].AsBoolean();
3153 }
3154 }
3155 }
3156  
3157 public class ChatterBoxInvitationMessage : IMessage
3158 {
3159 /// <summary>Key of sender</summary>
3160 public UUID FromAgentID;
3161 /// <summary>Name of sender</summary>
3162 public string FromAgentName;
3163 /// <summary>Key of destination avatar</summary>
3164 public UUID ToAgentID;
3165 /// <summary>ID of originating estate</summary>
3166 public uint ParentEstateID;
3167 /// <summary>Key of originating region</summary>
3168 public UUID RegionID;
3169 /// <summary>Coordinates in originating region</summary>
3170 public Vector3 Position;
3171 /// <summary>Instant message type</summary>
3172 public InstantMessageDialog Dialog;
3173 /// <summary>Group IM session toggle</summary>
3174 public bool GroupIM;
3175 /// <summary>Key of IM session, for Group Messages, the groups UUID</summary>
3176 public UUID IMSessionID;
3177 /// <summary>Timestamp of the instant message</summary>
3178 public DateTime Timestamp;
3179 /// <summary>Instant message text</summary>
3180 public string Message;
3181 /// <summary>Whether this message is held for offline avatars</summary>
3182 public InstantMessageOnline Offline;
3183 /// <summary>Context specific packed data</summary>
3184 public byte[] BinaryBucket;
3185 /// <summary>Is this invitation for voice group/conference chat</summary>
3186 public bool Voice;
3187  
3188 /// <summary>
3189 /// Serialize the object
3190 /// </summary>
3191 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3192 public OSDMap Serialize()
3193 {
3194 OSDMap dataMap = new OSDMap(3);
3195 dataMap["timestamp"] = OSD.FromDate(Timestamp);
3196 dataMap["type"] = OSD.FromInteger((uint)Dialog);
3197 dataMap["binary_bucket"] = OSD.FromBinary(BinaryBucket);
3198  
3199 OSDMap paramsMap = new OSDMap(11);
3200 paramsMap["from_id"] = OSD.FromUUID(FromAgentID);
3201 paramsMap["from_name"] = OSD.FromString(FromAgentName);
3202 paramsMap["to_id"] = OSD.FromUUID(ToAgentID);
3203 paramsMap["parent_estate_id"] = OSD.FromInteger(ParentEstateID);
3204 paramsMap["region_id"] = OSD.FromUUID(RegionID);
3205 paramsMap["position"] = OSD.FromVector3(Position);
3206 paramsMap["from_group"] = OSD.FromBoolean(GroupIM);
3207 paramsMap["id"] = OSD.FromUUID(IMSessionID);
3208 paramsMap["message"] = OSD.FromString(Message);
3209 paramsMap["offline"] = OSD.FromInteger((uint)Offline);
3210  
3211 paramsMap["data"] = dataMap;
3212  
3213 OSDMap imMap = new OSDMap(1);
3214 imMap["message_params"] = paramsMap;
3215  
3216 OSDMap map = new OSDMap(1);
3217 map["instantmessage"] = imMap;
3218  
3219 return map;
3220 }
3221  
3222 /// <summary>
3223 /// Deserialize the message
3224 /// </summary>
3225 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3226 public void Deserialize(OSDMap map)
3227 {
3228 if (map.ContainsKey("voice"))
3229 {
3230 FromAgentID = map["from_id"].AsUUID();
3231 FromAgentName = map["from_name"].AsString();
3232 IMSessionID = map["session_id"].AsUUID();
3233 BinaryBucket = Utils.StringToBytes(map["session_name"].AsString());
3234 Voice = true;
3235 }
3236 else
3237 {
3238 OSDMap im = (OSDMap)map["instantmessage"];
3239 OSDMap msg = (OSDMap)im["message_params"];
3240 OSDMap msgdata = (OSDMap)msg["data"];
3241  
3242 FromAgentID = msg["from_id"].AsUUID();
3243 FromAgentName = msg["from_name"].AsString();
3244 ToAgentID = msg["to_id"].AsUUID();
3245 ParentEstateID = (uint)msg["parent_estate_id"].AsInteger();
3246 RegionID = msg["region_id"].AsUUID();
3247 Position = msg["position"].AsVector3();
3248 GroupIM = msg["from_group"].AsBoolean();
3249 IMSessionID = msg["id"].AsUUID();
3250 Message = msg["message"].AsString();
3251 Offline = (InstantMessageOnline)msg["offline"].AsInteger();
3252 Dialog = (InstantMessageDialog)msgdata["type"].AsInteger();
3253 BinaryBucket = msgdata["binary_bucket"].AsBinary();
3254 Timestamp = msgdata["timestamp"].AsDate();
3255 Voice = false;
3256 }
3257 }
3258 }
3259  
3260 public class RegionInfoMessage : IMessage
3261 {
3262 public int ParcelLocalID;
3263 public string RegionName;
3264 public string ChannelUri;
3265  
3266 #region IMessage Members
3267  
3268 public OSDMap Serialize()
3269 {
3270 OSDMap map = new OSDMap(3);
3271 map["parcel_local_id"] = OSD.FromInteger(ParcelLocalID);
3272 map["region_name"] = OSD.FromString(RegionName);
3273 OSDMap voiceMap = new OSDMap(1);
3274 voiceMap["channel_uri"] = OSD.FromString(ChannelUri);
3275 map["voice_credentials"] = voiceMap;
3276 return map;
3277 }
3278  
3279 public void Deserialize(OSDMap map)
3280 {
3281 this.ParcelLocalID = map["parcel_local_id"].AsInteger();
3282 this.RegionName = map["region_name"].AsString();
3283 OSDMap voiceMap = (OSDMap)map["voice_credentials"];
3284 this.ChannelUri = voiceMap["channel_uri"].AsString();
3285 }
3286  
3287 #endregion
3288 }
3289  
3290 /// <summary>
3291 /// Sent from the simulator to the viewer.
3292 ///
3293 /// When an agent initially joins a session the AgentUpdatesBlock object will contain a list of session members including
3294 /// a boolean indicating they can use voice chat in this session, a boolean indicating they are allowed to moderate
3295 /// this session, and lastly a string which indicates another agent is entering the session with the Transition set to "ENTER"
3296 ///
3297 /// During the session lifetime updates on individuals are sent. During the update the booleans sent during the initial join are
3298 /// excluded with the exception of the Transition field. This indicates a new user entering or exiting the session with
3299 /// the string "ENTER" or "LEAVE" respectively.
3300 /// </summary>
3301 public class ChatterBoxSessionAgentListUpdatesMessage : IMessage
3302 {
3303 // initial when agent joins session
3304 // <llsd><map><key>events</key><array><map><key>body</key><map><key>agent_updates</key><map><key>32939971-a520-4b52-8ca5-6085d0e39933</key><map><key>info</key><map><key>can_voice_chat</key><boolean>1</boolean><key>is_moderator</key><boolean>1</boolean></map><key>transition</key><string>ENTER</string></map><key>ca00e3e1-0fdb-4136-8ed4-0aab739b29e8</key><map><key>info</key><map><key>can_voice_chat</key><boolean>1</boolean><key>is_moderator</key><boolean>0</boolean></map><key>transition</key><string>ENTER</string></map></map><key>session_id</key><string>be7a1def-bd8a-5043-5d5b-49e3805adf6b</string><key>updates</key><map><key>32939971-a520-4b52-8ca5-6085d0e39933</key><string>ENTER</string><key>ca00e3e1-0fdb-4136-8ed4-0aab739b29e8</key><string>ENTER</string></map></map><key>message</key><string>ChatterBoxSessionAgentListUpdates</string></map><map><key>body</key><map><key>agent_updates</key><map><key>32939971-a520-4b52-8ca5-6085d0e39933</key><map><key>info</key><map><key>can_voice_chat</key><boolean>1</boolean><key>is_moderator</key><boolean>1</boolean></map></map></map><key>session_id</key><string>be7a1def-bd8a-5043-5d5b-49e3805adf6b</string><key>updates</key><map /></map><key>message</key><string>ChatterBoxSessionAgentListUpdates</string></map></array><key>id</key><integer>5</integer></map></llsd>
3305  
3306 // a message containing only moderator updates
3307 // <llsd><map><key>events</key><array><map><key>body</key><map><key>agent_updates</key><map><key>ca00e3e1-0fdb-4136-8ed4-0aab739b29e8</key><map><key>info</key><map><key>mutes</key><map><key>text</key><boolean>1</boolean></map></map></map></map><key>session_id</key><string>be7a1def-bd8a-5043-5d5b-49e3805adf6b</string><key>updates</key><map /></map><key>message</key><string>ChatterBoxSessionAgentListUpdates</string></map></array><key>id</key><integer>7</integer></map></llsd>
3308  
3309 public UUID SessionID;
3310  
3311 public class AgentUpdatesBlock
3312 {
3313 public UUID AgentID;
3314  
3315 public bool CanVoiceChat;
3316 public bool IsModerator;
3317 // transition "transition" = "ENTER" or "LEAVE"
3318 public string Transition; // TODO: switch to an enum "ENTER" or "LEAVE"
3319  
3320 public bool MuteText;
3321 public bool MuteVoice;
3322 }
3323  
3324 public AgentUpdatesBlock[] Updates;
3325  
3326 /// <summary>
3327 /// Serialize the object
3328 /// </summary>
3329 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3330 public OSDMap Serialize()
3331 {
3332 OSDMap map = new OSDMap();
3333  
3334 OSDMap agent_updatesMap = new OSDMap(1);
3335 for (int i = 0; i < Updates.Length; i++)
3336 {
3337 OSDMap mutesMap = new OSDMap(2);
3338 mutesMap["text"] = OSD.FromBoolean(Updates[i].MuteText);
3339 mutesMap["voice"] = OSD.FromBoolean(Updates[i].MuteVoice);
3340  
3341 OSDMap infoMap = new OSDMap(4);
3342 infoMap["can_voice_chat"] = OSD.FromBoolean((bool)Updates[i].CanVoiceChat);
3343 infoMap["is_moderator"] = OSD.FromBoolean((bool)Updates[i].IsModerator);
3344 infoMap["mutes"] = mutesMap;
3345  
3346 OSDMap imap = new OSDMap(1);
3347 imap["info"] = infoMap;
3348 imap["transition"] = OSD.FromString(Updates[i].Transition);
3349  
3350 agent_updatesMap.Add(Updates[i].AgentID.ToString(), imap);
3351 }
3352  
3353 map.Add("agent_updates", agent_updatesMap);
3354  
3355 map["session_id"] = OSD.FromUUID(SessionID);
3356  
3357 return map;
3358 }
3359  
3360 /// <summary>
3361 /// Deserialize the message
3362 /// </summary>
3363 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3364 public void Deserialize(OSDMap map)
3365 {
3366  
3367 OSDMap agent_updates = (OSDMap)map["agent_updates"];
3368 SessionID = map["session_id"].AsUUID();
3369  
3370 List<AgentUpdatesBlock> updatesList = new List<AgentUpdatesBlock>();
3371  
3372 foreach (KeyValuePair<string, OSD> kvp in agent_updates)
3373 {
3374  
3375 if (kvp.Key == "updates")
3376 {
3377 // This appears to be redundant and duplicated by the info block, more dumps will confirm this
3378 /* <key>32939971-a520-4b52-8ca5-6085d0e39933</key>
3379 <string>ENTER</string> */
3380 }
3381 else if (kvp.Key == "session_id")
3382 {
3383 // I am making the assumption that each osdmap will contain the information for a
3384 // single session. This is how the map appears to read however more dumps should be taken
3385 // to confirm this.
3386 /* <key>session_id</key>
3387 <string>984f6a1e-4ceb-6366-8d5e-a18c6819c6f7</string> */
3388  
3389 }
3390 else // key is an agent uuid (we hope!)
3391 {
3392 // should be the agents uuid as the key, and "info" as the datablock
3393 /* <key>32939971-a520-4b52-8ca5-6085d0e39933</key>
3394 <map>
3395 <key>info</key>
3396 <map>
3397 <key>can_voice_chat</key>
3398 <boolean>1</boolean>
3399 <key>is_moderator</key>
3400 <boolean>1</boolean>
3401 </map>
3402 <key>transition</key>
3403 <string>ENTER</string>
3404 </map>*/
3405 AgentUpdatesBlock block = new AgentUpdatesBlock();
3406 block.AgentID = UUID.Parse(kvp.Key);
3407  
3408 OSDMap infoMap = (OSDMap)agent_updates[kvp.Key];
3409  
3410 OSDMap agentPermsMap = (OSDMap)infoMap["info"];
3411  
3412 block.CanVoiceChat = agentPermsMap["can_voice_chat"].AsBoolean();
3413 block.IsModerator = agentPermsMap["is_moderator"].AsBoolean();
3414  
3415 block.Transition = infoMap["transition"].AsString();
3416  
3417 if (agentPermsMap.ContainsKey("mutes"))
3418 {
3419 OSDMap mutesMap = (OSDMap)agentPermsMap["mutes"];
3420 block.MuteText = mutesMap["text"].AsBoolean();
3421 block.MuteVoice = mutesMap["voice"].AsBoolean();
3422 }
3423 updatesList.Add(block);
3424 }
3425 }
3426  
3427 Updates = new AgentUpdatesBlock[updatesList.Count];
3428  
3429 for (int i = 0; i < updatesList.Count; i++)
3430 {
3431 AgentUpdatesBlock block = new AgentUpdatesBlock();
3432 block.AgentID = updatesList[i].AgentID;
3433 block.CanVoiceChat = updatesList[i].CanVoiceChat;
3434 block.IsModerator = updatesList[i].IsModerator;
3435 block.MuteText = updatesList[i].MuteText;
3436 block.MuteVoice = updatesList[i].MuteVoice;
3437 block.Transition = updatesList[i].Transition;
3438 Updates[i] = block;
3439 }
3440 }
3441 }
3442  
3443 /// <summary>
3444 /// An EventQueue message sent when the agent is forcibly removed from a chatterbox session
3445 /// </summary>
3446 public class ForceCloseChatterBoxSessionMessage : IMessage
3447 {
3448 /// <summary>
3449 /// A string containing the reason the agent was removed
3450 /// </summary>
3451 public string Reason;
3452 /// <summary>
3453 /// The ChatterBoxSession's SessionID
3454 /// </summary>
3455 public UUID SessionID;
3456  
3457 /// <summary>
3458 /// Serialize the object
3459 /// </summary>
3460 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3461 public OSDMap Serialize()
3462 {
3463 OSDMap map = new OSDMap(2);
3464 map["reason"] = OSD.FromString(Reason);
3465 map["session_id"] = OSD.FromUUID(SessionID);
3466  
3467 return map;
3468 }
3469  
3470 /// <summary>
3471 /// Deserialize the message
3472 /// </summary>
3473 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3474 public void Deserialize(OSDMap map)
3475 {
3476 Reason = map["reason"].AsString();
3477 SessionID = map["session_id"].AsUUID();
3478 }
3479 }
3480  
3481 #endregion
3482  
3483 #region EventQueue
3484  
3485 public abstract class EventMessageBlock
3486 {
3487 public abstract OSDMap Serialize();
3488 public abstract void Deserialize(OSDMap map);
3489 }
3490  
3491 public class EventQueueAck : EventMessageBlock
3492 {
3493 public int AckID;
3494 public bool Done;
3495  
3496 /// <summary>
3497 /// Serialize the object
3498 /// </summary>
3499 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3500 public override OSDMap Serialize()
3501 {
3502 OSDMap map = new OSDMap();
3503 map["ack"] = OSD.FromInteger(AckID);
3504 map["done"] = OSD.FromBoolean(Done);
3505 return map;
3506 }
3507  
3508 /// <summary>
3509 /// Deserialize the message
3510 /// </summary>
3511 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3512 public override void Deserialize(OSDMap map)
3513 {
3514 AckID = map["ack"].AsInteger();
3515 Done = map["done"].AsBoolean();
3516 }
3517 }
3518  
3519 public class EventQueueEvent : EventMessageBlock
3520 {
3521 public class QueueEvent
3522 {
3523 public IMessage EventMessage;
3524 public string MessageKey;
3525 }
3526  
3527 public int Sequence;
3528 public QueueEvent[] MessageEvents;
3529  
3530 /// <summary>
3531 /// Serialize the object
3532 /// </summary>
3533 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3534 public override OSDMap Serialize()
3535 {
3536 OSDMap map = new OSDMap(1);
3537  
3538 OSDArray eventsArray = new OSDArray();
3539  
3540 for (int i = 0; i < MessageEvents.Length; i++)
3541 {
3542 OSDMap eventMap = new OSDMap(2);
3543 eventMap["body"] = MessageEvents[i].EventMessage.Serialize();
3544 eventMap["message"] = OSD.FromString(MessageEvents[i].MessageKey);
3545 eventsArray.Add(eventMap);
3546 }
3547  
3548 map["events"] = eventsArray;
3549 map["id"] = OSD.FromInteger(Sequence);
3550  
3551 return map;
3552 }
3553  
3554 /// <summary>
3555 /// Deserialize the message
3556 /// </summary>
3557 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3558 public override void Deserialize(OSDMap map)
3559 {
3560 Sequence = map["id"].AsInteger();
3561 OSDArray arrayEvents = (OSDArray)map["events"];
3562  
3563 MessageEvents = new QueueEvent[arrayEvents.Count];
3564  
3565 for (int i = 0; i < arrayEvents.Count; i++)
3566 {
3567 OSDMap eventMap = (OSDMap)arrayEvents[i];
3568 QueueEvent ev = new QueueEvent();
3569  
3570 ev.MessageKey = eventMap["message"].AsString();
3571 ev.EventMessage = MessageUtils.DecodeEvent(ev.MessageKey, (OSDMap)eventMap["body"]);
3572 MessageEvents[i] = ev;
3573 }
3574 }
3575 }
3576  
3577 public class EventQueueGetMessage : IMessage
3578 {
3579 public EventMessageBlock Messages;
3580  
3581 /// <summary>
3582 /// Serialize the object
3583 /// </summary>
3584 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3585 public OSDMap Serialize()
3586 {
3587 return Messages.Serialize();
3588 }
3589  
3590 /// <summary>
3591 /// Deserialize the message
3592 /// </summary>
3593 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3594 public void Deserialize(OSDMap map)
3595 {
3596 if (map.ContainsKey("ack"))
3597 Messages = new EventQueueAck();
3598 else if (map.ContainsKey("events"))
3599 Messages = new EventQueueEvent();
3600 else
3601 Logger.Log("Unable to deserialize EventQueueGetMessage: No message handler exists for event", Helpers.LogLevel.Warning);
3602  
3603 Messages.Deserialize(map);
3604 }
3605 }
3606  
3607 #endregion
3608  
3609 #region Stats Messages
3610  
3611 public class ViewerStatsMessage : IMessage
3612 {
3613 public int AgentsInView;
3614 public float AgentFPS;
3615 public string AgentLanguage;
3616 public float AgentMemoryUsed;
3617 public float MetersTraveled;
3618 public float AgentPing;
3619 public int RegionsVisited;
3620 public float AgentRuntime;
3621 public float SimulatorFPS;
3622 public DateTime AgentStartTime;
3623 public string AgentVersion;
3624  
3625 public float object_kbytes;
3626 public float texture_kbytes;
3627 public float world_kbytes;
3628  
3629 public float MiscVersion;
3630 public bool VertexBuffersEnabled;
3631  
3632 public UUID SessionID;
3633  
3634 public int StatsDropped;
3635 public int StatsFailedResends;
3636 public int FailuresInvalid;
3637 public int FailuresOffCircuit;
3638 public int FailuresResent;
3639 public int FailuresSendPacket;
3640  
3641 public int MiscInt1;
3642 public int MiscInt2;
3643 public string MiscString1;
3644  
3645 public int InCompressedPackets;
3646 public float InKbytes;
3647 public float InPackets;
3648 public float InSavings;
3649  
3650 public int OutCompressedPackets;
3651 public float OutKbytes;
3652 public float OutPackets;
3653 public float OutSavings;
3654  
3655 public string SystemCPU;
3656 public string SystemGPU;
3657 public int SystemGPUClass;
3658 public string SystemGPUVendor;
3659 public string SystemGPUVersion;
3660 public string SystemOS;
3661 public int SystemInstalledRam;
3662  
3663 /// <summary>
3664 /// Serialize the object
3665 /// </summary>
3666 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3667 public OSDMap Serialize()
3668 {
3669 OSDMap map = new OSDMap(5);
3670 map["session_id"] = OSD.FromUUID(SessionID);
3671  
3672 OSDMap agentMap = new OSDMap(11);
3673 agentMap["agents_in_view"] = OSD.FromInteger(AgentsInView);
3674 agentMap["fps"] = OSD.FromReal(AgentFPS);
3675 agentMap["language"] = OSD.FromString(AgentLanguage);
3676 agentMap["mem_use"] = OSD.FromReal(AgentMemoryUsed);
3677 agentMap["meters_traveled"] = OSD.FromReal(MetersTraveled);
3678 agentMap["ping"] = OSD.FromReal(AgentPing);
3679 agentMap["regions_visited"] = OSD.FromInteger(RegionsVisited);
3680 agentMap["run_time"] = OSD.FromReal(AgentRuntime);
3681 agentMap["sim_fps"] = OSD.FromReal(SimulatorFPS);
3682 agentMap["start_time"] = OSD.FromUInteger(Utils.DateTimeToUnixTime(AgentStartTime));
3683 agentMap["version"] = OSD.FromString(AgentVersion);
3684 map["agent"] = agentMap;
3685  
3686  
3687 OSDMap downloadsMap = new OSDMap(3); // downloads
3688 downloadsMap["object_kbytes"] = OSD.FromReal(object_kbytes);
3689 downloadsMap["texture_kbytes"] = OSD.FromReal(texture_kbytes);
3690 downloadsMap["world_kbytes"] = OSD.FromReal(world_kbytes);
3691 map["downloads"] = downloadsMap;
3692  
3693 OSDMap miscMap = new OSDMap(2);
3694 miscMap["Version"] = OSD.FromReal(MiscVersion);
3695 miscMap["Vertex Buffers Enabled"] = OSD.FromBoolean(VertexBuffersEnabled);
3696 map["misc"] = miscMap;
3697  
3698 OSDMap statsMap = new OSDMap(2);
3699  
3700 OSDMap failuresMap = new OSDMap(6);
3701 failuresMap["dropped"] = OSD.FromInteger(StatsDropped);
3702 failuresMap["failed_resends"] = OSD.FromInteger(StatsFailedResends);
3703 failuresMap["invalid"] = OSD.FromInteger(FailuresInvalid);
3704 failuresMap["off_circuit"] = OSD.FromInteger(FailuresOffCircuit);
3705 failuresMap["resent"] = OSD.FromInteger(FailuresResent);
3706 failuresMap["send_packet"] = OSD.FromInteger(FailuresSendPacket);
3707 statsMap["failures"] = failuresMap;
3708  
3709 OSDMap statsMiscMap = new OSDMap(3);
3710 statsMiscMap["int_1"] = OSD.FromInteger(MiscInt1);
3711 statsMiscMap["int_2"] = OSD.FromInteger(MiscInt2);
3712 statsMiscMap["string_1"] = OSD.FromString(MiscString1);
3713 statsMap["misc"] = statsMiscMap;
3714  
3715 OSDMap netMap = new OSDMap(3);
3716  
3717 // in
3718 OSDMap netInMap = new OSDMap(4);
3719 netInMap["compressed_packets"] = OSD.FromInteger(InCompressedPackets);
3720 netInMap["kbytes"] = OSD.FromReal(InKbytes);
3721 netInMap["packets"] = OSD.FromReal(InPackets);
3722 netInMap["savings"] = OSD.FromReal(InSavings);
3723 netMap["in"] = netInMap;
3724 // out
3725 OSDMap netOutMap = new OSDMap(4);
3726 netOutMap["compressed_packets"] = OSD.FromInteger(OutCompressedPackets);
3727 netOutMap["kbytes"] = OSD.FromReal(OutKbytes);
3728 netOutMap["packets"] = OSD.FromReal(OutPackets);
3729 netOutMap["savings"] = OSD.FromReal(OutSavings);
3730 netMap["out"] = netOutMap;
3731  
3732 statsMap["net"] = netMap;
3733  
3734 //system
3735 OSDMap systemStatsMap = new OSDMap(7);
3736 systemStatsMap["cpu"] = OSD.FromString(SystemCPU);
3737 systemStatsMap["gpu"] = OSD.FromString(SystemGPU);
3738 systemStatsMap["gpu_class"] = OSD.FromInteger(SystemGPUClass);
3739 systemStatsMap["gpu_vendor"] = OSD.FromString(SystemGPUVendor);
3740 systemStatsMap["gpu_version"] = OSD.FromString(SystemGPUVersion);
3741 systemStatsMap["os"] = OSD.FromString(SystemOS);
3742 systemStatsMap["ram"] = OSD.FromInteger(SystemInstalledRam);
3743 map["system"] = systemStatsMap;
3744  
3745 map["stats"] = statsMap;
3746 return map;
3747 }
3748  
3749 /// <summary>
3750 /// Deserialize the message
3751 /// </summary>
3752 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3753 public void Deserialize(OSDMap map)
3754 {
3755 SessionID = map["session_id"].AsUUID();
3756  
3757 OSDMap agentMap = (OSDMap)map["agent"];
3758 AgentsInView = agentMap["agents_in_view"].AsInteger();
3759 AgentFPS = (float)agentMap["fps"].AsReal();
3760 AgentLanguage = agentMap["language"].AsString();
3761 AgentMemoryUsed = (float)agentMap["mem_use"].AsReal();
3762 MetersTraveled = agentMap["meters_traveled"].AsInteger();
3763 AgentPing = (float)agentMap["ping"].AsReal();
3764 RegionsVisited = agentMap["regions_visited"].AsInteger();
3765 AgentRuntime = (float)agentMap["run_time"].AsReal();
3766 SimulatorFPS = (float)agentMap["sim_fps"].AsReal();
3767 AgentStartTime = Utils.UnixTimeToDateTime(agentMap["start_time"].AsUInteger());
3768 AgentVersion = agentMap["version"].AsString();
3769  
3770 OSDMap downloadsMap = (OSDMap)map["downloads"];
3771 object_kbytes = (float)downloadsMap["object_kbytes"].AsReal();
3772 texture_kbytes = (float)downloadsMap["texture_kbytes"].AsReal();
3773 world_kbytes = (float)downloadsMap["world_kbytes"].AsReal();
3774  
3775 OSDMap miscMap = (OSDMap)map["misc"];
3776 MiscVersion = (float)miscMap["Version"].AsReal();
3777 VertexBuffersEnabled = miscMap["Vertex Buffers Enabled"].AsBoolean();
3778  
3779 OSDMap statsMap = (OSDMap)map["stats"];
3780 OSDMap failuresMap = (OSDMap)statsMap["failures"];
3781 StatsDropped = failuresMap["dropped"].AsInteger();
3782 StatsFailedResends = failuresMap["failed_resends"].AsInteger();
3783 FailuresInvalid = failuresMap["invalid"].AsInteger();
3784 FailuresOffCircuit = failuresMap["off_circuit"].AsInteger();
3785 FailuresResent = failuresMap["resent"].AsInteger();
3786 FailuresSendPacket = failuresMap["send_packet"].AsInteger();
3787  
3788 OSDMap statsMiscMap = (OSDMap)statsMap["misc"];
3789 MiscInt1 = statsMiscMap["int_1"].AsInteger();
3790 MiscInt2 = statsMiscMap["int_2"].AsInteger();
3791 MiscString1 = statsMiscMap["string_1"].AsString();
3792 OSDMap netMap = (OSDMap)statsMap["net"];
3793 // in
3794 OSDMap netInMap = (OSDMap)netMap["in"];
3795 InCompressedPackets = netInMap["compressed_packets"].AsInteger();
3796 InKbytes = netInMap["kbytes"].AsInteger();
3797 InPackets = netInMap["packets"].AsInteger();
3798 InSavings = netInMap["savings"].AsInteger();
3799 // out
3800 OSDMap netOutMap = (OSDMap)netMap["out"];
3801 OutCompressedPackets = netOutMap["compressed_packets"].AsInteger();
3802 OutKbytes = netOutMap["kbytes"].AsInteger();
3803 OutPackets = netOutMap["packets"].AsInteger();
3804 OutSavings = netOutMap["savings"].AsInteger();
3805  
3806 //system
3807 OSDMap systemStatsMap = (OSDMap)map["system"];
3808 SystemCPU = systemStatsMap["cpu"].AsString();
3809 SystemGPU = systemStatsMap["gpu"].AsString();
3810 SystemGPUClass = systemStatsMap["gpu_class"].AsInteger();
3811 SystemGPUVendor = systemStatsMap["gpu_vendor"].AsString();
3812 SystemGPUVersion = systemStatsMap["gpu_version"].AsString();
3813 SystemOS = systemStatsMap["os"].AsString();
3814 SystemInstalledRam = systemStatsMap["ram"].AsInteger();
3815 }
3816 }
3817  
3818 /// <summary>
3819 ///
3820 /// </summary>
3821 public class PlacesReplyMessage : IMessage
3822 {
3823 public UUID AgentID;
3824 public UUID QueryID;
3825 public UUID TransactionID;
3826  
3827 public class QueryData
3828 {
3829 public int ActualArea;
3830 public int BillableArea;
3831 public string Description;
3832 public float Dwell;
3833 public int Flags;
3834 public float GlobalX;
3835 public float GlobalY;
3836 public float GlobalZ;
3837 public string Name;
3838 public UUID OwnerID;
3839 public string SimName;
3840 public UUID SnapShotID;
3841 public string ProductSku;
3842 public int Price;
3843 }
3844  
3845 public QueryData[] QueryDataBlocks;
3846  
3847 /// <summary>
3848 /// Serialize the object
3849 /// </summary>
3850 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3851 public OSDMap Serialize()
3852 {
3853 OSDMap map = new OSDMap(3);
3854  
3855 // add the AgentData map
3856 OSDMap agentIDmap = new OSDMap(2);
3857 agentIDmap["AgentID"] = OSD.FromUUID(AgentID);
3858 agentIDmap["QueryID"] = OSD.FromUUID(QueryID);
3859  
3860 OSDArray agentDataArray = new OSDArray();
3861 agentDataArray.Add(agentIDmap);
3862  
3863 map["AgentData"] = agentDataArray;
3864  
3865 // add the QueryData map
3866 OSDArray dataBlocksArray = new OSDArray(QueryDataBlocks.Length);
3867 for (int i = 0; i < QueryDataBlocks.Length; i++)
3868 {
3869 OSDMap queryDataMap = new OSDMap(14);
3870 queryDataMap["ActualArea"] = OSD.FromInteger(QueryDataBlocks[i].ActualArea);
3871 queryDataMap["BillableArea"] = OSD.FromInteger(QueryDataBlocks[i].BillableArea);
3872 queryDataMap["Desc"] = OSD.FromString(QueryDataBlocks[i].Description);
3873 queryDataMap["Dwell"] = OSD.FromReal(QueryDataBlocks[i].Dwell);
3874 queryDataMap["Flags"] = OSD.FromInteger(QueryDataBlocks[i].Flags);
3875 queryDataMap["GlobalX"] = OSD.FromReal(QueryDataBlocks[i].GlobalX);
3876 queryDataMap["GlobalY"] = OSD.FromReal(QueryDataBlocks[i].GlobalY);
3877 queryDataMap["GlobalZ"] = OSD.FromReal(QueryDataBlocks[i].GlobalZ);
3878 queryDataMap["Name"] = OSD.FromString(QueryDataBlocks[i].Name);
3879 queryDataMap["OwnerID"] = OSD.FromUUID(QueryDataBlocks[i].OwnerID);
3880 queryDataMap["Price"] = OSD.FromInteger(QueryDataBlocks[i].Price);
3881 queryDataMap["SimName"] = OSD.FromString(QueryDataBlocks[i].SimName);
3882 queryDataMap["SnapshotID"] = OSD.FromUUID(QueryDataBlocks[i].SnapShotID);
3883 queryDataMap["ProductSKU"] = OSD.FromString(QueryDataBlocks[i].ProductSku);
3884 dataBlocksArray.Add(queryDataMap);
3885 }
3886  
3887 map["QueryData"] = dataBlocksArray;
3888  
3889 // add the TransactionData map
3890 OSDMap transMap = new OSDMap(1);
3891 transMap["TransactionID"] = OSD.FromUUID(TransactionID);
3892 OSDArray transArray = new OSDArray();
3893 transArray.Add(transMap);
3894 map["TransactionData"] = transArray;
3895  
3896 return map;
3897 }
3898  
3899 /// <summary>
3900 /// Deserialize the message
3901 /// </summary>
3902 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3903 public void Deserialize(OSDMap map)
3904 {
3905 OSDArray agentDataArray = (OSDArray)map["AgentData"];
3906  
3907 OSDMap agentDataMap = (OSDMap)agentDataArray[0];
3908 AgentID = agentDataMap["AgentID"].AsUUID();
3909 QueryID = agentDataMap["QueryID"].AsUUID();
3910  
3911  
3912 OSDArray dataBlocksArray = (OSDArray)map["QueryData"];
3913 QueryDataBlocks = new QueryData[dataBlocksArray.Count];
3914 for (int i = 0; i < dataBlocksArray.Count; i++)
3915 {
3916 OSDMap dataMap = (OSDMap)dataBlocksArray[i];
3917 QueryData data = new QueryData();
3918 data.ActualArea = dataMap["ActualArea"].AsInteger();
3919 data.BillableArea = dataMap["BillableArea"].AsInteger();
3920 data.Description = dataMap["Desc"].AsString();
3921 data.Dwell = (float)dataMap["Dwell"].AsReal();
3922 data.Flags = dataMap["Flags"].AsInteger();
3923 data.GlobalX = (float)dataMap["GlobalX"].AsReal();
3924 data.GlobalY = (float)dataMap["GlobalY"].AsReal();
3925 data.GlobalZ = (float)dataMap["GlobalZ"].AsReal();
3926 data.Name = dataMap["Name"].AsString();
3927 data.OwnerID = dataMap["OwnerID"].AsUUID();
3928 data.Price = dataMap["Price"].AsInteger();
3929 data.SimName = dataMap["SimName"].AsString();
3930 data.SnapShotID = dataMap["SnapshotID"].AsUUID();
3931 data.ProductSku = dataMap["ProductSKU"].AsString();
3932 QueryDataBlocks[i] = data;
3933 }
3934  
3935 OSDArray transactionArray = (OSDArray)map["TransactionData"];
3936 OSDMap transactionDataMap = (OSDMap)transactionArray[0];
3937 TransactionID = transactionDataMap["TransactionID"].AsUUID();
3938 }
3939 }
3940  
3941 public class UpdateAgentInformationMessage : IMessage
3942 {
3943 public string MaxAccess; // PG, A, or M
3944  
3945 /// <summary>
3946 /// Serialize the object
3947 /// </summary>
3948 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3949 public OSDMap Serialize()
3950 {
3951 OSDMap map = new OSDMap(1);
3952 OSDMap prefsMap = new OSDMap(1);
3953 prefsMap["max"] = OSD.FromString(MaxAccess);
3954 map["access_prefs"] = prefsMap;
3955 return map;
3956 }
3957  
3958 /// <summary>
3959 /// Deserialize the message
3960 /// </summary>
3961 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
3962 public void Deserialize(OSDMap map)
3963 {
3964 OSDMap prefsMap = (OSDMap)map["access_prefs"];
3965 MaxAccess = prefsMap["max"].AsString();
3966 }
3967 }
3968  
3969 [Serializable]
3970 public class DirLandReplyMessage : IMessage
3971 {
3972 public UUID AgentID;
3973 public UUID QueryID;
3974  
3975 [Serializable]
3976 public class QueryReply
3977 {
3978 public int ActualArea;
3979 public bool Auction;
3980 public bool ForSale;
3981 public string Name;
3982 public UUID ParcelID;
3983 public string ProductSku;
3984 public int SalePrice;
3985 }
3986  
3987 public QueryReply[] QueryReplies;
3988  
3989 /// <summary>
3990 /// Serialize the object
3991 /// </summary>
3992 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
3993 public OSDMap Serialize()
3994 {
3995 OSDMap map = new OSDMap(3);
3996  
3997 OSDMap agentMap = new OSDMap(1);
3998 agentMap["AgentID"] = OSD.FromUUID(AgentID);
3999 OSDArray agentDataArray = new OSDArray(1);
4000 agentDataArray.Add(agentMap);
4001 map["AgentData"] = agentDataArray;
4002  
4003 OSDMap queryMap = new OSDMap(1);
4004 queryMap["QueryID"] = OSD.FromUUID(QueryID);
4005 OSDArray queryDataArray = new OSDArray(1);
4006 queryDataArray.Add(queryMap);
4007 map["QueryData"] = queryDataArray;
4008  
4009 OSDArray queryReplyArray = new OSDArray();
4010 for (int i = 0; i < QueryReplies.Length; i++)
4011 {
4012 OSDMap queryReply = new OSDMap(100);
4013 queryReply["ActualArea"] = OSD.FromInteger(QueryReplies[i].ActualArea);
4014 queryReply["Auction"] = OSD.FromBoolean(QueryReplies[i].Auction);
4015 queryReply["ForSale"] = OSD.FromBoolean(QueryReplies[i].ForSale);
4016 queryReply["Name"] = OSD.FromString(QueryReplies[i].Name);
4017 queryReply["ParcelID"] = OSD.FromUUID(QueryReplies[i].ParcelID);
4018 queryReply["ProductSKU"] = OSD.FromString(QueryReplies[i].ProductSku);
4019 queryReply["SalePrice"] = OSD.FromInteger(QueryReplies[i].SalePrice);
4020  
4021 queryReplyArray.Add(queryReply);
4022 }
4023 map["QueryReplies"] = queryReplyArray;
4024  
4025 return map;
4026 }
4027  
4028 /// <summary>
4029 /// Deserialize the message
4030 /// </summary>
4031 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4032 public void Deserialize(OSDMap map)
4033 {
4034 OSDArray agentDataArray = (OSDArray)map["AgentData"];
4035 OSDMap agentDataMap = (OSDMap)agentDataArray[0];
4036 AgentID = agentDataMap["AgentID"].AsUUID();
4037  
4038 OSDArray queryDataArray = (OSDArray)map["QueryData"];
4039 OSDMap queryDataMap = (OSDMap)queryDataArray[0];
4040 QueryID = queryDataMap["QueryID"].AsUUID();
4041  
4042 OSDArray queryRepliesArray = (OSDArray)map["QueryReplies"];
4043  
4044 QueryReplies = new QueryReply[queryRepliesArray.Count];
4045 for (int i = 0; i < queryRepliesArray.Count; i++)
4046 {
4047 QueryReply reply = new QueryReply();
4048 OSDMap replyMap = (OSDMap)queryRepliesArray[i];
4049 reply.ActualArea = replyMap["ActualArea"].AsInteger();
4050 reply.Auction = replyMap["Auction"].AsBoolean();
4051 reply.ForSale = replyMap["ForSale"].AsBoolean();
4052 reply.Name = replyMap["Name"].AsString();
4053 reply.ParcelID = replyMap["ParcelID"].AsUUID();
4054 reply.ProductSku = replyMap["ProductSKU"].AsString();
4055 reply.SalePrice = replyMap["SalePrice"].AsInteger();
4056  
4057 QueryReplies[i] = reply;
4058 }
4059 }
4060 }
4061  
4062 #endregion
4063  
4064 #region Object Messages
4065  
4066 public class UploadObjectAssetMessage : IMessage
4067 {
4068 public class Object
4069 {
4070 public class Face
4071 {
4072 public Bumpiness Bump;
4073 public Color4 Color;
4074 public bool Fullbright;
4075 public float Glow;
4076 public UUID ImageID;
4077 public float ImageRot;
4078 public int MediaFlags;
4079 public float OffsetS;
4080 public float OffsetT;
4081 public float ScaleS;
4082 public float ScaleT;
4083  
4084 public OSDMap Serialize()
4085 {
4086 OSDMap map = new OSDMap();
4087 map["bump"] = OSD.FromInteger((int)Bump);
4088 map["colors"] = OSD.FromColor4(Color);
4089 map["fullbright"] = OSD.FromBoolean(Fullbright);
4090 map["glow"] = OSD.FromReal(Glow);
4091 map["imageid"] = OSD.FromUUID(ImageID);
4092 map["imagerot"] = OSD.FromReal(ImageRot);
4093 map["media_flags"] = OSD.FromInteger(MediaFlags);
4094 map["offsets"] = OSD.FromReal(OffsetS);
4095 map["offsett"] = OSD.FromReal(OffsetT);
4096 map["scales"] = OSD.FromReal(ScaleS);
4097 map["scalet"] = OSD.FromReal(ScaleT);
4098  
4099 return map;
4100 }
4101  
4102 public void Deserialize(OSDMap map)
4103 {
4104 Bump = (Bumpiness)map["bump"].AsInteger();
4105 Color = map["colors"].AsColor4();
4106 Fullbright = map["fullbright"].AsBoolean();
4107 Glow = (float)map["glow"].AsReal();
4108 ImageID = map["imageid"].AsUUID();
4109 ImageRot = (float)map["imagerot"].AsReal();
4110 MediaFlags = map["media_flags"].AsInteger();
4111 OffsetS = (float)map["offsets"].AsReal();
4112 OffsetT = (float)map["offsett"].AsReal();
4113 ScaleS = (float)map["scales"].AsReal();
4114 ScaleT = (float)map["scalet"].AsReal();
4115 }
4116 }
4117  
4118 public class ExtraParam
4119 {
4120 public ExtraParamType Type;
4121 public byte[] ExtraParamData;
4122  
4123 public OSDMap Serialize()
4124 {
4125 OSDMap map = new OSDMap();
4126 map["extra_parameter"] = OSD.FromInteger((int)Type);
4127 map["param_data"] = OSD.FromBinary(ExtraParamData);
4128  
4129 return map;
4130 }
4131  
4132 public void Deserialize(OSDMap map)
4133 {
4134 Type = (ExtraParamType)map["extra_parameter"].AsInteger();
4135 ExtraParamData = map["param_data"].AsBinary();
4136 }
4137 }
4138  
4139 public Face[] Faces;
4140 public ExtraParam[] ExtraParams;
4141 public UUID GroupID;
4142 public Material Material;
4143 public string Name;
4144 public Vector3 Position;
4145 public Quaternion Rotation;
4146 public Vector3 Scale;
4147 public float PathBegin;
4148 public int PathCurve;
4149 public float PathEnd;
4150 public float RadiusOffset;
4151 public float Revolutions;
4152 public float ScaleX;
4153 public float ScaleY;
4154 public float ShearX;
4155 public float ShearY;
4156 public float Skew;
4157 public float TaperX;
4158 public float TaperY;
4159 public float Twist;
4160 public float TwistBegin;
4161 public float ProfileBegin;
4162 public int ProfileCurve;
4163 public float ProfileEnd;
4164 public float ProfileHollow;
4165 public UUID SculptID;
4166 public SculptType SculptType;
4167  
4168 public OSDMap Serialize()
4169 {
4170 OSDMap map = new OSDMap();
4171  
4172 map["group-id"] = OSD.FromUUID(GroupID);
4173 map["material"] = OSD.FromInteger((int)Material);
4174 map["name"] = OSD.FromString(Name);
4175 map["pos"] = OSD.FromVector3(Position);
4176 map["rotation"] = OSD.FromQuaternion(Rotation);
4177 map["scale"] = OSD.FromVector3(Scale);
4178  
4179 // Extra params
4180 OSDArray extraParams = new OSDArray();
4181 if (ExtraParams != null)
4182 {
4183 for (int i = 0; i < ExtraParams.Length; i++)
4184 extraParams.Add(ExtraParams[i].Serialize());
4185 }
4186 map["extra_parameters"] = extraParams;
4187  
4188 // Faces
4189 OSDArray faces = new OSDArray();
4190 if (Faces != null)
4191 {
4192 for (int i = 0; i < Faces.Length; i++)
4193 faces.Add(Faces[i].Serialize());
4194 }
4195 map["facelist"] = faces;
4196  
4197 // Shape
4198 OSDMap shape = new OSDMap();
4199 OSDMap path = new OSDMap();
4200 path["begin"] = OSD.FromReal(PathBegin);
4201 path["curve"] = OSD.FromInteger(PathCurve);
4202 path["end"] = OSD.FromReal(PathEnd);
4203 path["radius_offset"] = OSD.FromReal(RadiusOffset);
4204 path["revolutions"] = OSD.FromReal(Revolutions);
4205 path["scale_x"] = OSD.FromReal(ScaleX);
4206 path["scale_y"] = OSD.FromReal(ScaleY);
4207 path["shear_x"] = OSD.FromReal(ShearX);
4208 path["shear_y"] = OSD.FromReal(ShearY);
4209 path["skew"] = OSD.FromReal(Skew);
4210 path["taper_x"] = OSD.FromReal(TaperX);
4211 path["taper_y"] = OSD.FromReal(TaperY);
4212 path["twist"] = OSD.FromReal(Twist);
4213 path["twist_begin"] = OSD.FromReal(TwistBegin);
4214 shape["path"] = path;
4215 OSDMap profile = new OSDMap();
4216 profile["begin"] = OSD.FromReal(ProfileBegin);
4217 profile["curve"] = OSD.FromInteger(ProfileCurve);
4218 profile["end"] = OSD.FromReal(ProfileEnd);
4219 profile["hollow"] = OSD.FromReal(ProfileHollow);
4220 shape["profile"] = profile;
4221 OSDMap sculpt = new OSDMap();
4222 sculpt["id"] = OSD.FromUUID(SculptID);
4223 sculpt["type"] = OSD.FromInteger((int)SculptType);
4224 shape["sculpt"] = sculpt;
4225 map["shape"] = shape;
4226  
4227 return map;
4228 }
4229  
4230 public void Deserialize(OSDMap map)
4231 {
4232 GroupID = map["group-id"].AsUUID();
4233 Material = (Material)map["material"].AsInteger();
4234 Name = map["name"].AsString();
4235 Position = map["pos"].AsVector3();
4236 Rotation = map["rotation"].AsQuaternion();
4237 Scale = map["scale"].AsVector3();
4238  
4239 // Extra params
4240 OSDArray extraParams = map["extra_parameters"] as OSDArray;
4241 if (extraParams != null)
4242 {
4243 ExtraParams = new ExtraParam[extraParams.Count];
4244 for (int i = 0; i < extraParams.Count; i++)
4245 {
4246 ExtraParam extraParam = new ExtraParam();
4247 extraParam.Deserialize(extraParams[i] as OSDMap);
4248 ExtraParams[i] = extraParam;
4249 }
4250 }
4251 else
4252 {
4253 ExtraParams = new ExtraParam[0];
4254 }
4255  
4256 // Faces
4257 OSDArray faces = map["facelist"] as OSDArray;
4258 if (faces != null)
4259 {
4260 Faces = new Face[faces.Count];
4261 for (int i = 0; i < faces.Count; i++)
4262 {
4263 Face face = new Face();
4264 face.Deserialize(faces[i] as OSDMap);
4265 Faces[i] = face;
4266 }
4267 }
4268 else
4269 {
4270 Faces = new Face[0];
4271 }
4272  
4273 // Shape
4274 OSDMap shape = map["shape"] as OSDMap;
4275 OSDMap path = shape["path"] as OSDMap;
4276 PathBegin = (float)path["begin"].AsReal();
4277 PathCurve = path["curve"].AsInteger();
4278 PathEnd = (float)path["end"].AsReal();
4279 RadiusOffset = (float)path["radius_offset"].AsReal();
4280 Revolutions = (float)path["revolutions"].AsReal();
4281 ScaleX = (float)path["scale_x"].AsReal();
4282 ScaleY = (float)path["scale_y"].AsReal();
4283 ShearX = (float)path["shear_x"].AsReal();
4284 ShearY = (float)path["shear_y"].AsReal();
4285 Skew = (float)path["skew"].AsReal();
4286 TaperX = (float)path["taper_x"].AsReal();
4287 TaperY = (float)path["taper_y"].AsReal();
4288 Twist = (float)path["twist"].AsReal();
4289 TwistBegin = (float)path["twist_begin"].AsReal();
4290  
4291 OSDMap profile = shape["profile"] as OSDMap;
4292 ProfileBegin = (float)profile["begin"].AsReal();
4293 ProfileCurve = profile["curve"].AsInteger();
4294 ProfileEnd = (float)profile["end"].AsReal();
4295 ProfileHollow = (float)profile["hollow"].AsReal();
4296  
4297 OSDMap sculpt = shape["sculpt"] as OSDMap;
4298 if (sculpt != null)
4299 {
4300 SculptID = sculpt["id"].AsUUID();
4301 SculptType = (SculptType)sculpt["type"].AsInteger();
4302 }
4303 else
4304 {
4305 SculptID = UUID.Zero;
4306 SculptType = 0;
4307 }
4308 }
4309 }
4310  
4311 public Object[] Objects;
4312  
4313 public OSDMap Serialize()
4314 {
4315 OSDMap map = new OSDMap();
4316 OSDArray array = new OSDArray();
4317  
4318 if (Objects != null)
4319 {
4320 for (int i = 0; i < Objects.Length; i++)
4321 array.Add(Objects[i].Serialize());
4322 }
4323  
4324 map["objects"] = array;
4325 return map;
4326 }
4327  
4328 public void Deserialize(OSDMap map)
4329 {
4330 OSDArray array = map["objects"] as OSDArray;
4331  
4332 if (array != null)
4333 {
4334 Objects = new Object[array.Count];
4335  
4336 for (int i = 0; i < array.Count; i++)
4337 {
4338 Object obj = new Object();
4339 OSDMap objMap = array[i] as OSDMap;
4340  
4341 if (objMap != null)
4342 obj.Deserialize(objMap);
4343  
4344 Objects[i] = obj;
4345 }
4346 }
4347 else
4348 {
4349 Objects = new Object[0];
4350 }
4351 }
4352 }
4353  
4354 /// <summary>
4355 /// Event Queue message describing physics engine attributes of a list of objects
4356 /// Sim sends these when object is selected
4357 /// </summary>
4358 public class ObjectPhysicsPropertiesMessage : IMessage
4359 {
4360 /// <summary> Array with the list of physics properties</summary>
4361 public Primitive.PhysicsProperties[] ObjectPhysicsProperties;
4362  
4363 /// <summary>
4364 /// Serializes the message
4365 /// </summary>
4366 /// <returns>Serialized OSD</returns>
4367 public OSDMap Serialize()
4368 {
4369 OSDMap ret = new OSDMap();
4370 OSDArray array = new OSDArray();
4371  
4372 for (int i = 0; i < ObjectPhysicsProperties.Length; i++)
4373 {
4374 array.Add(ObjectPhysicsProperties[i].GetOSD());
4375 }
4376  
4377 ret["ObjectData"] = array;
4378 return ret;
4379 }
4380  
4381 /// <summary>
4382 /// Deserializes the message
4383 /// </summary>
4384 /// <param name="map">Incoming data to deserialize</param>
4385 public void Deserialize(OSDMap map)
4386 {
4387 OSDArray array = map["ObjectData"] as OSDArray;
4388 if (array != null)
4389 {
4390 ObjectPhysicsProperties = new Primitive.PhysicsProperties[array.Count];
4391  
4392 for (int i = 0; i < array.Count; i++)
4393 {
4394 ObjectPhysicsProperties[i] = Primitive.PhysicsProperties.FromOSD(array[i]);
4395 }
4396 }
4397 else
4398 {
4399 ObjectPhysicsProperties = new Primitive.PhysicsProperties[0];
4400 }
4401 }
4402 }
4403  
4404 public class RenderMaterialsMessage : IMessage
4405 {
4406 public OSD MaterialData;
4407  
4408 /// <summary>
4409 /// Deserializes the message
4410 /// </summary>
4411 /// <param name="map">Incoming data to deserialize</param>
4412 public void Deserialize(OSDMap map)
4413 {
4414 try
4415 {
4416 using (MemoryStream input = new MemoryStream(map["Zipped"].AsBinary()))
4417 {
4418 using (MemoryStream output = new MemoryStream())
4419 {
4420 using (ZOutputStream zout = new ZOutputStream(output))
4421 {
4422 byte[] buffer = new byte[2048];
4423 int len;
4424 while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
4425 {
4426 zout.Write(buffer, 0, len);
4427 }
4428 zout.Flush();
4429 output.Seek(0, SeekOrigin.Begin);
4430 MaterialData = OSDParser.DeserializeLLSDBinary(output);
4431 }
4432 }
4433 }
4434 }
4435 catch (Exception ex)
4436 {
4437 Logger.Log("Failed to decode RenderMaterials message:", Helpers.LogLevel.Warning, ex);
4438 MaterialData = new OSDMap();
4439 }
4440 }
4441  
4442 /// <summary>
4443 /// Serializes the message
4444 /// </summary>
4445 /// <returns>Serialized OSD</returns>
4446 public OSDMap Serialize()
4447 {
4448 return new OSDMap();
4449 }
4450 }
4451  
4452 public class GetObjectCostRequest : IMessage
4453 {
4454 /// <summary> Object IDs for which to request cost information
4455 public UUID[] ObjectIDs;
4456  
4457 /// <summary>
4458 /// Deserializes the message
4459 /// </summary>
4460 /// <param name="map">Incoming data to deserialize</param>
4461 public void Deserialize(OSDMap map)
4462 {
4463 OSDArray array = map["object_ids"] as OSDArray;
4464 if (array != null)
4465 {
4466 ObjectIDs = new UUID[array.Count];
4467  
4468 for (int i = 0; i < array.Count; i++)
4469 {
4470 ObjectIDs[i] = array[i].AsUUID();
4471 }
4472 }
4473 else
4474 {
4475 ObjectIDs = new UUID[0];
4476 }
4477 }
4478  
4479 /// <summary>
4480 /// Serializes the message
4481 /// </summary>
4482 /// <returns>Serialized OSD</returns>
4483 public OSDMap Serialize()
4484 {
4485 OSDMap ret = new OSDMap();
4486 OSDArray array = new OSDArray();
4487  
4488 for (int i = 0; i < ObjectIDs.Length; i++)
4489 {
4490 array.Add(OSD.FromUUID(ObjectIDs[i]));
4491 }
4492  
4493 ret["object_ids"] = array;
4494 return ret;
4495 }
4496 }
4497  
4498 public class GetObjectCostMessage : IMessage
4499 {
4500 public UUID object_id;
4501 public double link_cost;
4502 public double object_cost;
4503 public double physics_cost;
4504 public double link_physics_cost;
4505  
4506 /// <summary>
4507 /// Deserializes the message
4508 /// </summary>
4509 /// <param name="map">Incoming data to deserialize</param>
4510 public void Deserialize(OSDMap map)
4511 {
4512 if (map.Count != 1)
4513 Logger.Log("GetObjectCostMessage returned values for more than one object! Function needs to be fixed for that!", Helpers.LogLevel.Error);
4514  
4515 foreach (string key in map.Keys)
4516 {
4517 UUID.TryParse(key, out object_id);
4518 OSDMap values = (OSDMap)map[key];
4519  
4520 link_cost = values["linked_set_resource_cost"].AsReal();
4521 object_cost = values["resource_cost"].AsReal();
4522 physics_cost = values["physics_cost"].AsReal();
4523 link_physics_cost = values["linked_set_physics_cost"].AsReal();
4524 // value["resource_limiting_type"].AsString();
4525 return;
4526 }
4527 }
4528  
4529 /// <summary>
4530 /// Serializes the message
4531 /// </summary>
4532 /// <returns>Serialized OSD</returns>
4533 public OSDMap Serialize()
4534 {
4535 OSDMap values = new OSDMap(4);
4536 values.Add("linked_set_resource_cost", OSD.FromReal(link_cost));
4537 values.Add("resource_cost", OSD.FromReal(object_cost));
4538 values.Add("physics_cost", OSD.FromReal(physics_cost));
4539 values.Add("linked_set_physics_cost", OSD.FromReal(link_physics_cost));
4540  
4541 OSDMap map = new OSDMap(1);
4542 map.Add(OSD.FromUUID(object_id), values);
4543 return map;
4544 }
4545  
4546 /// <summary>
4547 /// Detects which class handles deserialization of this message
4548 /// </summary>
4549 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4550 /// <returns>Object capable of decoding this message</returns>
4551 public static IMessage GetMessageHandler(OSDMap map)
4552 {
4553 if (map == null)
4554 {
4555 return null;
4556 }
4557 else if (map.ContainsKey("object_ids"))
4558 {
4559 return new GetObjectCostRequest();
4560 }
4561 else
4562 {
4563 return new GetObjectCostMessage();
4564 }
4565 }
4566 }
4567  
4568 #endregion Object Messages
4569  
4570 #region Object Media Messages
4571 /// <summary>
4572 /// A message sent from the viewer to the simulator which
4573 /// specifies that the user has changed current URL
4574 /// of the specific media on a prim face
4575 /// </summary>
4576 public class ObjectMediaNavigateMessage : IMessage
4577 {
4578 /// <summary>
4579 /// New URL
4580 /// </summary>
4581 public string URL;
4582  
4583 /// <summary>
4584 /// Prim UUID where navigation occured
4585 /// </summary>
4586 public UUID PrimID;
4587  
4588 /// <summary>
4589 /// Face index
4590 /// </summary>
4591 public int Face;
4592 /// <summary>
4593 /// Serialize the object
4594 /// </summary>
4595 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
4596 public OSDMap Serialize()
4597 {
4598 OSDMap map = new OSDMap(3);
4599  
4600 map["current_url"] = OSD.FromString(URL);
4601 map["object_id"] = OSD.FromUUID(PrimID);
4602 map["texture_index"] = OSD.FromInteger(Face);
4603  
4604 return map;
4605 }
4606  
4607 /// <summary>
4608 /// Deserialize the message
4609 /// </summary>
4610 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4611 public void Deserialize(OSDMap map)
4612 {
4613 URL = map["current_url"].AsString();
4614 PrimID = map["object_id"].AsUUID();
4615 Face = map["texture_index"].AsInteger();
4616 }
4617 }
4618  
4619  
4620 /// <summary>Base class used for the ObjectMedia message</summary>
4621 [Serializable]
4622 public abstract class ObjectMediaBlock
4623 {
4624 public abstract OSDMap Serialize();
4625 public abstract void Deserialize(OSDMap map);
4626 }
4627  
4628 /// <summary>
4629 /// Message used to retrive prim media data
4630 /// </summary>
4631 public class ObjectMediaRequest : ObjectMediaBlock
4632 {
4633 /// <summary>
4634 /// Prim UUID
4635 /// </summary>
4636 public UUID PrimID;
4637  
4638 /// <summary>
4639 /// Requested operation, either GET or UPDATE
4640 /// </summary>
4641 public string Verb = "GET"; // "GET" or "UPDATE"
4642  
4643 /// <summary>
4644 /// Serialize object
4645 /// </summary>
4646 /// <returns>Serialized object as OSDMap</returns>
4647 public override OSDMap Serialize()
4648 {
4649 OSDMap map = new OSDMap(2);
4650 map["object_id"] = OSD.FromUUID(PrimID);
4651 map["verb"] = OSD.FromString(Verb);
4652 return map;
4653 }
4654  
4655 /// <summary>
4656 /// Deserialize the message
4657 /// </summary>
4658 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4659 public override void Deserialize(OSDMap map)
4660 {
4661 PrimID = map["object_id"].AsUUID();
4662 Verb = map["verb"].AsString();
4663 }
4664 }
4665  
4666  
4667 /// <summary>
4668 /// Message used to update prim media data
4669 /// </summary>
4670 public class ObjectMediaResponse : ObjectMediaBlock
4671 {
4672 /// <summary>
4673 /// Prim UUID
4674 /// </summary>
4675 public UUID PrimID;
4676  
4677 /// <summary>
4678 /// Array of media entries indexed by face number
4679 /// </summary>
4680 public MediaEntry[] FaceMedia;
4681  
4682 /// <summary>
4683 /// Media version string
4684 /// </summary>
4685 public string Version; // String in this format: x-mv:0000000016/00000000-0000-0000-0000-000000000000
4686  
4687 /// <summary>
4688 /// Serialize object
4689 /// </summary>
4690 /// <returns>Serialized object as OSDMap</returns>
4691 public override OSDMap Serialize()
4692 {
4693 OSDMap map = new OSDMap(2);
4694 map["object_id"] = OSD.FromUUID(PrimID);
4695  
4696 if (FaceMedia == null)
4697 {
4698 map["object_media_data"] = new OSDArray();
4699 }
4700 else
4701 {
4702 OSDArray mediaData = new OSDArray(FaceMedia.Length);
4703  
4704 for (int i = 0; i < FaceMedia.Length; i++)
4705 {
4706 if (FaceMedia[i] == null)
4707 mediaData.Add(new OSD());
4708 else
4709 mediaData.Add(FaceMedia[i].GetOSD());
4710 }
4711  
4712 map["object_media_data"] = mediaData;
4713 }
4714  
4715 map["object_media_version"] = OSD.FromString(Version);
4716 return map;
4717 }
4718  
4719 /// <summary>
4720 /// Deserialize the message
4721 /// </summary>
4722 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4723 public override void Deserialize(OSDMap map)
4724 {
4725 PrimID = map["object_id"].AsUUID();
4726  
4727 if (map["object_media_data"].Type == OSDType.Array)
4728 {
4729 OSDArray mediaData = (OSDArray)map["object_media_data"];
4730 if (mediaData.Count > 0)
4731 {
4732 FaceMedia = new MediaEntry[mediaData.Count];
4733 for (int i = 0; i < mediaData.Count; i++)
4734 {
4735 if (mediaData[i].Type == OSDType.Map)
4736 {
4737 FaceMedia[i] = MediaEntry.FromOSD(mediaData[i]);
4738 }
4739 }
4740 }
4741 }
4742 Version = map["object_media_version"].AsString();
4743 }
4744 }
4745  
4746  
4747 /// <summary>
4748 /// Message used to update prim media data
4749 /// </summary>
4750 public class ObjectMediaUpdate : ObjectMediaBlock
4751 {
4752 /// <summary>
4753 /// Prim UUID
4754 /// </summary>
4755 public UUID PrimID;
4756  
4757 /// <summary>
4758 /// Array of media entries indexed by face number
4759 /// </summary>
4760 public MediaEntry[] FaceMedia;
4761  
4762 /// <summary>
4763 /// Requested operation, either GET or UPDATE
4764 /// </summary>
4765 public string Verb = "UPDATE"; // "GET" or "UPDATE"
4766  
4767 /// <summary>
4768 /// Serialize object
4769 /// </summary>
4770 /// <returns>Serialized object as OSDMap</returns>
4771 public override OSDMap Serialize()
4772 {
4773 OSDMap map = new OSDMap(2);
4774 map["object_id"] = OSD.FromUUID(PrimID);
4775  
4776 if (FaceMedia == null)
4777 {
4778 map["object_media_data"] = new OSDArray();
4779 }
4780 else
4781 {
4782 OSDArray mediaData = new OSDArray(FaceMedia.Length);
4783  
4784 for (int i = 0; i < FaceMedia.Length; i++)
4785 {
4786 if (FaceMedia[i] == null)
4787 mediaData.Add(new OSD());
4788 else
4789 mediaData.Add(FaceMedia[i].GetOSD());
4790 }
4791  
4792 map["object_media_data"] = mediaData;
4793 }
4794  
4795 map["verb"] = OSD.FromString(Verb);
4796 return map;
4797 }
4798  
4799 /// <summary>
4800 /// Deserialize the message
4801 /// </summary>
4802 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4803 public override void Deserialize(OSDMap map)
4804 {
4805 PrimID = map["object_id"].AsUUID();
4806  
4807 if (map["object_media_data"].Type == OSDType.Array)
4808 {
4809 OSDArray mediaData = (OSDArray)map["object_media_data"];
4810 if (mediaData.Count > 0)
4811 {
4812 FaceMedia = new MediaEntry[mediaData.Count];
4813 for (int i = 0; i < mediaData.Count; i++)
4814 {
4815 if (mediaData[i].Type == OSDType.Map)
4816 {
4817 FaceMedia[i] = MediaEntry.FromOSD(mediaData[i]);
4818 }
4819 }
4820 }
4821 }
4822 Verb = map["verb"].AsString();
4823 }
4824 }
4825  
4826 /// <summary>
4827 /// Message for setting or getting per face MediaEntry
4828 /// </summary>
4829 [Serializable]
4830 public class ObjectMediaMessage : IMessage
4831 {
4832 /// <summary>The request or response details block</summary>
4833 public ObjectMediaBlock Request;
4834  
4835 /// <summary>
4836 /// Serialize the object
4837 /// </summary>
4838 /// <returns>An <see cref="OSDMap"/> containing the objects data</returns>
4839 public OSDMap Serialize()
4840 {
4841 return Request.Serialize();
4842 }
4843  
4844 /// <summary>
4845 /// Deserialize the message
4846 /// </summary>
4847 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4848 public void Deserialize(OSDMap map)
4849 {
4850 if (map.ContainsKey("verb"))
4851 {
4852 if (map["verb"].AsString() == "GET")
4853 Request = new ObjectMediaRequest();
4854 else if (map["verb"].AsString() == "UPDATE")
4855 Request = new ObjectMediaUpdate();
4856 }
4857 else if (map.ContainsKey("object_media_version"))
4858 Request = new ObjectMediaResponse();
4859 else
4860 Logger.Log("Unable to deserialize ObjectMedia: No message handler exists for method: " + map.AsString(), Helpers.LogLevel.Warning);
4861  
4862 if (Request != null)
4863 Request.Deserialize(map);
4864 }
4865 }
4866 #endregion Object Media Messages
4867  
4868 #region Resource usage
4869 /// <summary>Details about object resource usage</summary>
4870 public class ObjectResourcesDetail
4871 {
4872 /// <summary>Object UUID</summary>
4873 public UUID ID;
4874 /// <summary>Object name</summary>
4875 public string Name;
4876 /// <summary>Indicates if object is group owned</summary>
4877 public bool GroupOwned;
4878 /// <summary>Locatio of the object</summary>
4879 public Vector3d Location;
4880 /// <summary>Object owner</summary>
4881 public UUID OwnerID;
4882 /// <summary>Resource usage, keys are resource names, values are resource usage for that specific resource</summary>
4883 public Dictionary<string, int> Resources;
4884  
4885 /// <summary>
4886 /// Deserializes object from OSD
4887 /// </summary>
4888 /// <param name="obj">An <see cref="OSDMap"/> containing the data</param>
4889 public virtual void Deserialize(OSDMap obj)
4890 {
4891 ID = obj["id"].AsUUID();
4892 Name = obj["name"].AsString();
4893 Location = obj["location"].AsVector3d();
4894 GroupOwned = obj["is_group_owned"].AsBoolean();
4895 OwnerID = obj["owner_id"].AsUUID();
4896 OSDMap resources = (OSDMap)obj["resources"];
4897 Resources = new Dictionary<string, int>(resources.Keys.Count);
4898 foreach (KeyValuePair<string, OSD> kvp in resources)
4899 {
4900 Resources.Add(kvp.Key, kvp.Value.AsInteger());
4901 }
4902 }
4903  
4904 /// <summary>
4905 /// Makes an instance based on deserialized data
4906 /// </summary>
4907 /// <param name="osd"><see cref="OSD"/> serialized data</param>
4908 /// <returns>Instance containg deserialized data</returns>
4909 public static ObjectResourcesDetail FromOSD(OSD osd)
4910 {
4911 ObjectResourcesDetail res = new ObjectResourcesDetail();
4912 res.Deserialize((OSDMap)osd);
4913 return res;
4914 }
4915 }
4916  
4917 /// <summary>Details about parcel resource usage</summary>
4918 public class ParcelResourcesDetail
4919 {
4920 /// <summary>Parcel UUID</summary>
4921 public UUID ID;
4922 /// <summary>Parcel local ID</summary>
4923 public int LocalID;
4924 /// <summary>Parcel name</summary>
4925 public string Name;
4926 /// <summary>Indicates if parcel is group owned</summary>
4927 public bool GroupOwned;
4928 /// <summary>Parcel owner</summary>
4929 public UUID OwnerID;
4930 /// <summary>Array of <see cref="ObjectResourcesDetail"/> containing per object resource usage</summary>
4931 public ObjectResourcesDetail[] Objects;
4932  
4933 /// <summary>
4934 /// Deserializes object from OSD
4935 /// </summary>
4936 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4937 public virtual void Deserialize(OSDMap map)
4938 {
4939 ID = map["id"].AsUUID();
4940 LocalID = map["local_id"].AsInteger();
4941 Name = map["name"].AsString();
4942 GroupOwned = map["is_group_owned"].AsBoolean();
4943 OwnerID = map["owner_id"].AsUUID();
4944  
4945 OSDArray objectsOSD = (OSDArray)map["objects"];
4946 Objects = new ObjectResourcesDetail[objectsOSD.Count];
4947  
4948 for (int i = 0; i < objectsOSD.Count; i++)
4949 {
4950 Objects[i] = ObjectResourcesDetail.FromOSD(objectsOSD[i]);
4951 }
4952 }
4953  
4954 /// <summary>
4955 /// Makes an instance based on deserialized data
4956 /// </summary>
4957 /// <param name="osd"><see cref="OSD"/> serialized data</param>
4958 /// <returns>Instance containg deserialized data</returns>
4959 public static ParcelResourcesDetail FromOSD(OSD osd)
4960 {
4961 ParcelResourcesDetail res = new ParcelResourcesDetail();
4962 res.Deserialize((OSDMap)osd);
4963 return res;
4964 }
4965 }
4966  
4967 /// <summary>Resource usage base class, both agent and parcel resource
4968 /// usage contains summary information</summary>
4969 public abstract class BaseResourcesInfo : IMessage
4970 {
4971 /// <summary>Summary of available resources, keys are resource names,
4972 /// values are resource usage for that specific resource</summary>
4973 public Dictionary<string, int> SummaryAvailable;
4974 /// <summary>Summary resource usage, keys are resource names,
4975 /// values are resource usage for that specific resource</summary>
4976 public Dictionary<string, int> SummaryUsed;
4977  
4978 /// <summary>
4979 /// Serializes object
4980 /// </summary>
4981 /// <returns><see cref="OSDMap"/> serialized data</returns>
4982 public virtual OSDMap Serialize()
4983 {
4984 throw new NotImplementedException();
4985 }
4986  
4987 /// <summary>
4988 /// Deserializes object from OSD
4989 /// </summary>
4990 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
4991 public virtual void Deserialize(OSDMap map)
4992 {
4993 SummaryAvailable = new Dictionary<string, int>();
4994 SummaryUsed = new Dictionary<string, int>();
4995  
4996 OSDMap summary = (OSDMap)map["summary"];
4997 OSDArray available = (OSDArray)summary["available"];
4998 OSDArray used = (OSDArray)summary["used"];
4999  
5000 for (int i = 0; i < available.Count; i++)
5001 {
5002 OSDMap limit = (OSDMap)available[i];
5003 SummaryAvailable.Add(limit["type"].AsString(), limit["amount"].AsInteger());
5004 }
5005  
5006 for (int i = 0; i < used.Count; i++)
5007 {
5008 OSDMap limit = (OSDMap)used[i];
5009 SummaryUsed.Add(limit["type"].AsString(), limit["amount"].AsInteger());
5010 }
5011 }
5012 }
5013  
5014 /// <summary>Agent resource usage</summary>
5015 public class AttachmentResourcesMessage : BaseResourcesInfo
5016 {
5017 /// <summary>Per attachment point object resource usage</summary>
5018 public Dictionary<AttachmentPoint, ObjectResourcesDetail[]> Attachments;
5019  
5020 /// <summary>
5021 /// Deserializes object from OSD
5022 /// </summary>
5023 /// <param name="osd">An <see cref="OSDMap"/> containing the data</param>
5024 public override void Deserialize(OSDMap osd)
5025 {
5026 base.Deserialize(osd);
5027 OSDArray attachments = (OSDArray)((OSDMap)osd)["attachments"];
5028 Attachments = new Dictionary<AttachmentPoint, ObjectResourcesDetail[]>();
5029  
5030 for (int i = 0; i < attachments.Count; i++)
5031 {
5032 OSDMap attachment = (OSDMap)attachments[i];
5033 AttachmentPoint pt = Utils.StringToAttachmentPoint(attachment["location"].AsString());
5034  
5035 OSDArray objectsOSD = (OSDArray)attachment["objects"];
5036 ObjectResourcesDetail[] objects = new ObjectResourcesDetail[objectsOSD.Count];
5037  
5038 for (int j = 0; j < objects.Length; j++)
5039 {
5040 objects[j] = ObjectResourcesDetail.FromOSD(objectsOSD[j]);
5041 }
5042  
5043 Attachments.Add(pt, objects);
5044 }
5045 }
5046  
5047 /// <summary>
5048 /// Makes an instance based on deserialized data
5049 /// </summary>
5050 /// <param name="osd"><see cref="OSD"/> serialized data</param>
5051 /// <returns>Instance containg deserialized data</returns>
5052 public static AttachmentResourcesMessage FromOSD(OSD osd)
5053 {
5054 AttachmentResourcesMessage res = new AttachmentResourcesMessage();
5055 res.Deserialize((OSDMap)osd);
5056 return res;
5057 }
5058  
5059 /// <summary>
5060 /// Detects which class handles deserialization of this message
5061 /// </summary>
5062 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
5063 /// <returns>Object capable of decoding this message</returns>
5064 public static IMessage GetMessageHandler(OSDMap map)
5065 {
5066 if (map == null)
5067 {
5068 return null;
5069 }
5070 else
5071 {
5072 return new AttachmentResourcesMessage();
5073 }
5074 }
5075 }
5076  
5077 /// <summary>Request message for parcel resource usage</summary>
5078 public class LandResourcesRequest : IMessage
5079 {
5080 /// <summary>UUID of the parel to request resource usage info</summary>
5081 public UUID ParcelID;
5082  
5083 /// <summary>
5084 /// Serializes object
5085 /// </summary>
5086 /// <returns><see cref="OSDMap"/> serialized data</returns>
5087 public OSDMap Serialize()
5088 {
5089 OSDMap map = new OSDMap(1);
5090 map["parcel_id"] = OSD.FromUUID(ParcelID);
5091 return map;
5092 }
5093  
5094 /// <summary>
5095 /// Deserializes object from OSD
5096 /// </summary>
5097 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
5098 public void Deserialize(OSDMap map)
5099 {
5100 ParcelID = map["parcel_id"].AsUUID();
5101 }
5102 }
5103  
5104 /// <summary>Response message for parcel resource usage</summary>
5105 public class LandResourcesMessage : IMessage
5106 {
5107 /// <summary>URL where parcel resource usage details can be retrieved</summary>
5108 public Uri ScriptResourceDetails;
5109 /// <summary>URL where parcel resource usage summary can be retrieved</summary>
5110 public Uri ScriptResourceSummary;
5111  
5112 /// <summary>
5113 /// Serializes object
5114 /// </summary>
5115 /// <returns><see cref="OSDMap"/> serialized data</returns>
5116 public OSDMap Serialize()
5117 {
5118 OSDMap map = new OSDMap(1);
5119 if (ScriptResourceSummary != null)
5120 {
5121 map["ScriptResourceSummary"] = OSD.FromString(ScriptResourceSummary.ToString());
5122 }
5123  
5124 if (ScriptResourceDetails != null)
5125 {
5126 map["ScriptResourceDetails"] = OSD.FromString(ScriptResourceDetails.ToString());
5127 }
5128 return map;
5129 }
5130  
5131 /// <summary>
5132 /// Deserializes object from OSD
5133 /// </summary>
5134 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
5135 public void Deserialize(OSDMap map)
5136 {
5137 if (map.ContainsKey("ScriptResourceSummary"))
5138 {
5139 ScriptResourceSummary = new Uri(map["ScriptResourceSummary"].AsString());
5140 }
5141 if (map.ContainsKey("ScriptResourceDetails"))
5142 {
5143 ScriptResourceDetails = new Uri(map["ScriptResourceDetails"].AsString());
5144 }
5145 }
5146  
5147 /// <summary>
5148 /// Detects which class handles deserialization of this message
5149 /// </summary>
5150 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
5151 /// <returns>Object capable of decoding this message</returns>
5152 public static IMessage GetMessageHandler(OSDMap map)
5153 {
5154 if (map.ContainsKey("parcel_id"))
5155 {
5156 return new LandResourcesRequest();
5157 }
5158 else if (map.ContainsKey("ScriptResourceSummary"))
5159 {
5160 return new LandResourcesMessage();
5161 }
5162 return null;
5163 }
5164 }
5165  
5166 /// <summary>Parcel resource usage</summary>
5167 public class LandResourcesInfo : BaseResourcesInfo
5168 {
5169 /// <summary>Array of <see cref="ParcelResourcesDetail"/> containing per percal resource usage</summary>
5170 public ParcelResourcesDetail[] Parcels;
5171  
5172 /// <summary>
5173 /// Deserializes object from OSD
5174 /// </summary>
5175 /// <param name="map">An <see cref="OSDMap"/> containing the data</param>
5176 public override void Deserialize(OSDMap map)
5177 {
5178 if (map.ContainsKey("summary"))
5179 {
5180 base.Deserialize(map);
5181 }
5182 else if (map.ContainsKey("parcels"))
5183 {
5184 OSDArray parcelsOSD = (OSDArray)map["parcels"];
5185 Parcels = new ParcelResourcesDetail[parcelsOSD.Count];
5186  
5187 for (int i = 0; i < parcelsOSD.Count; i++)
5188 {
5189 Parcels[i] = ParcelResourcesDetail.FromOSD(parcelsOSD[i]);
5190 }
5191 }
5192 }
5193 }
5194  
5195 #endregion Resource usage
5196  
5197 #region Display names
5198 /// <summary>
5199 /// Reply to request for bunch if display names
5200 /// </summary>
5201 public class GetDisplayNamesMessage : IMessage
5202 {
5203 /// <summary> Current display name </summary>
5204 public AgentDisplayName[] Agents = new AgentDisplayName[0];
5205  
5206 /// <summary> Following UUIDs failed to return a valid display name </summary>
5207 public UUID[] BadIDs = new UUID[0];
5208  
5209 /// <summary>
5210 /// Serializes the message
5211 /// </summary>
5212 /// <returns>OSD containting the messaage</returns>
5213 public OSDMap Serialize()
5214 {
5215 OSDArray agents = new OSDArray();
5216  
5217 if (Agents != null && Agents.Length > 0)
5218 {
5219 for (int i = 0; i < Agents.Length; i++)
5220 {
5221 agents.Add(Agents[i].GetOSD());
5222 }
5223 }
5224  
5225 OSDArray badIDs = new OSDArray();
5226 if (BadIDs != null && BadIDs.Length > 0)
5227 {
5228 for (int i = 0; i < BadIDs.Length; i++)
5229 {
5230 badIDs.Add(new OSDUUID(BadIDs[i]));
5231 }
5232 }
5233  
5234 OSDMap ret = new OSDMap();
5235 ret["agents"] = agents;
5236 ret["bad_ids"] = badIDs;
5237 return ret;
5238 }
5239  
5240 public void Deserialize(OSDMap map)
5241 {
5242 if (map["agents"].Type == OSDType.Array)
5243 {
5244 OSDArray osdAgents = (OSDArray)map["agents"];
5245  
5246 if (osdAgents.Count > 0)
5247 {
5248 Agents = new AgentDisplayName[osdAgents.Count];
5249  
5250 for (int i = 0; i < osdAgents.Count; i++)
5251 {
5252 Agents[i] = AgentDisplayName.FromOSD(osdAgents[i]);
5253 }
5254 }
5255 }
5256  
5257 if (map["bad_ids"].Type == OSDType.Array)
5258 {
5259 OSDArray osdBadIDs = (OSDArray)map["bad_ids"];
5260 if (osdBadIDs.Count > 0)
5261 {
5262 BadIDs = new UUID[osdBadIDs.Count];
5263  
5264 for (int i = 0; i < osdBadIDs.Count; i++)
5265 {
5266 BadIDs[i] = osdBadIDs[i];
5267 }
5268 }
5269 }
5270 }
5271 }
5272  
5273 /// <summary>
5274 /// Message sent when requesting change of the display name
5275 /// </summary>
5276 public class SetDisplayNameMessage : IMessage
5277 {
5278 /// <summary> Current display name </summary>
5279 public string OldDisplayName;
5280  
5281 /// <summary> Desired new display name </summary>
5282 public string NewDisplayName;
5283  
5284 /// <summary>
5285 /// Serializes the message
5286 /// </summary>
5287 /// <returns>OSD containting the messaage</returns>
5288 public OSDMap Serialize()
5289 {
5290 OSDArray names = new OSDArray(2);
5291 names.Add(OldDisplayName);
5292 names.Add(NewDisplayName);
5293  
5294 OSDMap name = new OSDMap();
5295 name["display_name"] = names;
5296 return name;
5297 }
5298  
5299 public void Deserialize(OSDMap map)
5300 {
5301 OSDArray names = (OSDArray)map["display_name"];
5302 OldDisplayName = names[0];
5303 NewDisplayName = names[1];
5304 }
5305 }
5306  
5307 /// <summary>
5308 /// Message recieved in response to request to change display name
5309 /// </summary>
5310 public class SetDisplayNameReplyMessage : IMessage
5311 {
5312 /// <summary> New display name </summary>
5313 public AgentDisplayName DisplayName;
5314  
5315 /// <summary> String message indicating the result of the operation </summary>
5316 public string Reason;
5317  
5318 /// <summary> Numerical code of the result, 200 indicates success </summary>
5319 public int Status;
5320  
5321 /// <summary>
5322 /// Serializes the message
5323 /// </summary>
5324 /// <returns>OSD containting the messaage</returns>
5325 public OSDMap Serialize()
5326 {
5327 OSDMap agent = (OSDMap)DisplayName.GetOSD();
5328 OSDMap ret = new OSDMap();
5329 ret["content"] = agent;
5330 ret["reason"] = Reason;
5331 ret["status"] = Status;
5332 return ret;
5333 }
5334  
5335 public void Deserialize(OSDMap map)
5336 {
5337 OSDMap agent = (OSDMap)map["content"];
5338 DisplayName = AgentDisplayName.FromOSD(agent);
5339 Reason = map["reason"];
5340 Status = map["status"];
5341 }
5342 }
5343  
5344 /// <summary>
5345 /// Message recieved when someone nearby changes their display name
5346 /// </summary>
5347 public class DisplayNameUpdateMessage : IMessage
5348 {
5349 /// <summary> Previous display name, empty string if default </summary>
5350 public string OldDisplayName;
5351  
5352 /// <summary> New display name </summary>
5353 public AgentDisplayName DisplayName;
5354  
5355 /// <summary>
5356 /// Serializes the message
5357 /// </summary>
5358 /// <returns>OSD containting the messaage</returns>
5359 public OSDMap Serialize()
5360 {
5361 OSDMap agent = (OSDMap)DisplayName.GetOSD();
5362 agent["old_display_name"] = OldDisplayName;
5363 OSDMap ret = new OSDMap();
5364 ret["agent"] = agent;
5365 return ret;
5366 }
5367  
5368 public void Deserialize(OSDMap map)
5369 {
5370 OSDMap agent = (OSDMap)map["agent"];
5371 DisplayName = AgentDisplayName.FromOSD(agent);
5372 OldDisplayName = agent["old_display_name"];
5373 }
5374 }
5375 #endregion Display names
5376 }