PageRenderTime 61ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 4ms

/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs

https://gitlab.com/N3X15/VoxelSim
C# | 11145 lines | 8985 code | 1493 blank | 667 comment | 1574 complexity | 89d15798e98f9f7dccfa0f171faba23d MD5 | raw file
Possible License(s): BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  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 System.Threading;
  34. using System.Timers;
  35. using System.Xml;
  36. using log4net;
  37. using OpenMetaverse;
  38. using OpenMetaverse.Packets;
  39. using OpenMetaverse.Messages.Linden;
  40. using OpenMetaverse.StructuredData;
  41. using OpenSim.Framework;
  42. using OpenSim.Framework.Client;
  43. using OpenSim.Framework.Statistics;
  44. using OpenSim.Region.Framework.Interfaces;
  45. using OpenSim.Region.Framework.Scenes;
  46. using OpenSim.Services.Interfaces;
  47. using Timer = System.Timers.Timer;
  48. using AssetLandmark = OpenSim.Framework.AssetLandmark;
  49. using Nini.Config;
  50. namespace OpenSim.Region.ClientStack.LindenUDP
  51. {
  52. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  53. /// <summary>
  54. /// Handles new client connections
  55. /// Constructor takes a single Packet and authenticates everything
  56. /// </summary>
  57. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector
  58. {
  59. /// <value>
  60. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  61. /// </value>
  62. protected int m_debugPacketLevel = 0;
  63. #region Events
  64. public event GenericMessage OnGenericMessage;
  65. public event BinaryGenericMessage OnBinaryGenericMessage;
  66. public event Action<IClientAPI> OnLogout;
  67. public event ObjectPermissions OnObjectPermissions;
  68. public event Action<IClientAPI> OnConnectionClosed;
  69. public event ViewerEffectEventHandler OnViewerEffect;
  70. public event ImprovedInstantMessage OnInstantMessage;
  71. public event ChatMessage OnChatFromClient;
  72. public event TextureRequest OnRequestTexture;
  73. public event RezObject OnRezObject;
  74. public event DeRezObject OnDeRezObject;
  75. public event ModifyTerrain OnModifyTerrain;
  76. public event Action<IClientAPI> OnRegionHandShakeReply;
  77. public event GenericCall1 OnRequestWearables;
  78. public event SetAppearance OnSetAppearance;
  79. public event AvatarNowWearing OnAvatarNowWearing;
  80. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  81. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  82. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  83. public event ObjectAttach OnObjectAttach;
  84. public event ObjectDeselect OnObjectDetach;
  85. public event ObjectDrop OnObjectDrop;
  86. public event GenericCall1 OnCompleteMovementToRegion;
  87. public event UpdateAgent OnPreAgentUpdate;
  88. public event UpdateAgent OnAgentUpdate;
  89. public event AgentRequestSit OnAgentRequestSit;
  90. public event AgentSit OnAgentSit;
  91. public event AvatarPickerRequest OnAvatarPickerRequest;
  92. public event StartAnim OnStartAnim;
  93. public event StopAnim OnStopAnim;
  94. public event Action<IClientAPI> OnRequestAvatarsData;
  95. public event LinkObjects OnLinkObjects;
  96. public event DelinkObjects OnDelinkObjects;
  97. public event GrabObject OnGrabObject;
  98. public event DeGrabObject OnDeGrabObject;
  99. public event SpinStart OnSpinStart;
  100. public event SpinStop OnSpinStop;
  101. public event ObjectDuplicate OnObjectDuplicate;
  102. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  103. public event MoveObject OnGrabUpdate;
  104. public event SpinObject OnSpinUpdate;
  105. public event AddNewPrim OnAddPrim;
  106. public event RequestGodlikePowers OnRequestGodlikePowers;
  107. public event GodKickUser OnGodKickUser;
  108. public event ObjectExtraParams OnUpdateExtraParams;
  109. public event UpdateShape OnUpdatePrimShape;
  110. public event ObjectRequest OnObjectRequest;
  111. public event ObjectSelect OnObjectSelect;
  112. public event ObjectDeselect OnObjectDeselect;
  113. public event GenericCall7 OnObjectDescription;
  114. public event GenericCall7 OnObjectName;
  115. public event GenericCall7 OnObjectClickAction;
  116. public event GenericCall7 OnObjectMaterial;
  117. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  118. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  119. public event UpdatePrimFlags OnUpdatePrimFlags;
  120. public event UpdatePrimTexture OnUpdatePrimTexture;
  121. public event UpdateVector OnUpdatePrimGroupPosition;
  122. public event UpdateVector OnUpdatePrimSinglePosition;
  123. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  124. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  125. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  126. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  127. public event UpdateVector OnUpdatePrimScale;
  128. public event UpdateVector OnUpdatePrimGroupScale;
  129. public event StatusChange OnChildAgentStatus;
  130. public event GenericCall2 OnStopMovement;
  131. public event Action<UUID> OnRemoveAvatar;
  132. public event RequestMapBlocks OnRequestMapBlocks;
  133. public event RequestMapName OnMapNameRequest;
  134. public event TeleportLocationRequest OnTeleportLocationRequest;
  135. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  136. public event DisconnectUser OnDisconnectUser;
  137. public event RequestAvatarProperties OnRequestAvatarProperties;
  138. public event SetAlwaysRun OnSetAlwaysRun;
  139. public event FetchInventory OnAgentDataUpdateRequest;
  140. public event TeleportLocationRequest OnSetStartLocationRequest;
  141. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  142. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  143. public event LinkInventoryItem OnLinkInventoryItem;
  144. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  145. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  146. public event MoveInventoryFolder OnMoveInventoryFolder;
  147. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  148. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  149. public event FetchInventory OnFetchInventory;
  150. public event RequestTaskInventory OnRequestTaskInventory;
  151. public event UpdateInventoryItem OnUpdateInventoryItem;
  152. public event CopyInventoryItem OnCopyInventoryItem;
  153. public event MoveInventoryItem OnMoveInventoryItem;
  154. public event RemoveInventoryItem OnRemoveInventoryItem;
  155. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  156. public event UDPAssetUploadRequest OnAssetUploadRequest;
  157. public event XferReceive OnXferReceive;
  158. public event RequestXfer OnRequestXfer;
  159. public event ConfirmXfer OnConfirmXfer;
  160. public event AbortXfer OnAbortXfer;
  161. public event RequestTerrain OnRequestTerrain;
  162. public event RezScript OnRezScript;
  163. public event UpdateTaskInventory OnUpdateTaskInventory;
  164. public event MoveTaskInventory OnMoveTaskItem;
  165. public event RemoveTaskInventory OnRemoveTaskItem;
  166. public event RequestAsset OnRequestAsset;
  167. public event UUIDNameRequest OnNameFromUUIDRequest;
  168. public event ParcelAccessListRequest OnParcelAccessListRequest;
  169. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  170. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  171. public event ParcelDivideRequest OnParcelDivideRequest;
  172. public event ParcelJoinRequest OnParcelJoinRequest;
  173. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  174. public event ParcelSelectObjects OnParcelSelectObjects;
  175. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  176. public event ParcelAbandonRequest OnParcelAbandonRequest;
  177. public event ParcelGodForceOwner OnParcelGodForceOwner;
  178. public event ParcelReclaim OnParcelReclaim;
  179. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  180. public event ParcelDeedToGroup OnParcelDeedToGroup;
  181. public event RegionInfoRequest OnRegionInfoRequest;
  182. public event EstateCovenantRequest OnEstateCovenantRequest;
  183. public event FriendActionDelegate OnApproveFriendRequest;
  184. public event FriendActionDelegate OnDenyFriendRequest;
  185. public event FriendshipTermination OnTerminateFriendship;
  186. public event GrantUserFriendRights OnGrantUserRights;
  187. public event MoneyTransferRequest OnMoneyTransferRequest;
  188. public event EconomyDataRequest OnEconomyDataRequest;
  189. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  190. public event ParcelBuy OnParcelBuy;
  191. public event UUIDNameRequest OnTeleportHomeRequest;
  192. public event UUIDNameRequest OnUUIDGroupNameRequest;
  193. public event ScriptAnswer OnScriptAnswer;
  194. public event RequestPayPrice OnRequestPayPrice;
  195. public event ObjectSaleInfo OnObjectSaleInfo;
  196. public event ObjectBuy OnObjectBuy;
  197. public event BuyObjectInventory OnBuyObjectInventory;
  198. public event AgentSit OnUndo;
  199. public event AgentSit OnRedo;
  200. public event LandUndo OnLandUndo;
  201. public event ForceReleaseControls OnForceReleaseControls;
  202. public event GodLandStatRequest OnLandStatRequest;
  203. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  204. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  205. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  206. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  207. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  208. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  209. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  210. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  211. public event BakeTerrain OnBakeTerrain;
  212. public event RequestTerrain OnUploadTerrain;
  213. public event EstateChangeInfo OnEstateChangeInfo;
  214. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  215. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  216. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  217. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  218. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  219. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  220. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  221. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  222. public event RegionHandleRequest OnRegionHandleRequest;
  223. public event ParcelInfoRequest OnParcelInfoRequest;
  224. public event ScriptReset OnScriptReset;
  225. public event GetScriptRunning OnGetScriptRunning;
  226. public event SetScriptRunning OnSetScriptRunning;
  227. public event UpdateVector OnAutoPilotGo;
  228. public event TerrainUnacked OnUnackedTerrain;
  229. public event ActivateGesture OnActivateGesture;
  230. public event DeactivateGesture OnDeactivateGesture;
  231. public event ObjectOwner OnObjectOwner;
  232. public event DirPlacesQuery OnDirPlacesQuery;
  233. public event DirFindQuery OnDirFindQuery;
  234. public event DirLandQuery OnDirLandQuery;
  235. public event DirPopularQuery OnDirPopularQuery;
  236. public event DirClassifiedQuery OnDirClassifiedQuery;
  237. public event EventInfoRequest OnEventInfoRequest;
  238. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  239. public event MapItemRequest OnMapItemRequest;
  240. public event OfferCallingCard OnOfferCallingCard;
  241. public event AcceptCallingCard OnAcceptCallingCard;
  242. public event DeclineCallingCard OnDeclineCallingCard;
  243. public event SoundTrigger OnSoundTrigger;
  244. public event StartLure OnStartLure;
  245. public event TeleportLureRequest OnTeleportLureRequest;
  246. public event NetworkStats OnNetworkStatsUpdate;
  247. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  248. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  249. public event ClassifiedDelete OnClassifiedDelete;
  250. public event ClassifiedDelete OnClassifiedGodDelete;
  251. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  252. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  253. public event EventGodDelete OnEventGodDelete;
  254. public event ParcelDwellRequest OnParcelDwellRequest;
  255. public event UserInfoRequest OnUserInfoRequest;
  256. public event UpdateUserInfo OnUpdateUserInfo;
  257. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  258. public event PickDelete OnPickDelete;
  259. public event PickGodDelete OnPickGodDelete;
  260. public event PickInfoUpdate OnPickInfoUpdate;
  261. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  262. public event MuteListRequest OnMuteListRequest;
  263. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  264. public event PlacesQuery OnPlacesQuery;
  265. public event AgentFOV OnAgentFOV;
  266. public event FindAgentUpdate OnFindAgent;
  267. public event TrackAgentUpdate OnTrackAgent;
  268. public event NewUserReport OnUserReport;
  269. public event SaveStateHandler OnSaveState;
  270. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  271. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  272. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  273. public event FreezeUserUpdate OnParcelFreezeUser;
  274. public event EjectUserUpdate OnParcelEjectUser;
  275. public event ParcelBuyPass OnParcelBuyPass;
  276. public event ParcelGodMark OnParcelGodMark;
  277. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  278. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  279. public event SimWideDeletesDelegate OnSimWideDeletes;
  280. public event SendPostcard OnSendPostcard;
  281. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  282. public event MuteListEntryRemove OnRemoveMuteListEntry;
  283. public event GodlikeMessage onGodlikeMessage;
  284. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  285. #endregion Events
  286. #region Class Members
  287. // LLClientView Only
  288. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  289. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  290. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  291. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  292. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  293. private readonly LLUDPServer m_udpServer;
  294. private readonly LLUDPClient m_udpClient;
  295. private readonly UUID m_sessionId;
  296. private readonly UUID m_secureSessionId;
  297. protected readonly UUID m_agentId;
  298. private readonly uint m_circuitCode;
  299. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  300. private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
  301. private readonly IGroupsModule m_GroupsModule;
  302. private int m_cachedTextureSerial;
  303. private PriorityQueue m_entityUpdates;
  304. private Prioritizer m_prioritizer;
  305. private bool m_disableFacelights = false;
  306. /// <value>
  307. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  308. /// continually recreate it.
  309. /// </value>
  310. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  311. /// <value>
  312. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  313. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  314. /// ownerless phantom.
  315. ///
  316. /// All manipulation of this set has to occur under an m_entityUpdates.SyncRoot lock
  317. ///
  318. /// </value>
  319. protected HashSet<uint> m_killRecord;
  320. // protected HashSet<uint> m_attachmentsSent;
  321. private int m_moneyBalance;
  322. private int m_animationSequenceNumber = 1;
  323. private bool m_SendLogoutPacketWhenClosing = true;
  324. private AgentUpdateArgs lastarg;
  325. private bool m_IsActive = true;
  326. private bool m_IsLoggingOut = false;
  327. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  328. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  329. protected Scene m_scene;
  330. protected LLImageManager m_imageManager;
  331. protected string m_firstName;
  332. protected string m_lastName;
  333. protected Thread m_clientThread;
  334. protected Vector3 m_startpos;
  335. protected EndPoint m_userEndPoint;
  336. protected UUID m_activeGroupID;
  337. protected string m_activeGroupName = String.Empty;
  338. protected ulong m_activeGroupPowers;
  339. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  340. protected int m_terrainCheckerCount;
  341. protected uint m_agentFOVCounter;
  342. protected IAssetService m_assetService;
  343. private const bool m_checkPackets = true;
  344. private Timer m_propertiesPacketTimer;
  345. private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>();
  346. #endregion Class Members
  347. #region Properties
  348. public LLUDPClient UDPClient { get { return m_udpClient; } }
  349. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  350. public UUID SecureSessionId { get { return m_secureSessionId; } }
  351. public IScene Scene { get { return m_scene; } }
  352. public UUID SessionId { get { return m_sessionId; } }
  353. public Vector3 StartPos
  354. {
  355. get { return m_startpos; }
  356. set { m_startpos = value; }
  357. }
  358. public UUID AgentId { get { return m_agentId; } }
  359. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  360. public string ActiveGroupName { get { return m_activeGroupName; } }
  361. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  362. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  363. /// <summary>
  364. /// First name of the agent/avatar represented by the client
  365. /// </summary>
  366. public string FirstName { get { return m_firstName; } }
  367. /// <summary>
  368. /// Last name of the agent/avatar represented by the client
  369. /// </summary>
  370. public string LastName { get { return m_lastName; } }
  371. /// <summary>
  372. /// Full name of the client (first name and last name)
  373. /// </summary>
  374. public string Name { get { return FirstName + " " + LastName; } }
  375. public uint CircuitCode { get { return m_circuitCode; } }
  376. public int MoneyBalance { get { return m_moneyBalance; } }
  377. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  378. public bool IsActive
  379. {
  380. get { return m_IsActive; }
  381. set { m_IsActive = value; }
  382. }
  383. public bool IsLoggingOut
  384. {
  385. get { return m_IsLoggingOut; }
  386. set { m_IsLoggingOut = value; }
  387. }
  388. public bool DisableFacelights
  389. {
  390. get { return m_disableFacelights; }
  391. set { m_disableFacelights = value; }
  392. }
  393. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  394. #endregion Properties
  395. /// <summary>
  396. /// Constructor
  397. /// </summary>
  398. public LLClientView(EndPoint remoteEP, Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  399. UUID agentId, UUID sessionId, uint circuitCode)
  400. {
  401. RegisterInterface<IClientIM>(this);
  402. RegisterInterface<IClientChat>(this);
  403. RegisterInterface<IClientIPEndpoint>(this);
  404. InitDefaultAnimations();
  405. m_scene = scene;
  406. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  407. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  408. m_killRecord = new HashSet<uint>();
  409. // m_attachmentsSent = new HashSet<uint>();
  410. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  411. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  412. m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  413. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  414. m_agentId = agentId;
  415. m_sessionId = sessionId;
  416. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  417. m_circuitCode = circuitCode;
  418. m_userEndPoint = remoteEP;
  419. m_firstName = sessionInfo.LoginInfo.First;
  420. m_lastName = sessionInfo.LoginInfo.Last;
  421. m_startpos = sessionInfo.LoginInfo.StartPos;
  422. m_moneyBalance = 1000;
  423. m_udpServer = udpServer;
  424. m_udpClient = udpClient;
  425. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  426. m_udpClient.OnPacketStats += PopulateStats;
  427. m_propertiesPacketTimer = new Timer(100);
  428. m_propertiesPacketTimer.Elapsed += ProcessObjectPropertiesPacket;
  429. m_prioritizer = new Prioritizer(m_scene);
  430. RegisterLocalPacketHandlers();
  431. }
  432. public void SetDebugPacketLevel(int newDebug)
  433. {
  434. m_debugPacketLevel = newDebug;
  435. }
  436. #region Client Methods
  437. /// <summary>
  438. /// Shut down the client view
  439. /// </summary>
  440. public void Close()
  441. {
  442. m_log.DebugFormat(
  443. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  444. Name, m_scene.RegionInfo.RegionName);
  445. // Send the STOP packet
  446. DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
  447. OutPacket(disable, ThrottleOutPacketType.Unknown);
  448. IsActive = false;
  449. // Shutdown the image manager
  450. if (m_imageManager != null)
  451. m_imageManager.Close();
  452. // Fire the callback for this connection closing
  453. if (OnConnectionClosed != null)
  454. OnConnectionClosed(this);
  455. // Flush all of the packets out of the UDP server for this client
  456. if (m_udpServer != null)
  457. m_udpServer.Flush(m_udpClient);
  458. // Remove ourselves from the scene
  459. m_scene.RemoveClient(AgentId);
  460. // We can't reach into other scenes and close the connection
  461. // We need to do this over grid communications
  462. //m_scene.CloseAllAgents(CircuitCode);
  463. // Disable UDP handling for this client
  464. m_udpClient.Shutdown();
  465. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  466. //GC.Collect();
  467. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  468. }
  469. public void Kick(string message)
  470. {
  471. if (!ChildAgentStatus())
  472. {
  473. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  474. kupack.UserInfo.AgentID = AgentId;
  475. kupack.UserInfo.SessionID = SessionId;
  476. kupack.TargetBlock.TargetIP = 0;
  477. kupack.TargetBlock.TargetPort = 0;
  478. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  479. OutPacket(kupack, ThrottleOutPacketType.Task);
  480. // You must sleep here or users get no message!
  481. Thread.Sleep(500);
  482. }
  483. }
  484. public void Stop()
  485. {
  486. }
  487. #endregion Client Methods
  488. #region Packet Handling
  489. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  490. {
  491. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  492. if (handlerNetworkStatsUpdate != null)
  493. {
  494. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  495. }
  496. }
  497. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  498. {
  499. bool result = false;
  500. lock (PacketHandlers)
  501. {
  502. if (!PacketHandlers.ContainsKey(packetType))
  503. {
  504. PacketHandlers.Add(packetType, handler);
  505. result = true;
  506. }
  507. }
  508. return result;
  509. }
  510. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  511. {
  512. return AddLocalPacketHandler(packetType, handler, true);
  513. }
  514. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool async)
  515. {
  516. bool result = false;
  517. lock (m_packetHandlers)
  518. {
  519. if (!m_packetHandlers.ContainsKey(packetType))
  520. {
  521. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = async });
  522. result = true;
  523. }
  524. }
  525. return result;
  526. }
  527. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  528. {
  529. MethodName = MethodName.ToLower().Trim();
  530. bool result = false;
  531. lock (m_genericPacketHandlers)
  532. {
  533. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  534. {
  535. m_genericPacketHandlers.Add(MethodName, handler);
  536. result = true;
  537. }
  538. }
  539. return result;
  540. }
  541. /// <summary>
  542. /// Try to process a packet using registered packet handlers
  543. /// </summary>
  544. /// <param name="packet"></param>
  545. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  546. protected virtual bool ProcessPacketMethod(Packet packet)
  547. {
  548. bool result = false;
  549. PacketProcessor pprocessor;
  550. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  551. {
  552. //there is a local handler for this packet type
  553. if (pprocessor.Async)
  554. {
  555. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  556. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  557. result = true;
  558. }
  559. else
  560. {
  561. result = pprocessor.method(this, packet);
  562. }
  563. }
  564. else
  565. {
  566. //there is not a local handler so see if there is a Global handler
  567. PacketMethod method = null;
  568. bool found;
  569. lock (PacketHandlers)
  570. {
  571. found = PacketHandlers.TryGetValue(packet.Type, out method);
  572. }
  573. if (found)
  574. {
  575. result = method(this, packet);
  576. }
  577. }
  578. return result;
  579. }
  580. public void ProcessSpecificPacketAsync(object state)
  581. {
  582. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  583. try
  584. {
  585. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  586. }
  587. catch (Exception e)
  588. {
  589. // Make sure that we see any exception caused by the asynchronous operation.
  590. m_log.Error(
  591. string.Format("[LLCLIENTVIEW]: Caught exception while processing {0}", packetObject.Pack), e);
  592. }
  593. }
  594. #endregion Packet Handling
  595. # region Setup
  596. public virtual void Start()
  597. {
  598. m_scene.AddNewClient(this);
  599. RefreshGroupMembership();
  600. }
  601. # endregion
  602. public void ActivateGesture(UUID assetId, UUID gestureId)
  603. {
  604. }
  605. public void DeactivateGesture(UUID assetId, UUID gestureId)
  606. {
  607. }
  608. // Sound
  609. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  610. {
  611. }
  612. #region Scene/Avatar to Client
  613. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  614. {
  615. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  616. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  617. handshake.RegionInfo.BillableFactor = args.billableFactor;
  618. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  619. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  620. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  621. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  622. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  623. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  624. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  625. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  626. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  627. handshake.RegionInfo.SimAccess = args.simAccess;
  628. handshake.RegionInfo.WaterHeight = args.waterHeight;
  629. handshake.RegionInfo.RegionFlags = args.regionFlags;
  630. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  631. handshake.RegionInfo.SimOwner = args.SimOwner;
  632. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  633. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  634. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  635. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  636. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  637. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  638. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  639. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  640. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  641. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  642. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  643. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  644. handshake.RegionInfo3.CPUClassID = 9;
  645. handshake.RegionInfo3.CPURatio = 1;
  646. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  647. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  648. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  649. OutPacket(handshake, ThrottleOutPacketType.Task);
  650. }
  651. /// <summary>
  652. ///
  653. /// </summary>
  654. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  655. {
  656. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  657. mov.SimData.ChannelVersion = m_channelVersion;
  658. mov.AgentData.SessionID = m_sessionId;
  659. mov.AgentData.AgentID = AgentId;
  660. mov.Data.RegionHandle = regInfo.RegionHandle;
  661. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  662. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  663. {
  664. mov.Data.Position = m_startpos;
  665. }
  666. else
  667. {
  668. mov.Data.Position = pos;
  669. }
  670. mov.Data.LookAt = look;
  671. // Hack to get this out immediately and skip the throttles
  672. OutPacket(mov, ThrottleOutPacketType.Unknown);
  673. }
  674. public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
  675. UUID fromAgentID, byte source, byte audible)
  676. {
  677. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  678. reply.ChatData.Audible = audible;
  679. reply.ChatData.Message = Util.StringToBytes1024(message);
  680. reply.ChatData.ChatType = type;
  681. reply.ChatData.SourceType = source;
  682. reply.ChatData.Position = fromPos;
  683. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  684. reply.ChatData.OwnerID = fromAgentID;
  685. reply.ChatData.SourceID = fromAgentID;
  686. OutPacket(reply, ThrottleOutPacketType.Task);
  687. }
  688. /// <summary>
  689. /// Send an instant message to this client
  690. /// </summary>
  691. //
  692. // Don't remove transaction ID! Groups and item gives need to set it!
  693. public void SendInstantMessage(GridInstantMessage im)
  694. {
  695. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  696. {
  697. ImprovedInstantMessagePacket msg
  698. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  699. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  700. msg.AgentData.SessionID = UUID.Zero;
  701. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  702. msg.MessageBlock.Dialog = im.dialog;
  703. msg.MessageBlock.FromGroup = im.fromGroup;
  704. if (im.imSessionID == UUID.Zero.Guid)
  705. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  706. else
  707. msg.MessageBlock.ID = new UUID(im.imSessionID);
  708. msg.MessageBlock.Offline = im.offline;
  709. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  710. msg.MessageBlock.Position = im.Position;
  711. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  712. msg.MessageBlock.Timestamp = im.timestamp;
  713. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  714. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  715. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  716. if (im.message.StartsWith("[grouptest]"))
  717. { // this block is test code for implementing group IM - delete when group IM is finished
  718. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  719. if (eq != null)
  720. {
  721. im.dialog = 17;
  722. //eq.ChatterboxInvitation(
  723. // new UUID("00000000-68f9-1111-024e-222222111123"),
  724. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  725. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  726. eq.ChatterboxInvitation(
  727. new UUID("00000000-68f9-1111-024e-222222111123"),
  728. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  729. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  730. eq.ChatterBoxSessionAgentListUpdates(
  731. new UUID("00000000-68f9-1111-024e-222222111123"),
  732. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  733. }
  734. Console.WriteLine("SendInstantMessage: " + msg);
  735. }
  736. else
  737. OutPacket(msg, ThrottleOutPacketType.Task);
  738. }
  739. }
  740. public void SendGenericMessage(string method, List<string> message)
  741. {
  742. GenericMessagePacket gmp = new GenericMessagePacket();
  743. gmp.MethodData.Method = Util.StringToBytes256(method);
  744. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  745. int i = 0;
  746. foreach (string val in message)
  747. {
  748. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  749. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  750. }
  751. OutPacket(gmp, ThrottleOutPacketType.Task);
  752. }
  753. public void SendGenericMessage(string method, List<byte[]> message)
  754. {
  755. GenericMessagePacket gmp = new GenericMessagePacket();
  756. gmp.MethodData.Method = Util.StringToBytes256(method);
  757. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  758. int i = 0;
  759. foreach (byte[] val in message)
  760. {
  761. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  762. gmp.ParamList[i++].Parameter = val;
  763. }
  764. OutPacket(gmp, ThrottleOutPacketType.Task);
  765. }
  766. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  767. {
  768. int i = 0;
  769. foreach (GroupActiveProposals Proposal in Proposals)
  770. {
  771. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  772. GAPIRP.AgentData.AgentID = AgentId;
  773. GAPIRP.AgentData.GroupID = groupID;
  774. GAPIRP.TransactionData.TransactionID = transactionID;
  775. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  776. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  777. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  778. ProposalData.VoteCast = Utils.StringToBytes("false");
  779. ProposalData.VoteID = new UUID(Proposal.VoteID);
  780. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  781. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  782. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  783. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  784. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  785. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  786. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  787. ProposalData.AlreadyVoted = false;
  788. GAPIRP.ProposalData[i] = ProposalData;
  789. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  790. i++;
  791. }
  792. if (Proposals.Length == 0)
  793. {
  794. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  795. GAPIRP.AgentData.AgentID = AgentId;
  796. GAPIRP.AgentData.GroupID = groupID;
  797. GAPIRP.TransactionData.TransactionID = transactionID;
  798. GAPIRP.TransactionData.TotalNumItems = 1;
  799. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  800. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  801. ProposalData.VoteCast = Utils.StringToBytes("false");
  802. ProposalData.VoteID = UUID.Zero;
  803. ProposalData.VoteInitiator = UUID.Zero;
  804. ProposalData.Majority = 0;
  805. ProposalData.Quorum = 0;
  806. ProposalData.TerseDateID = Utils.StringToBytes("");
  807. ProposalData.StartDateTime = Utils.StringToBytes("");
  808. ProposalData.EndDateTime = Utils.StringToBytes("");
  809. ProposalData.ProposalText = Utils.StringToBytes("");
  810. ProposalData.AlreadyVoted = false;
  811. GAPIRP.ProposalData[0] = ProposalData;
  812. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  813. }
  814. }
  815. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  816. {
  817. int i = 0;
  818. foreach (GroupVoteHistory Vote in Votes)
  819. {
  820. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  821. GVHIRP.AgentData.AgentID = AgentId;
  822. GVHIRP.AgentData.GroupID = groupID;
  823. GVHIRP.TransactionData.TransactionID = transactionID;
  824. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  825. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  826. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  827. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  828. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  829. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  830. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  831. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  832. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  833. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  834. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  835. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  836. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  837. VoteItem.CandidateID = UUID.Zero;
  838. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  839. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  840. GVHIRP.VoteItem[i] = VoteItem;
  841. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  842. i++;
  843. }
  844. if (Votes.Length == 0)
  845. {
  846. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  847. GVHIRP.AgentData.AgentID = AgentId;
  848. GVHIRP.AgentData.GroupID = groupID;
  849. GVHIRP.TransactionData.TransactionID = transactionID;
  850. GVHIRP.TransactionData.TotalNumItems = 0;
  851. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  852. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  853. GVHIRP.HistoryItemData.Majority = 0;
  854. GVHIRP.HistoryItemData.Quorum = 0;
  855. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  856. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  857. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  858. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  859. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  860. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  861. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  862. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  863. VoteItem.CandidateID = UUID.Zero;
  864. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  865. VoteItem.VoteCast = Utils.StringToBytes("No");
  866. GVHIRP.VoteItem[0] = VoteItem;
  867. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  868. }
  869. }
  870. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  871. {
  872. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  873. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  874. GADRP.AgentData.AgentID = sender.AgentId;
  875. GADRP.AgentData.GroupID = groupID;
  876. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  877. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  878. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  879. GADRP.MoneyData.CurrentInterval = 0;
  880. GADRP.MoneyData.IntervalDays = 7;
  881. GADRP.MoneyData.RequestID = transactionID;
  882. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  883. History.Amount = amt;
  884. History.Description = Utils.StringToBytes("");
  885. GADRP.HistoryData[0] = History;
  886. OutPacket(GADRP, ThrottleOutPacketType.Task);
  887. }
  888. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  889. {
  890. GroupAccountSummaryReplyPacket GASRP =
  891. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  892. PacketType.GroupAccountSummaryReply);
  893. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  894. GASRP.AgentData.AgentID = sender.AgentId;
  895. GASRP.AgentData.GroupID = groupID;
  896. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  897. GASRP.MoneyData.Balance = (int)moneyAmt;
  898. GASRP.MoneyData.TotalCredits = totalTier;
  899. GASRP.MoneyData.TotalDebits = usedTier;
  900. GASRP.MoneyData.StartDate = new byte[1];
  901. GASRP.MoneyData.CurrentInterval = 1;
  902. GASRP.MoneyData.GroupTaxCurrent = 0;
  903. GASRP.MoneyData.GroupTaxEstimate = 0;
  904. GASRP.MoneyData.IntervalDays = 0;
  905. GASRP.MoneyData.LandTaxCurrent = 0;
  906. GASRP.MoneyData.LandTaxEstimate = 0;
  907. GASRP.MoneyData.LastTaxDate = new byte[1];
  908. GASRP.MoneyData.LightTaxCurrent = 0;
  909. GASRP.MoneyData.TaxDate = new byte[1];
  910. GASRP.MoneyData.RequestID = sender.AgentId;
  911. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  912. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  913. GASRP.MoneyData.ObjectTaxEstimate = 0;
  914. GASRP.MoneyData.NonExemptMembers = 0;
  915. GASRP.MoneyData.ObjectTaxCurrent = 0;
  916. GASRP.MoneyData.LightTaxEstimate = 0;
  917. OutPacket(GASRP, ThrottleOutPacketType.Task);
  918. }
  919. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  920. {
  921. GroupAccountTransactionsReplyPacket GATRP =
  922. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  923. PacketType.GroupAccountTransactionsReply);
  924. GATRP.AgentData = new GroupAccou

Large files files are truncated, but you can click here to view the full file