1
0

EventQueueGetHandlers.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Text;
  33. using log4net;
  34. using Nini.Config;
  35. using Mono.Addins;
  36. using OpenMetaverse;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. using OpenSim.Framework.Servers.HttpServer;
  40. using OpenSim.Region.Framework.Interfaces;
  41. using OpenSim.Region.Framework.Scenes;
  42. using Caps=OpenSim.Framework.Capabilities.Caps;
  43. namespace OpenSim.Region.ClientStack.Linden
  44. {
  45. public partial class EventQueueGetModule : IEventQueue, INonSharedRegionModule
  46. {
  47. /* this is not a event message
  48. public void DisableSimulator(ulong handle, UUID avatarID)
  49. {
  50. OSD item = EventQueueHelper.DisableSimulator(handle);
  51. Enqueue(item, avatarID);
  52. }
  53. */
  54. public osUTF8 StartEvent(string eventName)
  55. {
  56. osUTF8 sb = OSUTF8Cached.Acquire();
  57. LLSDxmlEncode2.AddMap(sb);
  58. LLSDxmlEncode2.AddElem("message", eventName, sb);
  59. LLSDxmlEncode2.AddMap("body", sb);
  60. return sb;
  61. }
  62. public osUTF8 StartEvent(string eventName, int cap)
  63. {
  64. osUTF8 sb = OSUTF8Cached.Acquire(cap);
  65. LLSDxmlEncode2.AddMap(sb);
  66. LLSDxmlEncode2.AddElem("message", eventName, sb);
  67. LLSDxmlEncode2.AddMap("body", sb);
  68. return sb;
  69. }
  70. public byte[] EndEventToBytes(osUTF8 sb)
  71. {
  72. LLSDxmlEncode2.AddEndMap(sb); // close body
  73. LLSDxmlEncode2.AddEndMap(sb); // close event
  74. return OSUTF8Cached.GetArrayAndRelease(sb);
  75. }
  76. public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
  77. {
  78. if (DebugLevel > 0)
  79. m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}",
  80. LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY);
  81. osUTF8 sb = StartEvent("EnableSimulator");
  82. LLSDxmlEncode2.AddArrayAndMap("SimulatorInfo", sb);
  83. LLSDxmlEncode2.AddElem("Handle", handle, sb);
  84. LLSDxmlEncode2.AddElem("IP", endPoint.Address.GetAddressBytes(), sb);
  85. LLSDxmlEncode2.AddElem("Port", endPoint.Port, sb);
  86. LLSDxmlEncode2.AddElem("RegionSizeX", (uint)regionSizeX, sb);
  87. LLSDxmlEncode2.AddElem("RegionSizeY", (uint)regionSizeY, sb);
  88. LLSDxmlEncode2.AddEndMapAndArray(sb);
  89. Enqueue(EndEventToBytes(sb), avatarID);
  90. }
  91. public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath,
  92. ulong regionHandle, int regionSizeX, int regionSizeY)
  93. {
  94. if (DebugLevel > 0)
  95. m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}",
  96. LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY);
  97. osUTF8 sb = StartEvent("EstablishAgentCommunication");
  98. LLSDxmlEncode2.AddElem("agent-id", avatarID, sb);
  99. LLSDxmlEncode2.AddElem("sim-ip-and-port", endPoint.ToString(), sb);
  100. LLSDxmlEncode2.AddElem("seed-capability", capsPath, sb);
  101. // current viewers ignore this, also not needed its sent on enablesim
  102. //LLSDxmlEncode2.AddElem("region-handle", regionHandle, sb);
  103. //LLSDxmlEncode2.AddElem("region-size-x", (uint)regionSizeX, sb);
  104. //LLSDxmlEncode2.AddElem("region-size-y", (uint)regionSizeY, sb);
  105. Enqueue(EndEventToBytes(sb), avatarID);
  106. }
  107. public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess,
  108. IPEndPoint regionExternalEndPoint,
  109. uint locationID, uint flags, string capsURL,
  110. UUID avatarID, int regionSizeX, int regionSizeY)
  111. {
  112. if (DebugLevel > 0)
  113. m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}",
  114. LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY);
  115. // not sure why flags get overwritten here
  116. if ((flags & (uint)TeleportFlags.IsFlying) != 0)
  117. flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying;
  118. else
  119. flags = (uint)TeleportFlags.ViaLocation;
  120. osUTF8 sb = StartEvent("TeleportFinish");
  121. LLSDxmlEncode2.AddArrayAndMap("Info", sb);
  122. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  123. LLSDxmlEncode2.AddElem("LocationID", (uint)4, sb); // TODO what is this?
  124. LLSDxmlEncode2.AddElem("SimIP", regionExternalEndPoint.Address.GetAddressBytes(), sb);
  125. LLSDxmlEncode2.AddElem("SimPort", regionExternalEndPoint.Port, sb);
  126. LLSDxmlEncode2.AddElem("RegionHandle", regionHandle, sb);
  127. LLSDxmlEncode2.AddElem("SeedCapability", capsURL, sb);
  128. LLSDxmlEncode2.AddElem("SimAccess",(int)simAccess, sb);
  129. LLSDxmlEncode2.AddElem("TeleportFlags", flags, sb);
  130. LLSDxmlEncode2.AddElem("RegionSizeX", (uint)regionSizeX, sb);
  131. LLSDxmlEncode2.AddElem("RegionSizeY", (uint)regionSizeY, sb);
  132. LLSDxmlEncode2.AddEndMapAndArray(sb);
  133. Enqueue(EndEventToBytes(sb), avatarID);
  134. }
  135. public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
  136. IPEndPoint newRegionExternalEndPoint,
  137. string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
  138. {
  139. if (DebugLevel > 0)
  140. m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>",
  141. LogHeader, handle, avatarID, regionSizeX, regionSizeY);
  142. osUTF8 sb = StartEvent("CrossedRegion");
  143. LLSDxmlEncode2.AddArrayAndMap("AgentData", sb);
  144. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  145. LLSDxmlEncode2.AddElem("SessionID", sessionID, sb);
  146. LLSDxmlEncode2.AddEndMapAndArray(sb);
  147. LLSDxmlEncode2.AddArrayAndMap("Info", sb);
  148. LLSDxmlEncode2.AddElem("LookAt", lookAt, sb);
  149. LLSDxmlEncode2.AddElem("Position", pos, sb);
  150. LLSDxmlEncode2.AddEndMapAndArray(sb);
  151. LLSDxmlEncode2.AddArrayAndMap("RegionData", sb);
  152. LLSDxmlEncode2.AddElem("RegionHandle", handle, sb);
  153. LLSDxmlEncode2.AddElem("SeedCapability", capsURL, sb);
  154. LLSDxmlEncode2.AddElem("SimIP", newRegionExternalEndPoint.Address.GetAddressBytes(), sb);
  155. LLSDxmlEncode2.AddElem("SimPort", newRegionExternalEndPoint.Port, sb);
  156. LLSDxmlEncode2.AddElem("RegionSizeX", (uint)regionSizeX, sb);
  157. LLSDxmlEncode2.AddElem("RegionSizeY", (uint)regionSizeY, sb);
  158. LLSDxmlEncode2.AddEndMapAndArray(sb);
  159. Enqueue(EndEventToBytes(sb), avatarID);
  160. }
  161. private static string InstantMessageBody(UUID fromAgent, string message, UUID toAgent,
  162. string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID,
  163. Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket,
  164. bool checkEstate, int godLevel, bool limitedToEstate)
  165. {
  166. osUTF8 sb = new osUTF8(512);
  167. LLSDxmlEncode2.AddMap("instantmessage", sb);
  168. LLSDxmlEncode2.AddMap("message_params", sb); //messageParams
  169. LLSDxmlEncode2.AddElem("type", dialog, sb);
  170. LLSDxmlEncode2.AddElem("position", position, sb);
  171. LLSDxmlEncode2.AddElem("region_id", UUID.Zero, sb);
  172. LLSDxmlEncode2.AddElem("to_id", toAgent, sb);
  173. LLSDxmlEncode2.AddElem("source", 0, sb);
  174. LLSDxmlEncode2.AddMap("data", sb); //messageParams data
  175. LLSDxmlEncode2.AddElem("binary_bucket", binaryBucket, sb);
  176. LLSDxmlEncode2.AddEndMap(sb); //messageParams data
  177. LLSDxmlEncode2.AddElem("message", message, sb);
  178. LLSDxmlEncode2.AddElem("id", transactionID, sb);
  179. LLSDxmlEncode2.AddElem("from_name", fromName, sb);
  180. LLSDxmlEncode2.AddElem("timestamp", timeStamp, sb);
  181. LLSDxmlEncode2.AddElem("offline", (offline ? 1 : 0), sb);
  182. LLSDxmlEncode2.AddElem("parent_estate_id", parentEstateID, sb);
  183. LLSDxmlEncode2.AddElem("ttl", (int)ttl, sb);
  184. LLSDxmlEncode2.AddElem("from_id", fromAgent, sb);
  185. LLSDxmlEncode2.AddElem("from_group", fromGroup, sb);
  186. LLSDxmlEncode2.AddEndMap(sb); //messageParams
  187. LLSDxmlEncode2.AddMap("agent_params", sb);
  188. LLSDxmlEncode2.AddElem("agent_id", fromAgent, sb);
  189. LLSDxmlEncode2.AddElem("check_estate", checkEstate, sb);
  190. LLSDxmlEncode2.AddElem("god_level", godLevel, sb);
  191. LLSDxmlEncode2.AddElem("limited_to_estate", limitedToEstate, sb);
  192. LLSDxmlEncode2.AddEndMap(sb); // agent params
  193. LLSDxmlEncode2.AddEndMap(sb);
  194. return sb.ToString();
  195. }
  196. public void ChatterboxInvitation(UUID sessionID, string sessionName,
  197. UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog,
  198. uint timeStamp, bool offline, int parentEstateID, Vector3 position,
  199. uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
  200. {
  201. osUTF8 sb = StartEvent("ChatterBoxInvitation");
  202. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  203. LLSDxmlEncode2.AddElem("from_name", fromName, sb);
  204. LLSDxmlEncode2.AddElem("session_name", sessionName, sb);
  205. LLSDxmlEncode2.AddElem("from_id", fromAgent, sb);
  206. LLSDxmlEncode2.AddLLSD(InstantMessageBody(fromAgent, message, toAgent,
  207. fromName, dialog, timeStamp, offline, parentEstateID, position,
  208. ttl, transactionID, fromGroup, binaryBucket, true, 0, true), sb);
  209. Enqueue(EndEventToBytes(sb), toAgent);
  210. }
  211. public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID toAgent, List<GroupChatListAgentUpdateData> updates)
  212. {
  213. osUTF8 sb = StartEvent("ChatterBoxSessionAgentListUpdates",1024);
  214. LLSDxmlEncode2.AddMap("agent_updates",sb);
  215. foreach (GroupChatListAgentUpdateData up in updates)
  216. {
  217. LLSDxmlEncode2.AddMap(up.agentID.ToString(), sb);
  218. LLSDxmlEncode2.AddMap("info", sb);
  219. LLSDxmlEncode2.AddElem("can_voice_chat", up.canVoice, sb);
  220. LLSDxmlEncode2.AddElem("is_moderator", up.isModerator, sb);
  221. LLSDxmlEncode2.AddMap("mutes",sb);
  222. LLSDxmlEncode2.AddElem("text", up.mutedText, sb);
  223. LLSDxmlEncode2.AddEndMap(sb); // mutes
  224. LLSDxmlEncode2.AddEndMap(sb); // info
  225. if (up.enterOrLeave)
  226. LLSDxmlEncode2.AddElem("transition", "ENTER", sb);
  227. else
  228. LLSDxmlEncode2.AddElem("transition", "LEAVE", sb);
  229. LLSDxmlEncode2.AddEndMap(sb); //agentid
  230. }
  231. LLSDxmlEncode2.AddEndMap(sb); // agent_updates
  232. LLSDxmlEncode2.AddEmptyMap("updates",sb);
  233. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  234. Enqueue(EndEventToBytes(sb), toAgent);
  235. }
  236. public void ChatterBoxSessionStartReply(UUID sessionID, string sessionName, int type,
  237. bool voiceEnabled, bool voiceModerated, UUID tmpSessionID,
  238. bool sucess, string error,
  239. UUID toAgent)
  240. {
  241. osUTF8 sb = StartEvent("ChatterBoxSessionStartReply");
  242. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  243. LLSDxmlEncode2.AddElem("temp_session_id", tmpSessionID, sb);
  244. LLSDxmlEncode2.AddElem("success", sucess, sb);
  245. if(sucess)
  246. {
  247. LLSDxmlEncode2.AddMap("session_info", sb);
  248. LLSDxmlEncode2.AddMap("moderated_mode", sb);
  249. LLSDxmlEncode2.AddElem("voice", voiceModerated, sb);
  250. LLSDxmlEncode2.AddEndMap(sb);
  251. LLSDxmlEncode2.AddElem("session_name", sessionName, sb);
  252. LLSDxmlEncode2.AddElem("type", type, sb);
  253. LLSDxmlEncode2.AddElem("voice_enabled", voiceEnabled, sb);
  254. LLSDxmlEncode2.AddEndMap(sb);
  255. }
  256. else
  257. LLSDxmlEncode2.AddElem("error", String.IsNullOrEmpty(error) ? "" : error, sb);
  258. Enqueue(EndEventToBytes(sb), toAgent);
  259. }
  260. public void ChatterBoxForceClose(UUID toAgent, UUID sessionID, string reason)
  261. {
  262. osUTF8 sb = StartEvent("ForceCloseChatterBoxSession");
  263. LLSDxmlEncode2.AddElem("session_id", sessionID, sb);
  264. LLSDxmlEncode2.AddElem("reason", reason, sb);
  265. Enqueue(EndEventToBytes(sb), toAgent);
  266. }
  267. public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data)
  268. {
  269. osUTF8 sb = StartEvent("AgentGroupDataUpdate");
  270. LLSDxmlEncode2.AddArrayAndMap("AgentData", sb);
  271. LLSDxmlEncode2.AddElem("AgentID", AgentID, sb);
  272. LLSDxmlEncode2.AddEndMapAndArray(sb);
  273. if (data.Length == 0)
  274. {
  275. LLSDxmlEncode2.AddEmptyArray("GroupData", sb);
  276. LLSDxmlEncode2.AddEmptyArray("NewGroupData", sb);
  277. }
  278. else
  279. {
  280. List<bool> lstInProfiles = new List<bool>(data.Length);
  281. LLSDxmlEncode2.AddArray("GroupData", sb);
  282. foreach (GroupMembershipData m in data)
  283. {
  284. LLSDxmlEncode2.AddMap(sb);
  285. LLSDxmlEncode2.AddElem("GroupID", m.GroupID, sb);
  286. LLSDxmlEncode2.AddElem("GroupPowers", m.GroupPowers, sb);
  287. LLSDxmlEncode2.AddElem("AcceptNotices", m.AcceptNotices, sb);
  288. LLSDxmlEncode2.AddElem("GroupInsigniaID", m.GroupPicture, sb);
  289. LLSDxmlEncode2.AddElem("Contribution", m.Contribution, sb);
  290. LLSDxmlEncode2.AddElem("GroupName", m.GroupName, sb);
  291. LLSDxmlEncode2.AddEndMap(sb);
  292. lstInProfiles.Add(m.ListInProfile);
  293. }
  294. LLSDxmlEncode2.AddEndArray(sb);
  295. LLSDxmlEncode2.AddArray("NewGroupData", sb);
  296. foreach(bool b in lstInProfiles)
  297. {
  298. LLSDxmlEncode2.AddMap(sb);
  299. LLSDxmlEncode2.AddElem("ListInProfile", b, sb);
  300. LLSDxmlEncode2.AddEndMap(sb);
  301. }
  302. LLSDxmlEncode2.AddEndArray(sb);
  303. }
  304. Enqueue(EndEventToBytes(sb), AgentID);
  305. }
  306. public void PlacesQueryReply(UUID avatarID, UUID queryID, UUID transactionID, PlacesReplyData[] replyDataArray)
  307. {
  308. osUTF8 sb = new osUTF8(256);
  309. LLSDxmlEncode2.AddMap(sb);
  310. LLSDxmlEncode2.AddElem("message", "PlacesReplyMessage", sb);
  311. LLSDxmlEncode2.AddMap("QueryData[]", sb); LLSDxmlEncode2.AddArray(sb);
  312. LLSDxmlEncode2.AddArray("AgentData", sb);
  313. LLSDxmlEncode2.AddMap(sb);
  314. LLSDxmlEncode2.AddElem("AgentID", avatarID, sb);
  315. LLSDxmlEncode2.AddElem("QueryID", queryID, sb);
  316. LLSDxmlEncode2.AddElem("TransactionID", transactionID, sb);
  317. LLSDxmlEncode2.AddEndMap(sb);
  318. LLSDxmlEncode2.AddEndArray(sb);
  319. LLSDxmlEncode2.AddArray("QueryData", sb);
  320. for (int i = 0; i < replyDataArray.Length; ++i)
  321. {
  322. PlacesReplyData data = replyDataArray[i];
  323. LLSDxmlEncode2.AddMap(sb);
  324. LLSDxmlEncode2.AddElem("ActualArea", data.ActualArea, sb);
  325. LLSDxmlEncode2.AddElem("BillableArea", data.BillableArea, sb);
  326. LLSDxmlEncode2.AddElem("Description", data.Desc, sb);
  327. LLSDxmlEncode2.AddElem("Dwell", data.Dwell, sb);
  328. LLSDxmlEncode2.AddElem("Flags", data.Flags, sb);
  329. LLSDxmlEncode2.AddElem("GlobalX", data.GlobalX, sb);
  330. LLSDxmlEncode2.AddElem("GlobalY", data.GlobalY, sb);
  331. LLSDxmlEncode2.AddElem("GlobalZ", data.GlobalZ, sb);
  332. LLSDxmlEncode2.AddElem("Name", data.Name, sb);
  333. LLSDxmlEncode2.AddElem("OwnerID", data.OwnerID, sb);
  334. LLSDxmlEncode2.AddElem("SimName", data.SimName, sb);
  335. LLSDxmlEncode2.AddElem("SnapShotID", data.SnapshotID, sb);
  336. LLSDxmlEncode2.AddElem("ProductSku", (int)0, sb);
  337. LLSDxmlEncode2.AddElem("Price", data.Price, sb);
  338. LLSDxmlEncode2.AddEndMap(sb);
  339. }
  340. LLSDxmlEncode2.AddEndArray(sb);
  341. Enqueue(EndEventToBytes(sb), avatarID);
  342. }
  343. public void ScriptRunningEvent(UUID objectID, UUID itemID, bool running, UUID avatarID)
  344. {
  345. osUTF8 sb = StartEvent("ScriptRunningReply");
  346. LLSDxmlEncode2.AddArrayAndMap("Script", sb);
  347. LLSDxmlEncode2.AddElem("ObjectID", objectID, sb);
  348. LLSDxmlEncode2.AddElem("ItemID", itemID, sb);
  349. LLSDxmlEncode2.AddElem("Running", running, sb);
  350. LLSDxmlEncode2.AddElem("Mono", true, sb);
  351. LLSDxmlEncode2.AddEndMapAndArray(sb);
  352. Enqueue(EndEventToBytes(sb), avatarID);
  353. }
  354. public void partPhysicsProperties(uint localID, byte physhapetype,
  355. float density, float friction, float bounce, float gravmod, UUID avatarID)
  356. {
  357. osUTF8 sb = StartEvent("ObjectPhysicsProperties");
  358. LLSDxmlEncode2.AddArrayAndMap("ObjectData", sb);
  359. LLSDxmlEncode2.AddElem("LocalID", (int)localID, sb);
  360. LLSDxmlEncode2.AddElem("Density", density, sb);
  361. LLSDxmlEncode2.AddElem("Friction", friction, sb);
  362. LLSDxmlEncode2.AddElem("GravityMultiplier", gravmod, sb);
  363. LLSDxmlEncode2.AddElem("Restitution", bounce, sb);
  364. LLSDxmlEncode2.AddElem("PhysicsShapeType", (int)physhapetype, sb);
  365. LLSDxmlEncode2.AddEndMapAndArray(sb);
  366. Enqueue(EndEventToBytes(sb), avatarID);
  367. }
  368. public void WindlightRefreshEvent(int interpolate, UUID avatarID)
  369. {
  370. osUTF8 sb = StartEvent("WindLightRefresh");
  371. LLSDxmlEncode2.AddElem("Interpolate", interpolate > 0 ? 1 : 0, sb);
  372. Enqueue(EndEventToBytes(sb), avatarID);
  373. }
  374. public static string KeepAliveEvent()
  375. {
  376. osUTF8 sb = new osUTF8(256);
  377. LLSDxmlEncode2.AddMap(sb);
  378. LLSDxmlEncode2.AddElem("message", "FAKEEVENT", sb);
  379. LLSDxmlEncode2.AddMap("body", sb);
  380. LLSDxmlEncode2.AddEndMap(sb); // close body
  381. LLSDxmlEncode2.AddEndMap(sb); // close event
  382. return sb.ToString();
  383. }
  384. public byte[] BuildEvent(string eventName, OSD eventBody)
  385. {
  386. OSDMap llsdEvent = new OSDMap(2);
  387. llsdEvent.Add("message", new OSDString(eventName));
  388. llsdEvent.Add("body", eventBody);
  389. return Util.UTF8NBGetbytes(OSDParser.SerializeLLSDInnerXmlString(llsdEvent));
  390. }
  391. }
  392. }