PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/OpenMetaverse/Modules/Messages/LindenMessages.cs

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