1
0

EventQueueGetHandlers.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Net;
  30. using OpenMetaverse;
  31. using OpenMetaverse.StructuredData;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Framework.Interfaces;
  34. namespace OpenSim.Region.ClientStack.Linden
  35. {
  36. public partial class EventQueueGetModule : IEventQueue, INonSharedRegionModule
  37. {
  38. /* this is not a event message
  39. public void DisableSimulator(ulong handle, UUID avatarID)
  40. {
  41. OSD item = EventQueueHelper.DisableSimulator(handle);
  42. Enqueue(item, avatarID);
  43. }
  44. */
  45. public osUTF8 StartEvent(string eventName)
  46. {
  47. osUTF8 sb = OSUTF8Cached.Acquire();
  48. LLSDxmlEncode2.AddMap(sb);
  49. LLSDxmlEncode2.AddElem("message", eventName, sb);
  50. LLSDxmlEncode2.AddMap("body", sb);
  51. return sb;
  52. }
  53. public osUTF8 StartEvent(string eventName, int cap)
  54. {
  55. osUTF8 sb = OSUTF8Cached.Acquire(cap);
  56. LLSDxmlEncode2.AddMap(sb);
  57. LLSDxmlEncode2.AddElem("message", eventName, sb);
  58. LLSDxmlEncode2.AddMap("body", sb);
  59. return sb;
  60. }
  61. public byte[] EndEventToBytes(osUTF8 sb)
  62. {
  63. LLSDxmlEncode2.AddEndMap(sb); // close body
  64. LLSDxmlEncode2.AddEndMap(sb); // close event
  65. return OSUTF8Cached.GetArrayAndRelease(sb);
  66. }
  67. public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
  68. {
  69. if (DebugLevel > 0)
  70. m_log.Debug($"{LogHeader} EnableSimulator. handle={handle}, endPoint={endPoint}, avatarID={avatarID}");
  71. osUTF8 sb = StartEvent("EnableSimulator");
  72. LLSDxmlEncode2.AddArrayAndMap("SimulatorInfo", sb);
  73. LLSDxmlEncode2.AddElem("Handle", handle, sb);
  74. LLSDxmlEncode2.AddElem("IP", endPoint.Address.GetAddressBytes(), sb);
  75. LLSDxmlEncode2.AddElem("Port", endPoint.Port, sb);
  76. LLSDxmlEncode2.AddElem("RegionSizeX", (uint)regionSizeX, sb);
  77. LLSDxmlEncode2.AddElem("RegionSizeY", (uint)regionSizeY, sb);
  78. LLSDxmlEncode2.AddEndMapAndArray(sb);
  79. Enqueue(EndEventToBytes(sb), avatarID);
  80. }
  81. public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath,
  82. ulong regionHandle, int regionSizeX, int regionSizeY)
  83. {
  84. if (DebugLevel > 0)
  85. m_log.Debug($"{LogHeader} EstablishAgentCommunication. handle={regionHandle}, endPoint={endPoint}, avatarID={avatarID}");
  86. osUTF8 sb = StartEvent("EstablishAgentCommunication");
  87. LLSDxmlEncode2.AddElem("agent-id", avatarID, sb);
  88. LLSDxmlEncode2.AddElem("sim-ip-and-port", endPoint.ToString(), sb);
  89. LLSDxmlEncode2.AddElem("seed-capability", capsPath, sb);
  90. // current viewers ignore this, also not needed its sent on enablesim
  91. //LLSDxmlEncode2.AddElem("region-handle", regionHandle, sb);
  92. //LLSDxmlEncode2.AddElem("region-size-x", (uint)regionSizeX, sb);
  93. //LLSDxmlEncode2.AddElem("region-size-y", (uint)regionSizeY, sb);
  94. Enqueue(EndEventToBytes(sb), avatarID);
  95. }
  96. public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess,
  97. IPEndPoint regionExternalEndPoint,
  98. uint locationID, uint flags, string capsURL,
  99. UUID avatarID, int regionSizeX, int regionSizeY)
  100. {
  101. if (DebugLevel > 0)
  102. m_log.Debug($"{LogHeader} TeleportFinishEvent. handle={regionHandle}, endPoint={regionExternalEndPoint}, avatarID={avatarID}");
  103. // not sure why flags get overwritten here
  104. if ((flags & (uint)TeleportFlags.IsFlying) != 0)
  105. flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying;
  106. else
  107. flags = (uint)TeleportFlags.ViaLocation;
  108. osUTF8 sb = StartEvent("TeleportFinish");
  109. LLSDxmlEncode2.AddArrayAndMap("Info", sb);
  110. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  111. LLSDxmlEncode2.AddElem("LocationID", (uint)4, sb); // TODO what is this?
  112. LLSDxmlEncode2.AddElem("SimIP", regionExternalEndPoint.Address.GetAddressBytes(), sb);
  113. LLSDxmlEncode2.AddElem("SimPort", regionExternalEndPoint.Port, sb);
  114. LLSDxmlEncode2.AddElem("RegionHandle", regionHandle, sb);
  115. LLSDxmlEncode2.AddElem("SeedCapability", capsURL, sb);
  116. LLSDxmlEncode2.AddElem("SimAccess",(int)simAccess, sb);
  117. LLSDxmlEncode2.AddElem("TeleportFlags", flags, sb);
  118. LLSDxmlEncode2.AddElem("RegionSizeX", (uint)regionSizeX, sb);
  119. LLSDxmlEncode2.AddElem("RegionSizeY", (uint)regionSizeY, sb);
  120. LLSDxmlEncode2.AddEndMapAndArray(sb);
  121. Enqueue(EndEventToBytes(sb), avatarID);
  122. }
  123. public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
  124. IPEndPoint newRegionExternalEndPoint,
  125. string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
  126. {
  127. if (DebugLevel > 0)
  128. m_log.Debug($"{LogHeader} CrossRegion. handle={handle}, avatarID={avatarID}, regionSize={regionSizeX},{regionSizeY}>");
  129. osUTF8 sb = StartEvent("CrossedRegion");
  130. LLSDxmlEncode2.AddArrayAndMap("AgentData", sb);
  131. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  132. LLSDxmlEncode2.AddElem("SessionID", sessionID, sb);
  133. LLSDxmlEncode2.AddEndMapAndArray(sb);
  134. LLSDxmlEncode2.AddArrayAndMap("Info", sb);
  135. LLSDxmlEncode2.AddElem("LookAt", lookAt, sb);
  136. LLSDxmlEncode2.AddElem("Position", pos, sb);
  137. LLSDxmlEncode2.AddEndMapAndArray(sb);
  138. LLSDxmlEncode2.AddArrayAndMap("RegionData", sb);
  139. LLSDxmlEncode2.AddElem("RegionHandle", handle, sb);
  140. LLSDxmlEncode2.AddElem("SeedCapability", capsURL, sb);
  141. LLSDxmlEncode2.AddElem("SimIP", newRegionExternalEndPoint.Address.GetAddressBytes(), sb);
  142. LLSDxmlEncode2.AddElem("SimPort", newRegionExternalEndPoint.Port, sb);
  143. LLSDxmlEncode2.AddElem("RegionSizeX", (uint)regionSizeX, sb);
  144. LLSDxmlEncode2.AddElem("RegionSizeY", (uint)regionSizeY, sb);
  145. LLSDxmlEncode2.AddEndMapAndArray(sb);
  146. Enqueue(EndEventToBytes(sb), avatarID);
  147. }
  148. private static string InstantMessageBody(UUID fromAgent, string message, UUID toAgent,
  149. string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID,
  150. Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket,
  151. bool checkEstate, int godLevel, bool limitedToEstate)
  152. {
  153. osUTF8 sb = new(512);
  154. LLSDxmlEncode2.AddMap("instantmessage", sb);
  155. LLSDxmlEncode2.AddMap("message_params", sb); //messageParams
  156. LLSDxmlEncode2.AddElem("type", dialog, sb);
  157. LLSDxmlEncode2.AddElem("position", position, sb);
  158. LLSDxmlEncode2.AddElem("region_id", UUID.Zero, sb);
  159. LLSDxmlEncode2.AddElem("to_id", toAgent, sb);
  160. LLSDxmlEncode2.AddElem("source", 0, sb);
  161. LLSDxmlEncode2.AddMap("data", sb); //messageParams data
  162. LLSDxmlEncode2.AddElem("binary_bucket", binaryBucket, sb);
  163. LLSDxmlEncode2.AddEndMap(sb); //messageParams data
  164. LLSDxmlEncode2.AddElem("message", message, sb);
  165. LLSDxmlEncode2.AddElem("id", transactionID, sb);
  166. LLSDxmlEncode2.AddElem("from_name", fromName, sb);
  167. LLSDxmlEncode2.AddElem("timestamp", timeStamp, sb);
  168. LLSDxmlEncode2.AddElem("offline", (offline ? 1 : 0), sb);
  169. LLSDxmlEncode2.AddElem("parent_estate_id", parentEstateID, sb);
  170. LLSDxmlEncode2.AddElem("ttl", (int)ttl, sb);
  171. LLSDxmlEncode2.AddElem("from_id", fromAgent, sb);
  172. LLSDxmlEncode2.AddElem("from_group", fromGroup, sb);
  173. LLSDxmlEncode2.AddEndMap(sb); //messageParams
  174. LLSDxmlEncode2.AddMap("agent_params", sb);
  175. LLSDxmlEncode2.AddElem("agent_id", fromAgent, sb);
  176. LLSDxmlEncode2.AddElem("check_estate", checkEstate, sb);
  177. LLSDxmlEncode2.AddElem("god_level", godLevel, sb);
  178. LLSDxmlEncode2.AddElem("limited_to_estate", limitedToEstate, sb);
  179. LLSDxmlEncode2.AddEndMap(sb); // agent params
  180. LLSDxmlEncode2.AddEndMap(sb);
  181. return sb.ToString();
  182. }
  183. public void ChatterboxInvitation(UUID sessionID, string sessionName,
  184. UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog,
  185. uint timeStamp, bool offline, int parentEstateID, Vector3 position,
  186. uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
  187. {
  188. osUTF8 sb = StartEvent("ChatterBoxInvitation");
  189. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  190. LLSDxmlEncode2.AddElem("from_name", fromName, sb);
  191. LLSDxmlEncode2.AddElem("session_name", sessionName, sb);
  192. LLSDxmlEncode2.AddElem("from_id", fromAgent, sb);
  193. LLSDxmlEncode2.AddLLSD(InstantMessageBody(fromAgent, message, toAgent,
  194. fromName, dialog, timeStamp, offline, parentEstateID, position,
  195. ttl, transactionID, fromGroup, binaryBucket, true, 0, true), sb);
  196. Enqueue(EndEventToBytes(sb), toAgent);
  197. }
  198. public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID toAgent, List<GroupChatListAgentUpdateData> updates)
  199. {
  200. osUTF8 sb = StartEvent("ChatterBoxSessionAgentListUpdates");
  201. LLSDxmlEncode2.AddMap("agent_updates",sb);
  202. foreach (GroupChatListAgentUpdateData up in updates)
  203. {
  204. LLSDxmlEncode2.AddMap(up.agentID.ToString(), sb);
  205. LLSDxmlEncode2.AddMap("info", sb);
  206. LLSDxmlEncode2.AddElem("can_voice_chat", up.canVoice, sb);
  207. LLSDxmlEncode2.AddElem("is_moderator", up.isModerator, sb);
  208. LLSDxmlEncode2.AddMap("mutes",sb);
  209. LLSDxmlEncode2.AddElem("text", up.mutedText, sb);
  210. LLSDxmlEncode2.AddEndMap(sb); // mutes
  211. LLSDxmlEncode2.AddEndMap(sb); // info
  212. if (up.enterOrLeave)
  213. LLSDxmlEncode2.AddElem("transition", "ENTER", sb);
  214. else
  215. LLSDxmlEncode2.AddElem("transition", "LEAVE", sb);
  216. LLSDxmlEncode2.AddEndMap(sb); //agentid
  217. }
  218. LLSDxmlEncode2.AddEndMap(sb); // agent_updates
  219. LLSDxmlEncode2.AddEmptyMap("updates",sb);
  220. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  221. Enqueue(EndEventToBytes(sb), toAgent);
  222. }
  223. public void ChatterBoxSessionStartReply(UUID sessionID, string sessionName, int type,
  224. bool voiceEnabled, bool voiceModerated, UUID tmpSessionID,
  225. bool sucess, string error,
  226. UUID toAgent)
  227. {
  228. osUTF8 sb = StartEvent("ChatterBoxSessionStartReply");
  229. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  230. LLSDxmlEncode2.AddElem("temp_session_id", tmpSessionID, sb);
  231. LLSDxmlEncode2.AddElem("success", sucess, sb);
  232. if(sucess)
  233. {
  234. LLSDxmlEncode2.AddMap("session_info", sb);
  235. LLSDxmlEncode2.AddMap("moderated_mode", sb);
  236. LLSDxmlEncode2.AddElem("voice", voiceModerated, sb);
  237. LLSDxmlEncode2.AddEndMap(sb);
  238. LLSDxmlEncode2.AddElem("session_name", sessionName, sb);
  239. LLSDxmlEncode2.AddElem("type", type, sb);
  240. LLSDxmlEncode2.AddElem("voice_enabled", voiceEnabled, sb);
  241. LLSDxmlEncode2.AddEndMap(sb);
  242. }
  243. else
  244. LLSDxmlEncode2.AddElem("error", String.IsNullOrEmpty(error) ? "" : error, sb);
  245. Enqueue(EndEventToBytes(sb), toAgent);
  246. }
  247. public void ChatterBoxForceClose(UUID toAgent, UUID sessionID, string reason)
  248. {
  249. osUTF8 sb = StartEvent("ForceCloseChatterBoxSession");
  250. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  251. LLSDxmlEncode2.AddElem("reason", reason, sb);
  252. Enqueue(EndEventToBytes(sb), toAgent);
  253. }
  254. public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data)
  255. {
  256. osUTF8 sb = StartEvent("AgentGroupDataUpdate");
  257. LLSDxmlEncode2.AddArrayAndMap("AgentData", sb);
  258. LLSDxmlEncode2.AddElem("AgentID", AgentID, sb);
  259. LLSDxmlEncode2.AddEndMapAndArray(sb);
  260. if (data.Length == 0)
  261. {
  262. LLSDxmlEncode2.AddEmptyArray("GroupData", sb);
  263. LLSDxmlEncode2.AddEmptyArray("NewGroupData", sb);
  264. }
  265. else
  266. {
  267. List<bool> lstInProfiles = new List<bool>(data.Length);
  268. LLSDxmlEncode2.AddArray("GroupData", sb);
  269. foreach (GroupMembershipData m in data)
  270. {
  271. LLSDxmlEncode2.AddMap(sb);
  272. LLSDxmlEncode2.AddElem("GroupID", m.GroupID, sb);
  273. LLSDxmlEncode2.AddElem("GroupPowers", m.GroupPowers, sb);
  274. LLSDxmlEncode2.AddElem("AcceptNotices", m.AcceptNotices, sb);
  275. LLSDxmlEncode2.AddElem("GroupInsigniaID", m.GroupPicture, sb);
  276. LLSDxmlEncode2.AddElem("Contribution", m.Contribution, sb);
  277. LLSDxmlEncode2.AddElem("GroupName", m.GroupName, sb);
  278. LLSDxmlEncode2.AddEndMap(sb);
  279. lstInProfiles.Add(m.ListInProfile);
  280. }
  281. LLSDxmlEncode2.AddEndArray(sb);
  282. LLSDxmlEncode2.AddArray("NewGroupData", sb);
  283. foreach(bool b in lstInProfiles)
  284. {
  285. LLSDxmlEncode2.AddMap(sb);
  286. LLSDxmlEncode2.AddElem("ListInProfile", b, sb);
  287. LLSDxmlEncode2.AddEndMap(sb);
  288. }
  289. LLSDxmlEncode2.AddEndArray(sb);
  290. }
  291. Enqueue(EndEventToBytes(sb), AgentID);
  292. }
  293. public void PlacesQueryReply(UUID avatarID, UUID queryID, UUID transactionID, PlacesReplyData[] replyDataArray)
  294. {
  295. osUTF8 sb = new(256);
  296. LLSDxmlEncode2.AddMap(sb);
  297. LLSDxmlEncode2.AddElem("message", "PlacesReplyMessage", sb);
  298. LLSDxmlEncode2.AddMap("QueryData[]", sb); LLSDxmlEncode2.AddArray(sb);
  299. LLSDxmlEncode2.AddArray("AgentData", sb);
  300. LLSDxmlEncode2.AddMap(sb);
  301. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  302. LLSDxmlEncode2.AddElem("QueryID", queryID, sb);
  303. LLSDxmlEncode2.AddElem("TransactionID", transactionID, sb);
  304. LLSDxmlEncode2.AddEndMap(sb);
  305. LLSDxmlEncode2.AddEndArray(sb);
  306. LLSDxmlEncode2.AddArray("QueryData", sb);
  307. for (int i = 0; i < replyDataArray.Length; ++i)
  308. {
  309. PlacesReplyData data = replyDataArray[i];
  310. LLSDxmlEncode2.AddMap(sb);
  311. LLSDxmlEncode2.AddElem("ActualArea", data.ActualArea, sb);
  312. LLSDxmlEncode2.AddElem("BillableArea", data.BillableArea, sb);
  313. LLSDxmlEncode2.AddElem("Description", data.Desc, sb);
  314. LLSDxmlEncode2.AddElem("Dwell", data.Dwell, sb);
  315. LLSDxmlEncode2.AddElem("Flags", data.Flags, sb);
  316. LLSDxmlEncode2.AddElem("GlobalX", data.GlobalX, sb);
  317. LLSDxmlEncode2.AddElem("GlobalY", data.GlobalY, sb);
  318. LLSDxmlEncode2.AddElem("GlobalZ", data.GlobalZ, sb);
  319. LLSDxmlEncode2.AddElem("Name", data.Name, sb);
  320. LLSDxmlEncode2.AddElem("OwnerID", data.OwnerID, sb);
  321. LLSDxmlEncode2.AddElem("SimName", data.SimName, sb);
  322. LLSDxmlEncode2.AddElem("SnapShotID", data.SnapshotID, sb);
  323. LLSDxmlEncode2.AddElem("ProductSku", (int)0, sb);
  324. LLSDxmlEncode2.AddElem("Price", data.Price, sb);
  325. LLSDxmlEncode2.AddEndMap(sb);
  326. }
  327. LLSDxmlEncode2.AddEndArray(sb);
  328. Enqueue(EndEventToBytes(sb), avatarID);
  329. }
  330. public void ScriptRunningEvent(UUID objectID, UUID itemID, bool running, UUID avatarID)
  331. {
  332. osUTF8 sb = StartEvent("ScriptRunningReply");
  333. LLSDxmlEncode2.AddArrayAndMap("Script", sb);
  334. LLSDxmlEncode2.AddElem("ObjectID", objectID, sb);
  335. LLSDxmlEncode2.AddElem("ItemID", itemID, sb);
  336. LLSDxmlEncode2.AddElem("Running", running, sb);
  337. LLSDxmlEncode2.AddElem("Mono", true, sb);
  338. LLSDxmlEncode2.AddEndMapAndArray(sb);
  339. Enqueue(EndEventToBytes(sb), avatarID);
  340. }
  341. public void partPhysicsProperties(uint localID, byte physhapetype,
  342. float density, float friction, float bounce, float gravmod, UUID avatarID)
  343. {
  344. osUTF8 sb = StartEvent("ObjectPhysicsProperties");
  345. LLSDxmlEncode2.AddArrayAndMap("ObjectData", sb);
  346. LLSDxmlEncode2.AddElem("LocalID", (int)localID, sb);
  347. LLSDxmlEncode2.AddElem("Density", density, sb);
  348. LLSDxmlEncode2.AddElem("Friction", friction, sb);
  349. LLSDxmlEncode2.AddElem("GravityMultiplier", gravmod, sb);
  350. LLSDxmlEncode2.AddElem("Restitution", bounce, sb);
  351. LLSDxmlEncode2.AddElem("PhysicsShapeType", (int)physhapetype, sb);
  352. LLSDxmlEncode2.AddEndMapAndArray(sb);
  353. Enqueue(EndEventToBytes(sb), avatarID);
  354. }
  355. public void WindlightRefreshEvent(int interpolate, UUID avatarID)
  356. {
  357. osUTF8 sb = StartEvent("WindLightRefresh");
  358. LLSDxmlEncode2.AddElem("Interpolate", interpolate > 0 ? 1 : 0, sb);
  359. Enqueue(EndEventToBytes(sb), avatarID);
  360. }
  361. public void SendBulkUpdateInventoryItem(InventoryItemBase item, UUID avatarID, UUID? transationID = null)
  362. {
  363. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  364. osUTF8 sb = StartEvent("BulkUpdateInventory");
  365. LLSDxmlEncode2.AddArray("AgentData", sb);
  366. LLSDxmlEncode2.AddMap(sb);
  367. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  368. LLSDxmlEncode2.AddElem("TransactionID", transationID ?? UUID.Random(), sb);
  369. LLSDxmlEncode2.AddEndMapAndArray(sb);
  370. LLSDxmlEncode2.AddRawElem("<key>FolderData</key><array><map><key>FolderID</key><uuid>00000000-0000-0000-0000-000000000000</uuid><key>Name</key><string></string><key>ParentID</key><uuid>00000000-0000-0000-0000-000000000000</uuid ><key>Type</key ><integer>-1</integer></map ></array>",sb);
  371. osUTF8 osName = new osUTF8(item.Name, 255);
  372. osUTF8 osDesc = new osUTF8(item.Description, 255);
  373. LLSDxmlEncode2.AddArray("ItemData", sb);
  374. LLSDxmlEncode2.AddMap(sb);
  375. LLSDxmlEncode2.AddElem("ItemID", item.ID, sb);
  376. LLSDxmlEncode2.AddElem("AssetID", item.AssetID, sb);
  377. LLSDxmlEncode2.AddElem("CreatorID", item.CreatorIdAsUuid, sb);
  378. LLSDxmlEncode2.AddElem("BaseMask", item.BasePermissions, sb);
  379. LLSDxmlEncode2.AddElem("CreationDate", item.CreationDate, sb);
  380. LLSDxmlEncode2.AddElem("Description", osDesc, sb);
  381. LLSDxmlEncode2.AddElem("EveryoneMask", item.EveryOnePermissions, sb);
  382. LLSDxmlEncode2.AddElem("FolderID", item.Folder, sb);
  383. LLSDxmlEncode2.AddElem("InvType", (sbyte)item.InvType, sb);
  384. LLSDxmlEncode2.AddElem("Name", osName, sb);
  385. LLSDxmlEncode2.AddElem("NextOwnerMask", item.NextPermissions, sb);
  386. LLSDxmlEncode2.AddElem("GroupID", item.GroupID, sb);
  387. LLSDxmlEncode2.AddElem("GroupMask", item.GroupPermissions, sb);
  388. LLSDxmlEncode2.AddElem("GroupOwned", item.GroupOwned , sb);
  389. LLSDxmlEncode2.AddElem("OwnerID", item.Owner, sb);
  390. LLSDxmlEncode2.AddElem("OwnerMask", item.CurrentPermissions, sb);
  391. LLSDxmlEncode2.AddElem("SalePrice", item.SalePrice, sb);
  392. LLSDxmlEncode2.AddElem("SaleType", item.SaleType, sb);
  393. LLSDxmlEncode2.AddElem("Type", (sbyte)item.AssetType, sb);
  394. LLSDxmlEncode2.AddElem("CallbackID", (uint)0, sb);
  395. LLSDxmlEncode2.AddElem("Flags", item.Flags & 0x2000ff, sb);
  396. uint iCRC =
  397. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  398. (sbyte)item.AssetType, item.AssetID,
  399. item.GroupID, 100,
  400. item.Owner, item.CreatorIdAsUuid,
  401. item.ID, item.Folder,
  402. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  403. FULL_MASK_PERMISSIONS);
  404. LLSDxmlEncode2.AddElem("CRC", iCRC, sb);
  405. LLSDxmlEncode2.AddEndMapAndArray(sb);
  406. Enqueue(EndEventToBytes(sb), avatarID);
  407. }
  408. public static string KeepAliveEvent()
  409. {
  410. osUTF8 sb = new(256);
  411. LLSDxmlEncode2.AddMap(sb);
  412. LLSDxmlEncode2.AddElem("message", "FAKEEVENT", sb);
  413. LLSDxmlEncode2.AddMap("body", sb);
  414. LLSDxmlEncode2.AddEndMap(sb); // close body
  415. LLSDxmlEncode2.AddEndMap(sb); // close event
  416. return sb.ToString();
  417. }
  418. public void SendLargeGenericMessage(UUID avatarID, UUID? transationID, UUID? sessionID,
  419. string method, UUID invoice, List<string> message)
  420. {
  421. osUTF8 sb = StartEvent("LargeGenericMessage");
  422. LLSDxmlEncode2.AddArrayAndMap("AgentData", sb);
  423. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  424. if (transationID.HasValue)
  425. LLSDxmlEncode2.AddElem("TransactionID", transationID.Value, sb);
  426. if (sessionID.HasValue)
  427. LLSDxmlEncode2.AddElem("SessionID", sessionID.Value, sb);
  428. LLSDxmlEncode2.AddEndMapAndArray(sb);
  429. LLSDxmlEncode2.AddArrayAndMap("MethodData", sb);
  430. LLSDxmlEncode2.AddElem("Method", method, sb);
  431. LLSDxmlEncode2.AddElem("Invoice", invoice, sb);
  432. LLSDxmlEncode2.AddEndMapAndArray(sb);
  433. LLSDxmlEncode2.AddArrayAndMap("ParamList", sb);
  434. foreach (string s in message)
  435. LLSDxmlEncode2.AddElem("Parameter", s, sb);
  436. LLSDxmlEncode2.AddEndMapAndArray(sb);
  437. Enqueue(EndEventToBytes(sb), avatarID);
  438. }
  439. public void SendLargeGenericMessage(UUID avatarID, UUID? transationID, UUID? sessionID,
  440. string method, UUID invoice, List<byte[]> message)
  441. {
  442. osUTF8 sb = StartEvent("LargeGenericMessage");
  443. LLSDxmlEncode2.AddArrayAndMap("AgentData", sb);
  444. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  445. if (transationID.HasValue)
  446. LLSDxmlEncode2.AddElem("TransactionID", transationID.Value, sb);
  447. if (sessionID.HasValue)
  448. LLSDxmlEncode2.AddElem("SessionID", sessionID.Value, sb);
  449. LLSDxmlEncode2.AddEndMapAndArray(sb);
  450. LLSDxmlEncode2.AddArrayAndMap("MethodData", sb);
  451. LLSDxmlEncode2.AddElem("Method", method, sb);
  452. LLSDxmlEncode2.AddElem("Invoice", invoice, sb);
  453. LLSDxmlEncode2.AddEndMapAndArray(sb);
  454. LLSDxmlEncode2.AddArrayAndMap("ParamList", sb);
  455. foreach (byte[] b in message)
  456. {
  457. LLSDxmlEncode2.AddLLSD("<key>Parameter</key><string>", sb);
  458. sb.Append(b);
  459. LLSDxmlEncode2.AddLLSD("</string>", sb);
  460. }
  461. LLSDxmlEncode2.AddEndMapAndArray(sb);
  462. Enqueue(EndEventToBytes(sb), avatarID);
  463. }
  464. public byte[] BuildEvent(string eventName, OSD eventBody)
  465. {
  466. OSDMap llsdEvent = new(2);
  467. llsdEvent.Add("message", new OSDString(eventName));
  468. llsdEvent.Add("body", eventBody);
  469. return Util.UTF8NBGetbytes(OSDParser.SerializeLLSDInnerXmlString(llsdEvent));
  470. }
  471. }
  472. }