From 429a84f390212d0f414a08420707fc90aca2a331 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 5 Oct 2009 17:38:14 -0700 Subject: [PATCH] Beginning work on the new LLUDP implementation --- OpenSim/Framework/ThrottleOutPacketType.cs | 8 +- OpenSim/Region/Application/OpenSimBase.cs | 2 +- .../ClientStack/IClientNetworkServer.cs | 2 +- .../LindenUDP/ILLClientStackNetworkHandler.cs | 38 - .../ClientStack/LindenUDP/ILLPacketHandler.cs | 83 - .../Region/ClientStack/LindenUDP/J2KImage.cs | 6 +- .../ClientStack/LindenUDP/LLClientView.cs | 2993 +++++++---------- .../ClientStack/LindenUDP/LLImageManager.cs | 2 +- .../ClientStack/LindenUDP/LLPacketHandler.cs | 7 +- .../ClientStack/LindenUDP/LLPacketServer.cs | 4 +- .../ClientStack/LindenUDP/LLUDPServer.cs | 1143 ++++--- .../Region/ClientStack/LindenUDP/LLUtil.cs | 5 + .../LindenUDP/Tests/PacketHandlerTests.cs | 2 +- .../LindenUDP/Tests/TestLLPacketServer.cs | 2 +- 14 files changed, 1889 insertions(+), 2408 deletions(-) delete mode 100644 OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs delete mode 100644 OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs diff --git a/OpenSim/Framework/ThrottleOutPacketType.cs b/OpenSim/Framework/ThrottleOutPacketType.cs index 08437577a8..fd490a5c6a 100644 --- a/OpenSim/Framework/ThrottleOutPacketType.cs +++ b/OpenSim/Framework/ThrottleOutPacketType.cs @@ -29,9 +29,9 @@ using System; namespace OpenSim.Framework { - [Flags] public enum ThrottleOutPacketType : int { + Unknown = -1, // Also doubles as 'do not throttle' Resend = 0, Land = 1, Wind = 2, @@ -39,11 +39,5 @@ namespace OpenSim.Framework Task = 4, Texture = 5, Asset = 6, - Unknown = 7, // Also doubles as 'do not throttle' - Back = 8, - - TypeMask = 15, // The mask to mask off the flags - - LowPriority = 128 // Additional flags } } diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 6e7a2a0a5e..4592c318b5 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -675,7 +675,7 @@ namespace OpenSim if (foundClientServer) { - m_clientServers[clientServerElement].Server.Close(); + m_clientServers[clientServerElement].NetworkStop(); m_clientServers.RemoveAt(clientServerElement); } IScene scene; diff --git a/OpenSim/Region/ClientStack/IClientNetworkServer.cs b/OpenSim/Region/ClientStack/IClientNetworkServer.cs index a71ad4d46e..54a441bbe6 100644 --- a/OpenSim/Region/ClientStack/IClientNetworkServer.cs +++ b/OpenSim/Region/ClientStack/IClientNetworkServer.cs @@ -38,7 +38,7 @@ namespace OpenSim.Region.ClientStack IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager authenticateClass); - Socket Server { get; } + void NetworkStop(); bool HandlesRegion(Location x); void AddScene(IScene x); diff --git a/OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs deleted file mode 100644 index ee151718ba..0000000000 --- a/OpenSim/Region/ClientStack/LindenUDP/ILLClientStackNetworkHandler.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Net.Sockets; - -namespace OpenSim.Region.ClientStack.LindenUDP -{ - public interface ILLClientStackNetworkHandler - { - void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode); // EndPoint packetSender); - void RemoveClientCircuit(uint circuitcode); - void RegisterPacketServer(LLPacketServer server); - } -} diff --git a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs deleted file mode 100644 index 31f9580a88..0000000000 --- a/OpenSim/Region/ClientStack/LindenUDP/ILLPacketHandler.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using OpenMetaverse; -using OpenMetaverse.Packets; -using OpenSim.Framework; - -namespace OpenSim.Region.ClientStack.LindenUDP -{ - public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); - public delegate void PacketDrop(Packet pack, Object id); - public delegate void QueueEmpty(ThrottleOutPacketType queue); - public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); - - /// - /// Interface to a class that handles all the activity involved with maintaining the client circuit (handling acks, - /// resends, pings, etc.) - /// - public interface ILLPacketHandler : IDisposable - { - event PacketStats OnPacketStats; - event PacketDrop OnPacketDrop; - event QueueEmpty OnQueueEmpty; - SynchronizeClientHandler SynchronizeClient { set; } - - int PacketsReceived { get; } - int PacketsReceivedReported { get; } - uint ResendTimeout { get; set; } - bool ReliableIsImportant { get; set; } - int MaxReliableResends { get; set; } - - /// - /// Initial handling of a received packet. It will be processed later in ProcessInPacket() - /// - /// - void InPacket(Packet packet); - - /// - /// Take action depending on the type and contents of an received packet. - /// - /// - void ProcessInPacket(LLQueItem item); - - void ProcessOutPacket(LLQueItem item); - void OutPacket(Packet NewPack, - ThrottleOutPacketType throttlePacketType); - void OutPacket(Packet NewPack, - ThrottleOutPacketType throttlePacketType, Object id); - LLPacketQueue PacketQueue { get; } - void Flush(); - void Clear(); - ClientInfo GetClientInfo(); - void SetClientInfo(ClientInfo info); - void AddImportantPacket(PacketType type); - void RemoveImportantPacket(PacketType type); - int GetQueueCount(ThrottleOutPacketType queue); - } -} diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 19ad0b497f..000f455c3f 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs @@ -197,12 +197,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_currentPacket = StartPacket; } - if ((m_imageManager != null) && (m_imageManager.Client != null) && (m_imageManager.Client.PacketHandler != null)) - if (m_imageManager.Client.PacketHandler.GetQueueCount(ThrottleOutPacketType.Texture) == 0) + if (m_imageManager != null && m_imageManager.Client != null) + { + if (m_imageManager.Client.IsThrottleEmpty(ThrottleOutPacketType.Texture)) { //m_log.Debug("No textures queued, sending one packet to kickstart it"); SendPacket(m_imageManager.Client); } + } } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 00527290ad..31cd53ff06 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -58,442 +58,120 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + // LLClientView Only + public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args); - /* static variables */ - public static SynchronizeClientHandler SynchronizeClient; - /* private variables */ + /// Used to adjust Sun Orbit values so Linden based viewers properly position sun + private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; + + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected static Dictionary PacketHandlers = new Dictionary(); //Global/static handlers for all clients + + private readonly LLUDPServer m_udpServer; + private readonly LLUDPClient m_udpClient; private readonly UUID m_sessionId; private readonly UUID m_secureSessionId = UUID.Zero; + private readonly UUID m_agentId; + private readonly uint m_circuitCode; + private readonly byte[] m_channelVersion = Utils.StringToBytes("OpenSimulator Server"); // Dummy value needed by libSL + private readonly Dictionary m_defaultAnimations = new Dictionary(); + private readonly IGroupsModule m_GroupsModule; private int m_debugPacketLevel; - - //private readonly IAssetCache m_assetCache; private int m_cachedTextureSerial; private Timer m_clientPingTimer; - private Timer m_avatarTerseUpdateTimer; private List m_avatarTerseUpdates = new List(); - private Timer m_primTerseUpdateTimer; private List m_primTerseUpdates = new List(); private Timer m_primFullUpdateTimer; - private List m_primFullUpdates = - new List(); - + private List m_primFullUpdates = new List(); private bool m_clientBlocked; - private int m_probesWithNoIngressPackets; - - private readonly UUID m_agentId; - private readonly uint m_circuitCode; private int m_moneyBalance; - private readonly ILLPacketHandler m_PacketHandler; - private int m_animationSequenceNumber = 1; - - private readonly byte[] m_channelVersion = Utils.StringToBytes("OpenSimulator Server"); // Dummy value needed by libSL - - private readonly Dictionary m_defaultAnimations = new Dictionary(); - private bool m_SendLogoutPacketWhenClosing = true; - private int m_inPacketsChecked; - - // Used to adjust Sun Orbit values so Linden based viewers properly position sun - private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f; - - - /* protected variables */ - - protected static Dictionary PacketHandlers = - new Dictionary(); //Global/static handlers for all clients + private AgentUpdateArgs lastarg; + private bool m_IsActive = true; protected Dictionary m_packetHandlers = new Dictionary(); protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers - protected IScene m_scene; - - protected LLPacketServer m_networkServer; - protected LLImageManager m_imageManager; - - /* public variables */ protected string m_firstName; protected string m_lastName; protected Thread m_clientThread; protected Vector3 m_startpos; protected EndPoint m_userEndPoint; - protected EndPoint m_proxyEndPoint; protected UUID m_activeGroupID = UUID.Zero; protected string m_activeGroupName = String.Empty; protected ulong m_activeGroupPowers; protected Dictionary m_groupPowers = new Dictionary(); - protected int m_avatarTerseUpdateRate = 50; - protected int m_avatarTerseUpdatesPerPacket = 5; + protected int m_terrainCheckerCount; - // LL uses these limits, apparently. Compressed terse would be - // 23, but we don't have that yet - // + // LL uses these limits, apparently. Compressed terse would be 23, but we don't have that yet protected int m_primTerseUpdatesPerPacket = 10; protected int m_primFullUpdatesPerPacket = 14; - protected int m_primTerseUpdateRate = 10; protected int m_primFullUpdateRate = 14; - protected int m_textureSendLimit = 20; protected int m_textureDataLimit = 10; - + protected int m_avatarTerseUpdateRate = 50; + protected int m_avatarTerseUpdatesPerPacket = 5; protected int m_packetMTU = 1400; - protected IAssetService m_assetService; - // LLClientView Only - public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args); - - /* Instantiated Designated Event Delegates */ - //- used so we don't create new objects for each incoming packet and then toss it out later */ - - private GenericMessage handlerGenericMessage; - private RequestAvatarProperties handlerRequestAvatarProperties; //OnRequestAvatarProperties; - private UpdateAvatarProperties handlerUpdateAvatarProperties; // OnUpdateAvatarProperties; - private ChatMessage handlerChatFromClient; //OnChatFromClient; - private ChatMessage handlerChatFromClient2; //OnChatFromClient; - private ImprovedInstantMessage handlerInstantMessage; //OnInstantMessage; - private FriendActionDelegate handlerApproveFriendRequest; //OnApproveFriendRequest; - private FriendshipTermination handlerTerminateFriendship; //OnTerminateFriendship; - private RezObject handlerRezObject; //OnRezObject; - private DeRezObject handlerDeRezObject; //OnDeRezObject; - private ModifyTerrain handlerModifyTerrain; - private BakeTerrain handlerBakeTerrain; - private EstateChangeInfo handlerEstateChangeInfo; - private Action handlerRegionHandShakeReply; //OnRegionHandShakeReply; - private GenericCall2 handlerRequestWearables; //OnRequestWearables; - private Action handlerRequestAvatarsData; //OnRequestAvatarsData; - private SetAppearance handlerSetAppearance; //OnSetAppearance; - private AvatarNowWearing handlerAvatarNowWearing; //OnAvatarNowWearing; - private RezSingleAttachmentFromInv handlerRezSingleAttachment; //OnRezSingleAttachmentFromInv; - private RezMultipleAttachmentsFromInv handlerRezMultipleAttachments; //OnRezMultipleAttachmentsFromInv; - private UUIDNameRequest handlerDetachAttachmentIntoInv; // Detach attachment! - private ObjectAttach handlerObjectAttach; //OnObjectAttach; - private SetAlwaysRun handlerSetAlwaysRun; //OnSetAlwaysRun; - private GenericCall2 handlerCompleteMovementToRegion; //OnCompleteMovementToRegion; - private UpdateAgent handlerAgentUpdate; //OnAgentUpdate; - private StartAnim handlerStartAnim; - private StopAnim handlerStopAnim; - private AgentRequestSit handlerAgentRequestSit; //OnAgentRequestSit; - private AgentSit handlerAgentSit; //OnAgentSit; - private AvatarPickerRequest handlerAvatarPickerRequest; //OnAvatarPickerRequest; - private FetchInventory handlerAgentDataUpdateRequest; //OnAgentDataUpdateRequest; - private TeleportLocationRequest handlerSetStartLocationRequest; //OnSetStartLocationRequest; - private TeleportLandmarkRequest handlerTeleportLandmarkRequest; //OnTeleportLandmarkRequest; - private LinkObjects handlerLinkObjects; //OnLinkObjects; - private DelinkObjects handlerDelinkObjects; //OnDelinkObjects; - private AddNewPrim handlerAddPrim; //OnAddPrim; - private UpdateShape handlerUpdatePrimShape; //null; - private ObjectExtraParams handlerUpdateExtraParams; //OnUpdateExtraParams; - private ObjectDuplicate handlerObjectDuplicate; - private ObjectDuplicateOnRay handlerObjectDuplicateOnRay; - private ObjectRequest handlerObjectRequest; - private ObjectSelect handlerObjectSelect; - private ObjectDeselect handlerObjectDeselect; - private ObjectIncludeInSearch handlerObjectIncludeInSearch; - private UpdatePrimFlags handlerUpdatePrimFlags; //OnUpdatePrimFlags; - private UpdatePrimTexture handlerUpdatePrimTexture; - private GrabObject handlerGrabObject; //OnGrabObject; - private MoveObject handlerGrabUpdate; //OnGrabUpdate; - private DeGrabObject handlerDeGrabObject; //OnDeGrabObject; - private SpinStart handlerSpinStart; //OnSpinStart; - private SpinObject handlerSpinUpdate; //OnSpinUpdate; - private SpinStop handlerSpinStop; //OnSpinStop; - private GenericCall7 handlerObjectDescription; - private GenericCall7 handlerObjectName; - private GenericCall7 handlerObjectClickAction; - private GenericCall7 handlerObjectMaterial; - private ObjectPermissions handlerObjectPermissions; - private RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily; //OnRequestObjectPropertiesFamily; - //private TextureRequest handlerTextureRequest; - private UDPAssetUploadRequest handlerAssetUploadRequest; //OnAssetUploadRequest; - private RequestXfer handlerRequestXfer; //OnRequestXfer; - private XferReceive handlerXferReceive; //OnXferReceive; - private ConfirmXfer handlerConfirmXfer; //OnConfirmXfer; - private AbortXfer handlerAbortXfer; - private CreateInventoryFolder handlerCreateInventoryFolder; //OnCreateNewInventoryFolder; - private UpdateInventoryFolder handlerUpdateInventoryFolder; - private MoveInventoryFolder handlerMoveInventoryFolder; - private CreateNewInventoryItem handlerCreateNewInventoryItem; //OnCreateNewInventoryItem; - private FetchInventory handlerFetchInventory; - private FetchInventoryDescendents handlerFetchInventoryDescendents; //OnFetchInventoryDescendents; - private PurgeInventoryDescendents handlerPurgeInventoryDescendents; //OnPurgeInventoryDescendents; - private UpdateInventoryItem handlerUpdateInventoryItem; - private CopyInventoryItem handlerCopyInventoryItem; - private MoveInventoryItem handlerMoveInventoryItem; - private RemoveInventoryItem handlerRemoveInventoryItem; - private RemoveInventoryFolder handlerRemoveInventoryFolder; - private RequestTaskInventory handlerRequestTaskInventory; //OnRequestTaskInventory; - private UpdateTaskInventory handlerUpdateTaskInventory; //OnUpdateTaskInventory; - private MoveTaskInventory handlerMoveTaskItem; - private RemoveTaskInventory handlerRemoveTaskItem; //OnRemoveTaskItem; - private RezScript handlerRezScript; //OnRezScript; - private RequestMapBlocks handlerRequestMapBlocks; //OnRequestMapBlocks; - private RequestMapName handlerMapNameRequest; //OnMapNameRequest; - private TeleportLocationRequest handlerTeleportLocationRequest; //OnTeleportLocationRequest; - private MoneyBalanceRequest handlerMoneyBalanceRequest; //OnMoneyBalanceRequest; - private UUIDNameRequest handlerNameRequest; - private ParcelAccessListRequest handlerParcelAccessListRequest; //OnParcelAccessListRequest; - private ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest; //OnParcelAccessListUpdateRequest; - private ParcelPropertiesRequest handlerParcelPropertiesRequest; //OnParcelPropertiesRequest; - private ParcelDivideRequest handlerParcelDivideRequest; //OnParcelDivideRequest; - private ParcelJoinRequest handlerParcelJoinRequest; //OnParcelJoinRequest; - private ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest; //OnParcelPropertiesUpdateRequest; - private ParcelSelectObjects handlerParcelSelectObjects; //OnParcelSelectObjects; - private ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest; //OnParcelObjectOwnerRequest; - private ParcelAbandonRequest handlerParcelAbandonRequest; - private ParcelGodForceOwner handlerParcelGodForceOwner; - private ParcelReclaim handlerParcelReclaim; - private RequestTerrain handlerRequestTerrain; - private RequestTerrain handlerUploadTerrain; - private ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest; - private RegionInfoRequest handlerRegionInfoRequest; //OnRegionInfoRequest; - private EstateCovenantRequest handlerEstateCovenantRequest; //OnEstateCovenantRequest; - private RequestGodlikePowers handlerReqGodlikePowers; //OnRequestGodlikePowers; - private GodKickUser handlerGodKickUser; //OnGodKickUser; - private ViewerEffectEventHandler handlerViewerEffect; //OnViewerEffect; - private Action handlerLogout; //OnLogout; - private MoneyTransferRequest handlerMoneyTransferRequest; //OnMoneyTransferRequest; - private ParcelBuy handlerParcelBuy; - private EconomyDataRequest handlerEconomoyDataRequest; - - private UpdateVector handlerUpdatePrimSinglePosition; //OnUpdatePrimSinglePosition; - private UpdatePrimSingleRotation handlerUpdatePrimSingleRotation; //OnUpdatePrimSingleRotation; - private UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition; //OnUpdatePrimSingleRotation; - private UpdateVector handlerUpdatePrimScale; //OnUpdatePrimScale; - private UpdateVector handlerUpdatePrimGroupScale; //OnUpdateGroupScale; - private UpdateVector handlerUpdateVector; //OnUpdatePrimGroupPosition; - private UpdatePrimRotation handlerUpdatePrimRotation; //OnUpdatePrimGroupRotation; - // private UpdatePrimGroupRotation handlerUpdatePrimGroupRotation; //OnUpdatePrimGroupMouseRotation; - // private RequestAsset handlerRequestAsset; // OnRequestAsset; - private UUIDNameRequest handlerTeleportHomeRequest; - - private RegionHandleRequest handlerRegionHandleRequest; // OnRegionHandleRequest - private ParcelInfoRequest handlerParcelInfoRequest; // OnParcelInfoRequest - - private ScriptAnswer handlerScriptAnswer; - private RequestPayPrice handlerRequestPayPrice; - private ObjectSaleInfo handlerObjectSaleInfo; - private ObjectBuy handlerObjectBuy; - //private BuyObjectInventory handlerBuyObjectInventory; - private ObjectDeselect handlerObjectDetach; - private ObjectDrop handlerObjectDrop; - private AgentSit handlerOnUndo; - - private ForceReleaseControls handlerForceReleaseControls; - - private GodLandStatRequest handlerLandStatRequest; - - private UUIDNameRequest handlerUUIDGroupNameRequest; - - private ParcelDeedToGroup handlerParcelDeedToGroup; - - private RequestObjectPropertiesFamily handlerObjectGroupRequest; - private ScriptReset handlerScriptReset; - private GetScriptRunning handlerGetScriptRunning; - private SetScriptRunning handlerSetScriptRunning; - private UpdateVector handlerAutoPilotGo; - //Gesture - private ActivateGesture handlerActivateGesture; - private DeactivateGesture handlerDeactivateGesture; - //Sound - private SoundTrigger handlerSoundTrigger; - private ObjectOwner handlerObjectOwner; - - private DirPlacesQuery handlerDirPlacesQuery; - private DirFindQuery handlerDirFindQuery; - private DirLandQuery handlerDirLandQuery; - private DirPopularQuery handlerDirPopularQuery; - private DirClassifiedQuery handlerDirClassifiedQuery; - private ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime; - - private MapItemRequest handlerMapItemRequest; - - private StartLure handlerStartLure; - private TeleportLureRequest handlerTeleportLureRequest; - - private NetworkStats handlerNetworkStatsUpdate; - - private ClassifiedInfoRequest handlerClassifiedInfoRequest; - private ClassifiedInfoUpdate handlerClassifiedInfoUpdate; - private ClassifiedDelete handlerClassifiedDelete; - private ClassifiedDelete handlerClassifiedGodDelete; - - private EventNotificationAddRequest handlerEventNotificationAddRequest; - private EventNotificationRemoveRequest handlerEventNotificationRemoveRequest; - private EventGodDelete handlerEventGodDelete; - - private ParcelDwellRequest handlerParcelDwellRequest; - - private UserInfoRequest handlerUserInfoRequest; - private UpdateUserInfo handlerUpdateUserInfo; - - private RetrieveInstantMessages handlerRetrieveInstantMessages; - - private PickDelete handlerPickDelete; - private PickGodDelete handlerPickGodDelete; - private PickInfoUpdate handlerPickInfoUpdate; - private AvatarNotesUpdate handlerAvatarNotesUpdate; - - private MuteListRequest handlerMuteListRequest; - - //private AvatarInterestUpdate handlerAvatarInterestUpdate; - - private PlacesQuery handlerPlacesQuery; - - private readonly IGroupsModule m_GroupsModule; - - private AgentUpdateArgs lastarg = null; - - //private TerrainUnacked handlerUnackedTerrain = null; - - //** - - /* Properties */ - - public UUID SecureSessionId - { - get { return m_secureSessionId; } - } - - public IScene Scene - { - get { return m_scene; } - } - - public UUID SessionId - { - get { return m_sessionId; } - } + #region Properties + public UUID SecureSessionId { get { return m_secureSessionId; } } + public IScene Scene { get { return m_scene; } } + public UUID SessionId { get { return m_sessionId; } } public Vector3 StartPos { get { return m_startpos; } set { m_startpos = value; } } - - public UUID AgentId - { - get { return m_agentId; } - } - - public UUID ActiveGroupId - { - get { return m_activeGroupID; } - } - - public string ActiveGroupName - { - get { return m_activeGroupName; } - } - - public ulong ActiveGroupPowers - { - get { return m_activeGroupPowers; } - } - - public bool IsGroupMember(UUID groupID) - { - return m_groupPowers.ContainsKey(groupID); - } - - public ulong GetGroupPowers(UUID groupID) - { - if (groupID == m_activeGroupID) - return m_activeGroupPowers; - - if (m_groupPowers.ContainsKey(groupID)) - return m_groupPowers[groupID]; - - return 0; - } - - /// - /// This is a utility method used by single states to not duplicate kicks and blue card of death messages. - /// - public bool ChildAgentStatus() - { - return m_scene.PresenceChildStatus(AgentId); - } - + public UUID AgentId { get { return m_agentId; } } + public UUID ActiveGroupId { get { return m_activeGroupID; } } + public string ActiveGroupName { get { return m_activeGroupName; } } + public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } + public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); } /// /// First name of the agent/avatar represented by the client /// - public string FirstName - { - get { return m_firstName; } - } - + public string FirstName { get { return m_firstName; } } /// /// Last name of the agent/avatar represented by the client /// - public string LastName - { - get { return m_lastName; } - } - + public string LastName { get { return m_lastName; } } /// /// Full name of the client (first name and last name) /// - public string Name - { - get { return FirstName + " " + LastName; } - } - - public uint CircuitCode - { - get { return m_circuitCode; } - } - - public int MoneyBalance - { - get { return m_moneyBalance; } - } - - public int NextAnimationSequenceNumber - { - get { return m_animationSequenceNumber++; } - } - - public ILLPacketHandler PacketHandler - { - get { return m_PacketHandler; } - } - - bool m_IsActive = true; - + public string Name { get { return FirstName + " " + LastName; } } + public uint CircuitCode { get { return m_circuitCode; } } + public int MoneyBalance { get { return m_moneyBalance; } } + public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } } public bool IsActive { get { return m_IsActive; } set { m_IsActive = value; } } + public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } } - public bool SendLogoutPacketWhenClosing - { - set { m_SendLogoutPacketWhenClosing = value; } - } - - /* METHODS */ + #endregion Properties /// /// Constructor /// - public LLClientView( - EndPoint remoteEP, IScene scene, LLPacketServer packServer, - AuthenticateResponse sessionInfo, UUID agentId, UUID sessionId, uint circuitCode, EndPoint proxyEP, - ClientStackUserSettings userSettings) + public LLClientView(EndPoint remoteEP, IScene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo, + UUID agentId, UUID sessionId, uint circuitCode) { - // Should be called first? - RegisterInterfaces(); - + RegisterInterface(this); + RegisterInterface(this); + RegisterInterface(this); m_GroupsModule = scene.RequestModuleInterface(); + m_moneyBalance = 1000; m_channelVersion = Utils.StringToBytes(scene.GetSimulatorVersion()); @@ -505,14 +183,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_assetService = m_scene.RequestModuleInterface(); - m_networkServer = packServer; + m_udpServer = udpServer; + m_udpClient = udpClient; m_agentId = agentId; m_sessionId = sessionId; m_circuitCode = circuitCode; m_userEndPoint = remoteEP; - m_proxyEndPoint = proxyEP; m_firstName = sessionInfo.LoginInfo.First; m_lastName = sessionInfo.LoginInfo.Last; @@ -528,40 +206,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP // in it to process. It's an on-purpose threadlock though because // without it, the clientloop will suck up all sim resources. - m_PacketHandler = new LLPacketHandler(this, m_networkServer, userSettings); - m_PacketHandler.SynchronizeClient = SynchronizeClient; - m_PacketHandler.OnPacketStats += PopulateStats; - m_PacketHandler.OnQueueEmpty += HandleQueueEmpty; - - if (scene.Config != null) - { - IConfig clientConfig = scene.Config.Configs["LLClient"]; - if (clientConfig != null) - { - m_PacketHandler.ReliableIsImportant = - clientConfig.GetBoolean("ReliableIsImportant", - false); - m_PacketHandler.MaxReliableResends = clientConfig.GetInt("MaxReliableResends", - m_PacketHandler.MaxReliableResends); - m_primTerseUpdatesPerPacket = clientConfig.GetInt("TerseUpdatesPerPacket", - m_primTerseUpdatesPerPacket); - m_primFullUpdatesPerPacket = clientConfig.GetInt("FullUpdatesPerPacket", - m_primFullUpdatesPerPacket); - - m_primTerseUpdateRate = clientConfig.GetInt("TerseUpdateRate", - m_primTerseUpdateRate); - m_primFullUpdateRate = clientConfig.GetInt("FullUpdateRate", - m_primFullUpdateRate); - - m_textureSendLimit = clientConfig.GetInt("TextureSendLimit", - m_textureSendLimit); - - m_textureDataLimit = clientConfig.GetInt("TextureDataLimit", - m_textureDataLimit); - - m_packetMTU = clientConfig.GetInt("PacketMTU", 1400); - } - } + //m_PacketHandler = new LLPacketHandler(this, m_networkServer, userSettings); + //m_PacketHandler.SynchronizeClient = SynchronizeClient; + //m_PacketHandler.OnPacketStats += PopulateStats; + //m_PacketHandler.OnQueueEmpty += HandleQueueEmpty; RegisterLocalPacketHandlers(); m_imageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface()); @@ -572,12 +220,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_debugPacketLevel = newDebugPacketLevel; } - # region Client Methods + #region Client Methods private void CloseCleanup(bool shutdownCircuit) { - - m_scene.RemoveClient(AgentId); //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); @@ -645,8 +291,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_imageManager != null) m_imageManager.Close(); - if (m_PacketHandler != null) - m_PacketHandler.Flush(); + if (m_udpServer != null) + m_udpServer.Flush(); // raise an event on the packet server to Shutdown the circuit // Now, if we raise the event then the packet server will call this method itself, so don't try cleanup @@ -700,28 +346,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_primFullUpdateTimer.Stop(); } - public void Restart() - { - // re-construct - m_PacketHandler.Clear(); - - m_clientPingTimer = new Timer(5000); - m_clientPingTimer.Elapsed += CheckClientConnectivity; - m_clientPingTimer.Enabled = true; - - m_avatarTerseUpdateTimer = new Timer(m_avatarTerseUpdateRate); - m_avatarTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessAvatarTerseUpdates); - m_avatarTerseUpdateTimer.AutoReset = false; - - m_primTerseUpdateTimer = new Timer(m_primTerseUpdateRate); - m_primTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessPrimTerseUpdates); - m_primTerseUpdateTimer.AutoReset = false; - - m_primFullUpdateTimer = new Timer(m_primFullUpdateRate); - m_primFullUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessPrimFullUpdates); - m_primFullUpdateTimer.AutoReset = false; - } - private void Terminate() { IsActive = false; @@ -730,9 +354,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_avatarTerseUpdateTimer.Close(); m_primTerseUpdateTimer.Close(); m_primFullUpdateTimer.Close(); - - m_PacketHandler.OnPacketStats -= PopulateStats; - m_PacketHandler.Dispose(); + + //m_udpServer.OnPacketStats -= PopulateStats; + m_udpClient.Shutdown(); // wait for thread stoped // m_clientThread.Join(); @@ -741,13 +365,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP //m_networkServer.CloseClient(this); } - #endregion + #endregion Client Methods - # region Packet Handling + #region Packet Handling public void PopulateStats(int inPackets, int outPackets, int unAckedBytes) { - handlerNetworkStatsUpdate = OnNetworkStatsUpdate; + NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate; if (handlerNetworkStatsUpdate != null) { handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes); @@ -856,86 +480,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Console.WriteLine(m_circuitCode + ":" + direction + ": " + info); } - /// - /// Main packet processing loop for the UDP component of the client session. Both incoming and outgoing - /// packets are processed here. - /// - protected virtual void ClientLoop() - { - m_log.DebugFormat( - "[CLIENT]: Entered main packet processing loop for {0} in {1}", Name, Scene.RegionInfo.RegionName); - - while (IsActive) - { - LLQueItem nextPacket = m_PacketHandler.PacketQueue.Dequeue(); - - if (nextPacket == null) { - m_log.DebugFormat("[CLIENT]: PacketQueue return null LLQueItem"); - continue; - } - - if (nextPacket.Incoming) - { - if (m_debugPacketLevel > 0) - DebugPacket("IN", nextPacket.Packet); - m_PacketHandler.ProcessInPacket(nextPacket); - } - else - { - if (m_debugPacketLevel > 0) - DebugPacket("OUT", nextPacket.Packet); - m_PacketHandler.ProcessOutPacket(nextPacket); - } - } - } - - # endregion - - protected int m_terrainCheckerCount; - - /// - /// Event handler for check client timer - /// Checks to ensure that the client is still connected. If the client has failed to respond to many pings - /// in succession then close down the connection. - /// - /// - /// - protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) - { - if (m_PacketHandler.PacketsReceived == m_inPacketsChecked) - { - // no packet came in since the last time we checked... - - m_probesWithNoIngressPackets++; - if ((m_probesWithNoIngressPackets > 30 && !m_clientBlocked) // agent active - || (m_probesWithNoIngressPackets > 90 && m_clientBlocked)) // agent paused - { - m_clientPingTimer.Enabled = false; - - m_log.WarnFormat( - "[CLIENT]: Client for agent {0} {1} has stopped responding to pings. Closing connection", - Name, AgentId); - - if (OnConnectionClosed != null) - { - OnConnectionClosed(this); - } - } - else - { - // this will normally trigger at least one packet (ping response) - SendStartPingCheck(0); - } - } - else - { - // Something received in the meantime - we can reset the counters - m_probesWithNoIngressPackets = 0; - // ... and store the current number of packets received to find out if another one got in on the next cycle - m_inPacketsChecked = m_PacketHandler.PacketsReceived; - } - - } + #endregion Packet Handling # region Setup @@ -947,11 +492,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP { //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); - // Ping the client regularly to check that it's still there - m_clientPingTimer = new Timer(5000); - m_clientPingTimer.Elapsed += CheckClientConnectivity; - m_clientPingTimer.Enabled = true; - m_avatarTerseUpdateTimer = new Timer(m_avatarTerseUpdateRate); m_avatarTerseUpdateTimer.Elapsed += new ElapsedEventHandler(ProcessAvatarTerseUpdates); m_avatarTerseUpdateTimer.AutoReset = false; @@ -981,7 +521,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Run a user session. This method lies at the base of the entire client thread. /// - protected virtual void RunUserSession() + protected void RunUserSession() { //tell this thread we are using the culture set up for the sim (currently hardcoded to en_US) //otherwise it will override this and use the system default @@ -991,7 +531,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP { // This sets up all the timers InitNewClient(); - ClientLoop(); } catch (Exception e) { @@ -1015,11 +554,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP + "Any further actions taken will not be processed.\n" + "Please relog", true); - LLQueItem item = new LLQueItem(); - item.Packet = packet; - item.Sequence = packet.Header.Sequence; - - m_PacketHandler.ProcessOutPacket(item); + m_udpServer.SendPacket(m_agentId, packet, ThrottleOutPacketType.Unknown, false); // There may be a better way to do this. Perhaps kick? Not sure this propogates notifications to // listeners yet, though. @@ -1037,7 +572,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP # endregion - // Previously ClientView.API partial class + #region Events + public event GenericMessage OnGenericMessage; public event BinaryGenericMessage OnBinaryGenericMessage; public event Action OnLogout; @@ -1197,13 +733,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; public event UpdateVector OnAutoPilotGo; - public event TerrainUnacked OnUnackedTerrain; - public event ActivateGesture OnActivateGesture; public event DeactivateGesture OnDeactivateGesture; public event ObjectOwner OnObjectOwner; - public event DirPlacesQuery OnDirPlacesQuery; public event DirFindQuery OnDirFindQuery; public event DirLandQuery OnDirLandQuery; @@ -1211,45 +744,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event DirClassifiedQuery OnDirClassifiedQuery; public event EventInfoRequest OnEventInfoRequest; public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime; - public event MapItemRequest OnMapItemRequest; - public event OfferCallingCard OnOfferCallingCard; public event AcceptCallingCard OnAcceptCallingCard; public event DeclineCallingCard OnDeclineCallingCard; public event SoundTrigger OnSoundTrigger; - public event StartLure OnStartLure; public event TeleportLureRequest OnTeleportLureRequest; public event NetworkStats OnNetworkStatsUpdate; - public event ClassifiedInfoRequest OnClassifiedInfoRequest; public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; public event ClassifiedDelete OnClassifiedDelete; public event ClassifiedDelete OnClassifiedGodDelete; - public event EventNotificationAddRequest OnEventNotificationAddRequest; public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; public event EventGodDelete OnEventGodDelete; - public event ParcelDwellRequest OnParcelDwellRequest; - public event UserInfoRequest OnUserInfoRequest; public event UpdateUserInfo OnUpdateUserInfo; - public event RetrieveInstantMessages OnRetrieveInstantMessages; - public event PickDelete OnPickDelete; public event PickGodDelete OnPickGodDelete; public event PickInfoUpdate OnPickInfoUpdate; public event AvatarNotesUpdate OnAvatarNotesUpdate; - public event MuteListRequest OnMuteListRequest; - - //public event AvatarInterestUpdate OnAvatarInterestUpdate; - + public event AvatarInterestUpdate OnAvatarInterestUpdate; public event PlacesQuery OnPlacesQuery; + #endregion Events + public void ActivateGesture(UUID assetId, UUID gestureId) { } @@ -2768,7 +2291,953 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(avatarReply, ThrottleOutPacketType.Task); } - #endregion + /// + /// Send the client an Estate message blue box pop-down with a single OK button + /// + /// + /// + /// + /// + public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message) + { + if (!ChildAgentStatus()) + SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3())); + + //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch()); + } + + public void SendLogoutPacket() + { + // I know this is a bit of a hack, however there are times when you don't + // want to send this, but still need to do the rest of the shutdown process + // this method gets called from the packet server.. which makes it practically + // impossible to do any other way. + + if (m_SendLogoutPacketWhenClosing) + { + LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); + // TODO: don't create new blocks if recycling an old packet + logReply.AgentData.AgentID = AgentId; + logReply.AgentData.SessionID = SessionId; + logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; + logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); + logReply.InventoryData[0].ItemID = UUID.Zero; + + OutPacket(logReply, ThrottleOutPacketType.Task); + } + } + + public void SendHealth(float health) + { + HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage); + healthpacket.HealthData.Health = health; + OutPacket(healthpacket, ThrottleOutPacketType.Task); + } + + public void SendAgentOnline(UUID[] agentIDs) + { + OnlineNotificationPacket onp = new OnlineNotificationPacket(); + OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length]; + for (int i = 0; i < agentIDs.Length; i++) + { + OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock(); + onpbl.AgentID = agentIDs[i]; + onpb[i] = onpbl; + } + onp.AgentBlock = onpb; + onp.Header.Reliable = true; + OutPacket(onp, ThrottleOutPacketType.Task); + } + + public void SendAgentOffline(UUID[] agentIDs) + { + OfflineNotificationPacket offp = new OfflineNotificationPacket(); + OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length]; + for (int i = 0; i < agentIDs.Length; i++) + { + OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock(); + onpbl.AgentID = agentIDs[i]; + offpb[i] = onpbl; + } + offp.AgentBlock = offpb; + offp.Header.Reliable = true; + OutPacket(offp, ThrottleOutPacketType.Task); + } + + public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, + Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) + { + AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); + avatarSitResponse.SitObject.ID = TargetID; + if (CameraAtOffset != Vector3.Zero) + { + avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset; + avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset; + } + avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook; + avatarSitResponse.SitTransform.AutoPilot = autopilot; + avatarSitResponse.SitTransform.SitPosition = OffsetPos; + avatarSitResponse.SitTransform.SitRotation = SitOrientation; + + OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); + } + + public void SendAdminResponse(UUID Token, uint AdminLevel) + { + GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); + GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock(); + GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock(); + + adb.AgentID = AgentId; + adb.SessionID = SessionId; // More security + gdb.GodLevel = (byte)AdminLevel; + gdb.Token = Token; + //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; + respondPacket.GrantData = gdb; + respondPacket.AgentData = adb; + OutPacket(respondPacket, ThrottleOutPacketType.Task); + } + + public void SendGroupMembership(GroupMembershipData[] GroupMembership) + { + m_groupPowers.Clear(); + + AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket(); + AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length]; + for (int i = 0; i < GroupMembership.Length; i++) + { + m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; + + AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); + Group.AcceptNotices = GroupMembership[i].AcceptNotices; + Group.Contribution = GroupMembership[i].Contribution; + Group.GroupID = GroupMembership[i].GroupID; + Group.GroupInsigniaID = GroupMembership[i].GroupPicture; + Group.GroupName = Utils.StringToBytes(GroupMembership[i].GroupName); + Group.GroupPowers = GroupMembership[i].GroupPowers; + Groups[i] = Group; + + + } + Groupupdate.GroupData = Groups; + Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock(); + Groupupdate.AgentData.AgentID = AgentId; + OutPacket(Groupupdate, ThrottleOutPacketType.Task); + + try + { + IEventQueue eq = Scene.RequestModuleInterface(); + if (eq != null) + { + eq.GroupMembership(Groupupdate, this.AgentId); + } + } + catch (Exception ex) + { + m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString()); + m_log.Warn("sending group membership data via UDP"); + OutPacket(Groupupdate, ThrottleOutPacketType.Task); + } + } + + + public void SendGroupNameReply(UUID groupLLUID, string GroupName) + { + UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket(); + UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1]; + UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock(); + uidnamebloc.ID = groupLLUID; + uidnamebloc.GroupName = Utils.StringToBytes(GroupName); + uidnameblock[0] = uidnamebloc; + pack.UUIDNameBlock = uidnameblock; + OutPacket(pack, ThrottleOutPacketType.Task); + } + + public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) + { + LandStatReplyPacket lsrp = new LandStatReplyPacket(); + // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock(); + LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length]; + //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); + // lsrepdb. + lsrp.RequestData.ReportType = reportType; + lsrp.RequestData.RequestFlags = requestFlags; + lsrp.RequestData.TotalObjectCount = resultCount; + for (int i = 0; i < lsrpia.Length; i++) + { + LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); + lsrepdb.LocationX = lsrpia[i].LocationX; + lsrepdb.LocationY = lsrpia[i].LocationY; + lsrepdb.LocationZ = lsrpia[i].LocationZ; + lsrepdb.Score = lsrpia[i].Score; + lsrepdb.TaskID = lsrpia[i].TaskID; + lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID; + lsrepdb.TaskName = Utils.StringToBytes(lsrpia[i].TaskName); + lsrepdb.OwnerName = Utils.StringToBytes(lsrpia[i].OwnerName); + lsrepdba[i] = lsrepdb; + } + lsrp.ReportData = lsrepdba; + OutPacket(lsrp, ThrottleOutPacketType.Task); + } + + public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running) + { + ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket(); + scriptRunningReply.Script.ObjectID = objectID; + scriptRunningReply.Script.ItemID = itemID; + scriptRunningReply.Script.Running = running; + + OutPacket(scriptRunningReply, ThrottleOutPacketType.Task); + } + + public void SendAsset(AssetRequestToClient req) + { + //m_log.Debug("sending asset " + req.RequestAssetID); + TransferInfoPacket Transfer = new TransferInfoPacket(); + Transfer.TransferInfo.ChannelType = 2; + Transfer.TransferInfo.Status = 0; + Transfer.TransferInfo.TargetType = 0; + if (req.AssetRequestSource == 2) + { + Transfer.TransferInfo.Params = new byte[20]; + Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); + int assType = req.AssetInf.Type; + Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); + } + else if (req.AssetRequestSource == 3) + { + Transfer.TransferInfo.Params = req.Params; + // Transfer.TransferInfo.Params = new byte[100]; + //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); + //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); + } + Transfer.TransferInfo.Size = req.AssetInf.Data.Length; + Transfer.TransferInfo.TransferID = req.TransferRequestID; + Transfer.Header.Zerocoded = true; + OutPacket(Transfer, ThrottleOutPacketType.Asset); + + if (req.NumPackets == 1) + { + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = 0; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + TransferPacket.TransferData.Data = req.AssetInf.Data; + TransferPacket.TransferData.Status = 1; + TransferPacket.Header.Zerocoded = true; + OutPacket(TransferPacket, ThrottleOutPacketType.Asset); + } + else + { + int processedLength = 0; + int maxChunkSize = Settings.MAX_PACKET_SIZE - 100; + int packetNumber = 0; + + while (processedLength < req.AssetInf.Data.Length) + { + TransferPacketPacket TransferPacket = new TransferPacketPacket(); + TransferPacket.TransferData.Packet = packetNumber; + TransferPacket.TransferData.ChannelType = 2; + TransferPacket.TransferData.TransferID = req.TransferRequestID; + + int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); + byte[] chunk = new byte[chunkSize]; + Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); + + TransferPacket.TransferData.Data = chunk; + + // 0 indicates more packets to come, 1 indicates last packet + if (req.AssetInf.Data.Length - processedLength > maxChunkSize) + { + TransferPacket.TransferData.Status = 0; + } + else + { + TransferPacket.TransferData.Status = 1; + } + TransferPacket.Header.Zerocoded = true; + OutPacket(TransferPacket, ThrottleOutPacketType.Asset); + + processedLength += chunkSize; + packetNumber++; + } + } + } + + public void SendTexture(AssetBase TextureAsset) + { + + } + + public void SendRegionHandle(UUID regionID, ulong handle) + { + RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply); + reply.ReplyBlock.RegionID = regionID; + reply.ReplyBlock.RegionHandle = handle; + OutPacket(reply, ThrottleOutPacketType.Land); + } + + public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y) + { + ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply); + reply.AgentData.AgentID = m_agentId; + reply.Data.ParcelID = parcelID; + reply.Data.OwnerID = land.OwnerID; + reply.Data.Name = Utils.StringToBytes(land.Name); + reply.Data.Desc = Utils.StringToBytes(land.Description); + reply.Data.ActualArea = land.Area; + reply.Data.BillableArea = land.Area; // TODO: what is this? + + // Bit 0: Mature, bit 7: on sale, other bits: no idea + reply.Data.Flags = (byte)( + ((land.Flags & (uint)ParcelFlags.MaturePublish) != 0 ? (1 << 0) : 0) + + ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0)); + + Vector3 pos = land.UserLocation; + if (pos.Equals(Vector3.Zero)) + { + pos = (land.AABBMax + land.AABBMin) * 0.5f; + } + reply.Data.GlobalX = info.RegionLocX * Constants.RegionSize + x; + reply.Data.GlobalY = info.RegionLocY * Constants.RegionSize + y; + reply.Data.GlobalZ = pos.Z; + reply.Data.SimName = Utils.StringToBytes(info.RegionName); + reply.Data.SnapshotID = land.SnapshotID; + reply.Data.Dwell = land.Dwell; + reply.Data.SalePrice = land.SalePrice; + reply.Data.AuctionID = (int)land.AuctionID; + + OutPacket(reply, ThrottleOutPacketType.Land); + } + + public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt) + { + ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest); + + packet.Data.ObjectName = Utils.StringToBytes(objName); + packet.Data.SimName = Utils.StringToBytes(simName); + packet.Data.SimPosition = pos; + packet.Data.LookAt = lookAt; + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data) + { + DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply); + + packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock(); + + packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1]; + packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock(); + + packet.QueryReplies = + new DirPlacesReplyPacket.QueryRepliesBlock[data.Length]; + + packet.StatusData = new DirPlacesReplyPacket.StatusDataBlock[ + data.Length]; + + packet.AgentData.AgentID = AgentId; + + packet.QueryData[0].QueryID = queryID; + + int i = 0; + foreach (DirPlacesReplyData d in data) + { + packet.QueryReplies[i] = + new DirPlacesReplyPacket.QueryRepliesBlock(); + packet.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock(); + packet.QueryReplies[i].ParcelID = d.parcelID; + packet.QueryReplies[i].Name = Utils.StringToBytes(d.name); + packet.QueryReplies[i].ForSale = d.forSale; + packet.QueryReplies[i].Auction = d.auction; + packet.QueryReplies[i].Dwell = d.dwell; + packet.StatusData[i].Status = d.Status; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data) + { + DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply); + + packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock(); + packet.QueryData.QueryID = queryID; + + packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[ + data.Length]; + + int i = 0; + foreach (DirPeopleReplyData d in data) + { + packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock(); + packet.QueryReplies[i].AgentID = d.agentID; + packet.QueryReplies[i].FirstName = + Utils.StringToBytes(d.firstName); + packet.QueryReplies[i].LastName = + Utils.StringToBytes(d.lastName); + packet.QueryReplies[i].Group = + Utils.StringToBytes(d.group); + packet.QueryReplies[i].Online = d.online; + packet.QueryReplies[i].Reputation = d.reputation; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data) + { + DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply); + + packet.AgentData = new DirEventsReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.QueryData = new DirEventsReplyPacket.QueryDataBlock(); + packet.QueryData.QueryID = queryID; + + packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[ + data.Length]; + + packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[ + data.Length]; + + int i = 0; + foreach (DirEventsReplyData d in data) + { + packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock(); + packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock(); + packet.QueryReplies[i].OwnerID = d.ownerID; + packet.QueryReplies[i].Name = + Utils.StringToBytes(d.name); + packet.QueryReplies[i].EventID = d.eventID; + packet.QueryReplies[i].Date = + Utils.StringToBytes(d.date); + packet.QueryReplies[i].UnixTime = d.unixTime; + packet.QueryReplies[i].EventFlags = d.eventFlags; + packet.StatusData[i].Status = d.Status; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data) + { + DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply); + + packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock(); + packet.QueryData.QueryID = queryID; + + packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[ + data.Length]; + + int i = 0; + foreach (DirGroupsReplyData d in data) + { + packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock(); + packet.QueryReplies[i].GroupID = d.groupID; + packet.QueryReplies[i].GroupName = + Utils.StringToBytes(d.groupName); + packet.QueryReplies[i].Members = d.members; + packet.QueryReplies[i].SearchOrder = d.searchOrder; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data) + { + DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply); + + packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock(); + packet.QueryData.QueryID = queryID; + + packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[ + data.Length]; + packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[ + data.Length]; + + int i = 0; + foreach (DirClassifiedReplyData d in data) + { + packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock(); + packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock(); + packet.QueryReplies[i].ClassifiedID = d.classifiedID; + packet.QueryReplies[i].Name = + Utils.StringToBytes(d.name); + packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags; + packet.QueryReplies[i].CreationDate = d.creationDate; + packet.QueryReplies[i].ExpirationDate = d.expirationDate; + packet.QueryReplies[i].PriceForListing = d.price; + packet.StatusData[i].Status = d.Status; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirLandReply(UUID queryID, DirLandReplyData[] data) + { + DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply); + + packet.AgentData = new DirLandReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.QueryData = new DirLandReplyPacket.QueryDataBlock(); + packet.QueryData.QueryID = queryID; + + packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[ + data.Length]; + + int i = 0; + foreach (DirLandReplyData d in data) + { + packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock(); + packet.QueryReplies[i].ParcelID = d.parcelID; + packet.QueryReplies[i].Name = + Utils.StringToBytes(d.name); + packet.QueryReplies[i].Auction = d.auction; + packet.QueryReplies[i].ForSale = d.forSale; + packet.QueryReplies[i].SalePrice = d.salePrice; + packet.QueryReplies[i].ActualArea = d.actualArea; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data) + { + DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply); + + packet.AgentData = new DirPopularReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.QueryData = new DirPopularReplyPacket.QueryDataBlock(); + packet.QueryData.QueryID = queryID; + + packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[ + data.Length]; + + int i = 0; + foreach (DirPopularReplyData d in data) + { + packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock(); + packet.QueryReplies[i].ParcelID = d.parcelID; + packet.QueryReplies[i].Name = + Utils.StringToBytes(d.name); + packet.QueryReplies[i].Dwell = d.dwell; + i++; + } + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendEventInfoReply(EventData data) + { + EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply); + + packet.AgentData = new EventInfoReplyPacket.AgentDataBlock(); + packet.AgentData.AgentID = AgentId; + + packet.EventData = new EventInfoReplyPacket.EventDataBlock(); + packet.EventData.EventID = data.eventID; + packet.EventData.Creator = Utils.StringToBytes(data.creator); + packet.EventData.Name = Utils.StringToBytes(data.name); + packet.EventData.Category = Utils.StringToBytes(data.category); + packet.EventData.Desc = Utils.StringToBytes(data.description); + packet.EventData.Date = Utils.StringToBytes(data.date); + packet.EventData.DateUTC = data.dateUTC; + packet.EventData.Duration = data.duration; + packet.EventData.Cover = data.cover; + packet.EventData.Amount = data.amount; + packet.EventData.SimName = Utils.StringToBytes(data.simName); + packet.EventData.GlobalPos = new Vector3d(data.globalPos); + packet.EventData.EventFlags = data.eventFlags; + + OutPacket(packet, ThrottleOutPacketType.Task); + } + + public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) + { + MapItemReplyPacket mirplk = new MapItemReplyPacket(); + mirplk.AgentData.AgentID = AgentId; + mirplk.RequestData.ItemType = mapitemtype; + mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length]; + for (int i = 0; i < replies.Length; i++) + { + MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock(); + mrdata.X = replies[i].x; + mrdata.Y = replies[i].y; + mrdata.ID = replies[i].id; + mrdata.Extra = replies[i].Extra; + mrdata.Extra2 = replies[i].Extra2; + mrdata.Name = Utils.StringToBytes(replies[i].name); + mirplk.Data[i] = mrdata; + } + //m_log.Debug(mirplk.ToString()); + OutPacket(mirplk, ThrottleOutPacketType.Task); + + } + + public void SendOfferCallingCard(UUID srcID, UUID transactionID) + { + // a bit special, as this uses AgentID to store the source instead + // of the destination. The destination (the receiver) goes into destID + OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard); + p.AgentData.AgentID = srcID; + p.AgentData.SessionID = UUID.Zero; + p.AgentBlock.DestID = AgentId; + p.AgentBlock.TransactionID = transactionID; + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendAcceptCallingCard(UUID transactionID) + { + AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard); + p.AgentData.AgentID = AgentId; + p.AgentData.SessionID = UUID.Zero; + p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1]; + p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock(); + p.FolderData[0].FolderID = UUID.Zero; + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendDeclineCallingCard(UUID transactionID) + { + DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard); + p.AgentData.AgentID = AgentId; + p.AgentData.SessionID = UUID.Zero; + p.TransactionBlock.TransactionID = transactionID; + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendTerminateFriend(UUID exFriendID) + { + TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship); + p.AgentData.AgentID = AgentId; + p.AgentData.SessionID = SessionId; + p.ExBlock.OtherID = exFriendID; + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) + { + AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); + + p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); + p.AgentData.AgentID = AgentId; + p.AgentData.AvatarID = avatarID; + + p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; + int i = 0; + foreach (GroupMembershipData m in data) + { + p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); + p.GroupData[i].GroupPowers = m.GroupPowers; + p.GroupData[i].AcceptNotices = m.AcceptNotices; + p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); + p.GroupData[i].GroupID = m.GroupID; + p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); + p.GroupData[i].GroupInsigniaID = m.GroupPicture; + i++; + } + + p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); + p.NewGroupData.ListInProfile = true; + + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendJoinGroupReply(UUID groupID, bool success) + { + JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply); + + p.AgentData = new JoinGroupReplyPacket.AgentDataBlock(); + p.AgentData.AgentID = AgentId; + + p.GroupData = new JoinGroupReplyPacket.GroupDataBlock(); + p.GroupData.GroupID = groupID; + p.GroupData.Success = success; + + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) + { + EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply); + + p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock(); + p.AgentData.AgentID = agentID; + + p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock(); + p.GroupData.GroupID = groupID; + + p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock(); + p.EjectData.Success = success; + + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendLeaveGroupReply(UUID groupID, bool success) + { + LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply); + + p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock(); + p.AgentData.AgentID = AgentId; + + p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock(); + p.GroupData.GroupID = groupID; + p.GroupData.Success = success; + + OutPacket(p, ThrottleOutPacketType.Task); + } + + public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) + { + if (classifiedID.Length != name.Length) + return; + + AvatarClassifiedReplyPacket ac = + (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( + PacketType.AvatarClassifiedReply); + + ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); + ac.AgentData.AgentID = AgentId; + ac.AgentData.TargetID = targetID; + + ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length]; + int i; + for (i = 0; i < classifiedID.Length; i++) + { + ac.Data[i].ClassifiedID = classifiedID[i]; + ac.Data[i].Name = Utils.StringToBytes(name[i]); + } + + OutPacket(ac, ThrottleOutPacketType.Task); + } + + public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price) + { + ClassifiedInfoReplyPacket cr = + (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket( + PacketType.ClassifiedInfoReply); + + cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock(); + cr.AgentData.AgentID = AgentId; + + cr.Data = new ClassifiedInfoReplyPacket.DataBlock(); + cr.Data.ClassifiedID = classifiedID; + cr.Data.CreatorID = creatorID; + cr.Data.CreationDate = creationDate; + cr.Data.ExpirationDate = expirationDate; + cr.Data.Category = category; + cr.Data.Name = Utils.StringToBytes(name); + cr.Data.Desc = Utils.StringToBytes(description); + cr.Data.ParcelID = parcelID; + cr.Data.ParentEstate = parentEstate; + cr.Data.SnapshotID = snapshotID; + cr.Data.SimName = Utils.StringToBytes(simName); + cr.Data.PosGlobal = new Vector3d(globalPos); + cr.Data.ParcelName = Utils.StringToBytes(parcelName); + cr.Data.ClassifiedFlags = classifiedFlags; + cr.Data.PriceForListing = price; + + OutPacket(cr, ThrottleOutPacketType.Task); + } + + public void SendAgentDropGroup(UUID groupID) + { + AgentDropGroupPacket dg = + (AgentDropGroupPacket)PacketPool.Instance.GetPacket( + PacketType.AgentDropGroup); + + dg.AgentData = new AgentDropGroupPacket.AgentDataBlock(); + dg.AgentData.AgentID = AgentId; + dg.AgentData.GroupID = groupID; + + OutPacket(dg, ThrottleOutPacketType.Task); + } + + public void SendAvatarNotesReply(UUID targetID, string text) + { + AvatarNotesReplyPacket an = + (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket( + PacketType.AvatarNotesReply); + + an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock(); + an.AgentData.AgentID = AgentId; + + an.Data = new AvatarNotesReplyPacket.DataBlock(); + an.Data.TargetID = targetID; + an.Data.Notes = Utils.StringToBytes(text); + + OutPacket(an, ThrottleOutPacketType.Task); + } + + public void SendAvatarPicksReply(UUID targetID, Dictionary picks) + { + AvatarPicksReplyPacket ap = + (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket( + PacketType.AvatarPicksReply); + + ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock(); + ap.AgentData.AgentID = AgentId; + ap.AgentData.TargetID = targetID; + + ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count]; + + int i = 0; + foreach (KeyValuePair pick in picks) + { + ap.Data[i] = new AvatarPicksReplyPacket.DataBlock(); + ap.Data[i].PickID = pick.Key; + ap.Data[i].PickName = Utils.StringToBytes(pick.Value); + i++; + } + + OutPacket(ap, ThrottleOutPacketType.Task); + } + + public void SendAvatarClassifiedReply(UUID targetID, Dictionary classifieds) + { + AvatarClassifiedReplyPacket ac = + (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( + PacketType.AvatarClassifiedReply); + + ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); + ac.AgentData.AgentID = AgentId; + ac.AgentData.TargetID = targetID; + + ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count]; + + int i = 0; + foreach (KeyValuePair classified in classifieds) + { + ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock(); + ac.Data[i].ClassifiedID = classified.Key; + ac.Data[i].Name = Utils.StringToBytes(classified.Value); + i++; + } + + OutPacket(ac, ThrottleOutPacketType.Task); + } + + public void SendParcelDwellReply(int localID, UUID parcelID, float dwell) + { + ParcelDwellReplyPacket pd = + (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket( + PacketType.ParcelDwellReply); + + pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock(); + pd.AgentData.AgentID = AgentId; + + pd.Data = new ParcelDwellReplyPacket.DataBlock(); + pd.Data.LocalID = localID; + pd.Data.ParcelID = parcelID; + pd.Data.Dwell = dwell; + + OutPacket(pd, ThrottleOutPacketType.Land); + } + + public void SendUserInfoReply(bool imViaEmail, bool visible, string email) + { + UserInfoReplyPacket ur = + (UserInfoReplyPacket)PacketPool.Instance.GetPacket( + PacketType.UserInfoReply); + + string Visible = "hidden"; + if (visible) + Visible = "default"; + + ur.AgentData = new UserInfoReplyPacket.AgentDataBlock(); + ur.AgentData.AgentID = AgentId; + + ur.UserData = new UserInfoReplyPacket.UserDataBlock(); + ur.UserData.IMViaEMail = imViaEmail; + ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible); + ur.UserData.EMail = Utils.StringToBytes(email); + + OutPacket(ur, ThrottleOutPacketType.Task); + } + + public void SendCreateGroupReply(UUID groupID, bool success, string message) + { + CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply); + + createGroupReply.AgentData = + new CreateGroupReplyPacket.AgentDataBlock(); + createGroupReply.ReplyData = + new CreateGroupReplyPacket.ReplyDataBlock(); + + createGroupReply.AgentData.AgentID = AgentId; + createGroupReply.ReplyData.GroupID = groupID; + + createGroupReply.ReplyData.Success = success; + createGroupReply.ReplyData.Message = Utils.StringToBytes(message); + OutPacket(createGroupReply, ThrottleOutPacketType.Task); + } + + public void SendUseCachedMuteList() + { + UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList); + + useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock(); + useCachedMuteList.AgentData.AgentID = AgentId; + + OutPacket(useCachedMuteList, ThrottleOutPacketType.Task); + } + + public void SendMuteListUpdate(string filename) + { + MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate); + + muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock(); + muteListUpdate.MuteData.AgentID = AgentId; + muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename); + + OutPacket(muteListUpdate, ThrottleOutPacketType.Task); + } + + public void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) + { + PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply); + + pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock(); + pickInfoReply.AgentData.AgentID = AgentId; + + pickInfoReply.Data = new PickInfoReplyPacket.DataBlock(); + pickInfoReply.Data.PickID = pickID; + pickInfoReply.Data.CreatorID = creatorID; + pickInfoReply.Data.TopPick = topPick; + pickInfoReply.Data.ParcelID = parcelID; + pickInfoReply.Data.Name = Utils.StringToBytes(name); + pickInfoReply.Data.Desc = Utils.StringToBytes(desc); + pickInfoReply.Data.SnapshotID = snapshotID; + pickInfoReply.Data.User = Utils.StringToBytes(user); + pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName); + pickInfoReply.Data.SimName = Utils.StringToBytes(simName); + pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal); + pickInfoReply.Data.SortOrder = sortOrder; + pickInfoReply.Data.Enabled = enabled; + + OutPacket(pickInfoReply, ThrottleOutPacketType.Task); + } + + #endregion Scene/Avatar to Client // Gesture @@ -3201,7 +3670,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } outPacket.Header.Zerocoded = true; - OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); + OutPacket(outPacket, ThrottleOutPacketType.Task); if (m_primFullUpdates.Count == 0 && m_primFullUpdateTimer.Enabled) lock (m_primFullUpdateTimer) @@ -3291,7 +3760,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP outPacket.Header.Reliable = false; outPacket.Header.Zerocoded = true; - OutPacket(outPacket, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); + OutPacket(outPacket, ThrottleOutPacketType.Task); if (m_primTerseUpdates.Count == 0) lock (m_primTerseUpdateTimer) @@ -4242,6 +4711,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(packet, ThrottleOutPacketType.Task); } + public ulong GetGroupPowers(UUID groupID) + { + if (groupID == m_activeGroupID) + return m_activeGroupPowers; + + if (m_groupPowers.ContainsKey(groupID)) + return m_groupPowers[groupID]; + + return 0; + } + + /// + /// This is a utility method used by single states to not duplicate kicks and blue card of death messages. + /// + public bool ChildAgentStatus() + { + return m_scene.PresenceChildStatus(AgentId); + } + #endregion /// @@ -4260,6 +4748,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); } + #region Packet Handlers + private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) { MoneyTransferRequestPacket money = (MoneyTransferRequestPacket) Pack; @@ -4267,7 +4757,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId && money.AgentData.SessionID == sender.SessionId) { - handlerMoneyTransferRequest = OnMoneyTransferRequest; + MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest; if (handlerMoneyTransferRequest != null) { handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID, @@ -4286,7 +4776,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ParcelBuyPacket parcel = (ParcelBuyPacket) Pack; if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId) { - handlerParcelBuy = OnParcelBuy; + ParcelBuy handlerParcelBuy = OnParcelBuy; if (handlerParcelBuy != null) { handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final, @@ -4307,7 +4797,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < upack.UUIDNameBlock.Length; i++) { - handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest; + UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest; if (handlerUUIDGroupNameRequest != null) { handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this); @@ -4323,7 +4813,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_genericPacketHandlers.Count == 0) return false; if (gmpack.AgentData.SessionID != SessionId) return false; - handlerGenericMessage = null; + GenericMessage handlerGenericMessage = null; string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim(); @@ -4364,7 +4854,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack; if (ogpack.AgentData.SessionID != SessionId) return false; - handlerObjectGroupRequest = OnObjectGroupRequest; + RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest; if (handlerObjectGroupRequest != null) { for (int i = 0; i < ogpack.ObjectData.Length; i++) @@ -4379,7 +4869,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; if (viewer.AgentData.SessionID != SessionId) return false; - handlerViewerEffect = OnViewerEffect; + ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect; if (handlerViewerEffect != null) { int length = viewer.Effect.Length; @@ -4403,6 +4893,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } + #endregion Packet Handlers + public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question) { ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion); @@ -4468,7 +4960,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName); - handlerLogout = OnLogout; + Action handlerLogout = OnLogout; if (handlerLogout != null) { @@ -4550,7 +5042,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case 1: Vector3 pos1 = new Vector3(block.Data, 0); - handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; + UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; if (handlerUpdatePrimSinglePosition != null) { // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); @@ -4560,7 +5052,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case 2: Quaternion rot1 = new Quaternion(block.Data, 0, true); - handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; + UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; if (handlerUpdatePrimSingleRotation != null) { // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W); @@ -4571,7 +5063,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Vector3 rotPos = new Vector3(block.Data, 0); Quaternion rot2 = new Quaternion(block.Data, 12, true); - handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition; + UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition; if (handlerUpdatePrimSingleRotationPosition != null) { // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z); @@ -4583,7 +5075,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case 20: Vector3 scale4 = new Vector3(block.Data, 0); - handlerUpdatePrimScale = OnUpdatePrimScale; + UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale; if (handlerUpdatePrimScale != null) { // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z); @@ -4611,7 +5103,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case 9: Vector3 pos2 = new Vector3(block.Data, 0); - handlerUpdateVector = OnUpdatePrimGroupPosition; + UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition; if (handlerUpdateVector != null) { @@ -4622,7 +5114,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case 10: Quaternion rot3 = new Quaternion(block.Data, 0, true); - handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; + UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; if (handlerUpdatePrimRotation != null) { // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W); @@ -4645,7 +5137,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case 28: Vector3 scale7 = new Vector3(block.Data, 0); - handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; + UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; if (handlerUpdatePrimGroupScale != null) { // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z); @@ -4765,45 +5257,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// - /// returns a byte array of the client set throttles Gets multiplied by the multiplier - /// - /// - /// non 1 multiplier for subdividing the throttles between individual regions - /// - public byte[] GetThrottlesPacked(float multiplier) - { - return m_PacketHandler.PacketQueue.GetThrottlesPacked(multiplier); - } - /// - /// sets the throttles from values supplied by the client + /// Sets the throttles from values supplied by the client /// /// public void SetChildAgentThrottle(byte[] throttles) { - m_PacketHandler.PacketQueue.SetThrottleFromClient(throttles); + m_udpClient.SetThrottles(throttles); + } + + public byte[] GetThrottlesPacked(float multiplier) + { + return m_udpClient.GetThrottlesPacked(); + } + + public bool IsThrottleEmpty(ThrottleOutPacketType category) + { + return m_udpClient.IsThrottleEmpty(category); } /// - /// Method gets called when a new packet has arrived from the UDP - /// server. This happens after it's been decoded into a libsl object. + /// Unused /// - /// object containing the packet. public virtual void InPacket(object NewPack) { - // Cast NewPack to Packet. - m_PacketHandler.InPacket((Packet) NewPack); + throw new NotImplementedException(); } /// - /// This is the starting point for sending a simulator packet out to the client. - /// - /// Please do not call this from outside the LindenUDP client stack. + /// This is the starting point for sending a simulator packet out to the client /// - /// - /// Corresponds to the type of data that is going out. Enum - public void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType) + /// Packet to send + /// Throttling category for the packet + private void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType) { - m_PacketHandler.OutPacket(NewPack, throttlePacketType); + m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); } public bool AddMoney(int debit) @@ -4847,7 +5334,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; } - handlerAutoPilotGo = OnAutoPilotGo; + UpdateVector handlerAutoPilotGo = OnAutoPilotGo; if (handlerAutoPilotGo != null) { handlerAutoPilotGo(0, new Vector3(locx, locy, locz), this); @@ -4899,7 +5386,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRequestAvatarProperties = OnRequestAvatarProperties; + RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties; if (handlerRequestAvatarProperties != null) { handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); @@ -4940,7 +5427,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP args.Sender = this; args.SenderUUID = this.AgentId; - handlerChatFromClient = OnChatFromClient; + ChatMessage handlerChatFromClient = OnChatFromClient; if (handlerChatFromClient != null) handlerChatFromClient(this, args); } @@ -4958,7 +5445,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerUpdateAvatarProperties = OnUpdateAvatarProperties; + UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties; if (handlerUpdateAvatarProperties != null) { AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData; @@ -4998,7 +5485,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP args.Position = new Vector3(); args.Scene = Scene; args.Sender = this; - handlerChatFromClient2 = OnChatFromClient; + ChatMessage handlerChatFromClient2 = OnChatFromClient; if (handlerChatFromClient2 != null) handlerChatFromClient2(this, args); } @@ -5019,7 +5506,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message); - handlerInstantMessage = OnInstantMessage; + ImprovedInstantMessage handlerInstantMessage = OnInstantMessage; if (handlerInstantMessage != null) { @@ -5062,7 +5549,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP callingCardFolders.Add(afriendpack.FolderData[fi].FolderID); } - handlerApproveFriendRequest = OnApproveFriendRequest; + FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest; if (handlerApproveFriendRequest != null) { handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders); @@ -5105,7 +5592,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP UUID listOwnerAgentID = tfriendpack.AgentData.AgentID; UUID exFriendID = tfriendpack.ExBlock.OtherID; - handlerTerminateFriendship = OnTerminateFriendship; + FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship; if (handlerTerminateFriendship != null) { handlerTerminateFriendship(this, listOwnerAgentID, exFriendID); @@ -5124,7 +5611,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRezObject = OnRezObject; + RezObject handlerRezObject = OnRezObject; if (handlerRezObject != null) { handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd, @@ -5147,7 +5634,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDeRezObject = OnDeRezObject; + DeRezObject handlerDeRezObject = OnDeRezObject; if (handlerDeRezObject != null) { List deRezIDs = new List(); @@ -5186,7 +5673,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { for (int i = 0; i < modify.ParcelData.Length; i++) { - handlerModifyTerrain = OnModifyTerrain; + ModifyTerrain handlerModifyTerrain = OnModifyTerrain; if (handlerModifyTerrain != null) { handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, @@ -5203,7 +5690,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.RegionHandshakeReply: - handlerRegionHandShakeReply = OnRegionHandShakeReply; + Action handlerRegionHandShakeReply = OnRegionHandShakeReply; if (handlerRegionHandShakeReply != null) { handlerRegionHandShakeReply(this); @@ -5212,14 +5699,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.AgentWearablesRequest: - handlerRequestWearables = OnRequestWearables; + GenericCall2 handlerRequestWearables = OnRequestWearables; if (handlerRequestWearables != null) { handlerRequestWearables(); } - handlerRequestAvatarsData = OnRequestAvatarsData; + Action handlerRequestAvatarsData = OnRequestAvatarsData; if (handlerRequestAvatarsData != null) { @@ -5240,7 +5727,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerSetAppearance = OnSetAppearance; + SetAppearance handlerSetAppearance = OnSetAppearance; if (handlerSetAppearance != null) { // Temporarily protect ourselves from the mantis #951 failure. @@ -5291,7 +5778,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP wearingArgs.NowWearing.Add(wearable); } - handlerAvatarNowWearing = OnAvatarNowWearing; + AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing; if (handlerAvatarNowWearing != null) { handlerAvatarNowWearing(this, wearingArgs); @@ -5300,7 +5787,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.RezSingleAttachmentFromInv: - handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; + RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; if (handlerRezSingleAttachment != null) { RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; @@ -5321,7 +5808,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.RezMultipleAttachmentsFromInv: - handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; + RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv; if (handlerRezMultipleAttachments != null) { RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack; @@ -5332,7 +5819,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.DetachAttachmentIntoInv: - handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; + UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; if (handlerDetachAttachmentIntoInv != null) { DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; @@ -5362,7 +5849,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectAttach = OnObjectAttach; + ObjectAttach handlerObjectAttach = OnObjectAttach; if (handlerObjectAttach != null) { @@ -5389,7 +5876,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int j = 0; j < dett.ObjectData.Length; j++) { uint obj = dett.ObjectData[j].ObjectLocalID; - handlerObjectDetach = OnObjectDetach; + ObjectDeselect handlerObjectDetach = OnObjectDetach; if (handlerObjectDetach != null) { handlerObjectDetach(obj, this); @@ -5413,7 +5900,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int j = 0; j < dropp.ObjectData.Length; j++) { uint obj = dropp.ObjectData[j].ObjectLocalID; - handlerObjectDrop = OnObjectDrop; + ObjectDrop handlerObjectDrop = OnObjectDrop; if (handlerObjectDrop != null) { handlerObjectDrop(obj, this); @@ -5433,14 +5920,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerSetAlwaysRun = OnSetAlwaysRun; + SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun; if (handlerSetAlwaysRun != null) handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); break; case PacketType.CompleteAgentMovement: - handlerCompleteMovementToRegion = OnCompleteMovementToRegion; + GenericCall2 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; if (handlerCompleteMovementToRegion != null) { handlerCompleteMovementToRegion(); @@ -5509,7 +5996,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP arg.HeadRotation = x.HeadRotation; arg.SessionID = x.SessionID; arg.State = x.State; - handlerAgentUpdate = OnAgentUpdate; + UpdateAgent handlerAgentUpdate = OnAgentUpdate; lastarg = arg; // save this set of arguments for nexttime if (handlerAgentUpdate != null) OnAgentUpdate(this, arg); @@ -5532,8 +6019,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerStartAnim = null; - handlerStopAnim = null; + StartAnim handlerStartAnim = null; + StopAnim handlerStopAnim = null; for (int i = 0; i < AgentAni.AnimationList.Length; i++) { @@ -5570,7 +6057,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerAgentRequestSit = OnAgentRequestSit; + AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; if (handlerAgentRequestSit != null) handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); @@ -5591,7 +6078,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerAgentSit = OnAgentSit; + AgentSit handlerAgentSit = OnAgentSit; if (handlerAgentSit != null) { OnAgentSit(this, agentSit.AgentData.AgentID); @@ -5609,7 +6096,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerSoundTrigger = OnSoundTrigger; + SoundTrigger handlerSoundTrigger = OnSoundTrigger; if (handlerSoundTrigger != null) { handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, soundTriggerPacket.SoundData.OwnerID, @@ -5636,7 +6123,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name)); - handlerAvatarPickerRequest = OnAvatarPickerRequest; + AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest; if (handlerAvatarPickerRequest != null) { handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, @@ -5656,7 +6143,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; + FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; if (handlerAgentDataUpdateRequest != null) { @@ -5666,7 +6153,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.UserInfoRequest: - handlerUserInfoRequest = OnUserInfoRequest; + UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest; if (handlerUserInfoRequest != null) { handlerUserInfoRequest(this); @@ -5689,7 +6176,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerUpdateUserInfo = OnUpdateUserInfo; + UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo; if (handlerUpdateUserInfo != null) { bool visible = true; @@ -5718,7 +6205,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) { - handlerSetStartLocationRequest = OnSetStartLocationRequest; + TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest; if (handlerSetStartLocationRequest != null) { handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, @@ -5740,7 +6227,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - m_PacketHandler.PacketQueue.SetThrottleFromClient(atpack.Throttle.Throttles); + m_udpClient.SetThrottles(atpack.Throttle.Throttles); break; case PacketType.AgentPause: @@ -5756,7 +6243,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.ForceScriptControlRelease: - handlerForceReleaseControls = OnForceReleaseControls; + ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls; if (handlerForceReleaseControls != null) { handlerForceReleaseControls(this, AgentId); @@ -5790,7 +6277,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP childrenprims.Add(link.ObjectData[i].ObjectLocalID); } } - handlerLinkObjects = OnLinkObjects; + LinkObjects handlerLinkObjects = OnLinkObjects; if (handlerLinkObjects != null) { handlerLinkObjects(this, parentprimid, childrenprims); @@ -5818,7 +6305,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { prims.Add(delink.ObjectData[i].ObjectLocalID); } - handlerDelinkObjects = OnDelinkObjects; + DelinkObjects handlerDelinkObjects = OnDelinkObjects; if (handlerDelinkObjects != null) { handlerDelinkObjects(prims); @@ -5850,7 +6337,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP //Check to see if adding the prim is allowed; useful for any module wanting to restrict the //object from rezing initially - handlerAddPrim = OnAddPrim; + AddNewPrim handlerAddPrim = OnAddPrim; if (handlerAddPrim != null) handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); } @@ -5868,7 +6355,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerUpdatePrimShape = null; + UpdateShape handlerUpdatePrimShape = null; for (int i = 0; i < shapePacket.ObjectData.Length; i++) { handlerUpdatePrimShape = OnUpdatePrimShape; @@ -5913,7 +6400,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerUpdateExtraParams = OnUpdateExtraParams; + ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams; if (handlerUpdateExtraParams != null) { for (int i = 0 ; i < extraPar.ObjectData.Length ; i++) @@ -5938,7 +6425,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; - handlerObjectDuplicate = null; + ObjectDuplicate handlerObjectDuplicate = null; for (int i = 0; i < dupe.ObjectData.Length; i++) { @@ -5965,7 +6452,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectRequest = null; + ObjectRequest handlerObjectRequest = null; for (int i = 0; i < incomingRequest.ObjectData.Length; i++) { @@ -5988,7 +6475,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectSelect = null; + ObjectSelect handlerObjectSelect = null; for (int i = 0; i < incomingselect.ObjectData.Length; i++) { @@ -6011,7 +6498,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectDeselect = null; + ObjectDeselect handlerObjectDeselect = null; for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) { @@ -6038,7 +6525,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < position.ObjectData.Length; i++) { - handlerUpdateVector = OnUpdatePrimGroupPosition; + UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition; if (handlerUpdateVector != null) handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this); } @@ -6059,7 +6546,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < scale.ObjectData.Length; i++) { - handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; + UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; if (handlerUpdatePrimGroupScale != null) handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this); } @@ -6080,7 +6567,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < rotation.ObjectData.Length; i++) { - handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; + UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; if (handlerUpdatePrimRotation != null) handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this); } @@ -6098,7 +6585,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerUpdatePrimFlags = OnUpdatePrimFlags; + UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags; if (handlerUpdatePrimFlags != null) { @@ -6115,7 +6602,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.ObjectImage: ObjectImagePacket imagePack = (ObjectImagePacket)Pack; - handlerUpdatePrimTexture = null; + UpdatePrimTexture handlerUpdatePrimTexture = null; for (int i = 0; i < imagePack.ObjectData.Length; i++) { handlerUpdatePrimTexture = OnUpdatePrimTexture; @@ -6138,7 +6625,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerGrabObject = OnGrabObject; + GrabObject handlerGrabObject = OnGrabObject; if (handlerGrabObject != null) { @@ -6172,7 +6659,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerGrabUpdate = OnGrabUpdate; + MoveObject handlerGrabUpdate = OnGrabUpdate; if (handlerGrabUpdate != null) { @@ -6207,7 +6694,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDeGrabObject = OnDeGrabObject; + DeGrabObject handlerDeGrabObject = OnDeGrabObject; if (handlerDeGrabObject != null) { List touchArgs = new List(); @@ -6241,7 +6728,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerSpinStart = OnSpinStart; + SpinStart handlerSpinStart = OnSpinStart; if (handlerSpinStart != null) { handlerSpinStart(spinStart.ObjectData.ObjectID, this); @@ -6265,7 +6752,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle); //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle); - handlerSpinUpdate = OnSpinUpdate; + SpinObject handlerSpinUpdate = OnSpinUpdate; if (handlerSpinUpdate != null) { handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this); @@ -6284,7 +6771,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerSpinStop = OnSpinStop; + SpinStop handlerSpinStop = OnSpinStop; if (handlerSpinStop != null) { handlerSpinStop(spinStop.ObjectData.ObjectID, this); @@ -6303,7 +6790,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectDescription = null; + GenericCall7 handlerObjectDescription = null; for (int i = 0; i < objDes.ObjectData.Length; i++) { @@ -6327,7 +6814,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectName = null; + GenericCall7 handlerObjectName = null; for (int i = 0; i < objName.ObjectData.Length; i++) { handlerObjectName = OnObjectName; @@ -6355,7 +6842,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP UUID AgentID = newobjPerms.AgentData.AgentID; UUID SessionID = newobjPerms.AgentData.SessionID; - handlerObjectPermissions = null; + ObjectPermissions handlerObjectPermissions = null; for (int i = 0; i < newobjPerms.ObjectData.Length; i++) { @@ -6404,7 +6891,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int i = 0; i < undoitem.ObjectData.Length; i++) { UUID objiD = undoitem.ObjectData[i].ObjectID; - handlerOnUndo = OnUndo; + AgentSit handlerOnUndo = OnUndo; if (handlerOnUndo != null) { handlerOnUndo(this, objiD); @@ -6425,8 +6912,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectDuplicateOnRay = null; - + ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null; for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) { @@ -6456,7 +6942,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; - handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; + RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; if (handlerRequestObjectPropertiesFamily != null) { @@ -6468,7 +6954,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.ObjectIncludeInSearch: //This lets us set objects to appear in search (stuff like DataSnapshot, etc) ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; - handlerObjectIncludeInSearch = null; + ObjectIncludeInSearch handlerObjectIncludeInSearch = null; #region Packet Session and User Check if (m_checkPackets) @@ -6505,7 +6991,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerScriptAnswer = OnScriptAnswer; + ScriptAnswer handlerScriptAnswer = OnScriptAnswer; if (handlerScriptAnswer != null) { handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); @@ -6524,7 +7010,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectClickAction = OnObjectClickAction; + GenericCall7 handlerObjectClickAction = OnObjectClickAction; if (handlerObjectClickAction != null) { foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData) @@ -6548,7 +7034,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectMaterial = OnObjectMaterial; + GenericCall7 handlerObjectMaterial = OnObjectMaterial; if (handlerObjectMaterial != null) { foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData) @@ -6702,7 +7188,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); - handlerAssetUploadRequest = OnAssetUploadRequest; + UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest; if (handlerAssetUploadRequest != null) { @@ -6715,7 +7201,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.RequestXfer: RequestXferPacket xferReq = (RequestXferPacket)Pack; - handlerRequestXfer = OnRequestXfer; + RequestXfer handlerRequestXfer = OnRequestXfer; if (handlerRequestXfer != null) { @@ -6725,7 +7211,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.SendXferPacket: SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; - handlerXferReceive = OnXferReceive; + XferReceive handlerXferReceive = OnXferReceive; if (handlerXferReceive != null) { handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); @@ -6734,7 +7220,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.ConfirmXferPacket: ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; - handlerConfirmXfer = OnConfirmXfer; + ConfirmXfer handlerConfirmXfer = OnConfirmXfer; if (handlerConfirmXfer != null) { handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); @@ -6742,7 +7228,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; case PacketType.AbortXfer: AbortXferPacket abortXfer = (AbortXferPacket)Pack; - handlerAbortXfer = OnAbortXfer; + AbortXfer handlerAbortXfer = OnAbortXfer; if (handlerAbortXfer != null) { handlerAbortXfer(this, abortXfer.XferID.ID); @@ -6761,7 +7247,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerCreateInventoryFolder = OnCreateNewInventoryFolder; + CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder; if (handlerCreateInventoryFolder != null) { handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID, @@ -6784,7 +7270,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerUpdateInventoryFolder = null; + UpdateInventoryFolder handlerUpdateInventoryFolder = null; for (int i = 0; i < invFolderx.FolderData.Length; i++) { @@ -6813,7 +7299,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerMoveInventoryFolder = null; + MoveInventoryFolder handlerMoveInventoryFolder = null; for (int i = 0; i < invFoldery.InventoryData.Length; i++) { @@ -6838,7 +7324,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerCreateNewInventoryItem = OnCreateNewInventoryItem; + CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem; if (handlerCreateNewInventoryItem != null) { handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, @@ -6867,7 +7353,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerFetchInventory = null; + FetchInventory handlerFetchInventory = null; for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++) { @@ -6893,7 +7379,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerFetchInventoryDescendents = OnFetchInventoryDescendents; + FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents; if (handlerFetchInventoryDescendents != null) { handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, @@ -6913,7 +7399,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; + PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; if (handlerPurgeInventoryDescendents != null) { handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); @@ -6933,7 +7419,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnUpdateInventoryItem != null) { - handlerUpdateInventoryItem = null; + UpdateInventoryItem handlerUpdateInventoryItem = null; for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) { handlerUpdateInventoryItem = OnUpdateInventoryItem; @@ -6955,49 +7441,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice; itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType; itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags; - /* - OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, - inventoryItemUpdate.InventoryData[i].ItemID, - Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name), - Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description), - inventoryItemUpdate.InventoryData[i].NextOwnerMask); - */ + OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID, inventoryItemUpdate.InventoryData[i].ItemID, itemUpd); } } } - //m_log.Debug(Pack.ToString()); - /*for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++) - { - if (inventoryItemUpdate.InventoryData[i].TransactionID != UUID.Zero) - { - AssetBase asset = m_assetCache.GetAsset(inventoryItemUpdate.InventoryData[i].TransactionID.Combine(this.SecureSessionId)); - if (asset != null) - { - // m_log.Debug("updating inventory item, found asset" + asset.FullID.ToString() + " already in cache"); - m_inventoryCache.UpdateInventoryItemAsset(this, inventoryItemUpdate.InventoryData[i].ItemID, asset); - } - else - { - asset = this.UploadAssets.AddUploadToAssetCache(inventoryItemUpdate.InventoryData[i].TransactionID); - if (asset != null) - { - //m_log.Debug("updating inventory item, adding asset" + asset.FullID.ToString() + " to cache"); - m_inventoryCache.UpdateInventoryItemAsset(this, inventoryItemUpdate.InventoryData[i].ItemID, asset); - } - else - { - //m_log.Debug("trying to update inventory item, but asset is null"); - } - } - } - else - { - m_inventoryCache.UpdateInventoryItemDetails(this, inventoryItemUpdate.InventoryData[i].ItemID, inventoryItemUpdate.InventoryData[i]); ; - } - }*/ break; case PacketType.CopyInventoryItem: CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; @@ -7011,7 +7461,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerCopyInventoryItem = null; + CopyInventoryItem handlerCopyInventoryItem = null; if (OnCopyInventoryItem != null) { foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) @@ -7040,7 +7490,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnMoveInventoryItem != null) { - handlerMoveInventoryItem = null; + MoveInventoryItem handlerMoveInventoryItem = null; InventoryItemBase itm = null; List items = new List(); foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) @@ -7073,7 +7523,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnRemoveInventoryItem != null) { - handlerRemoveInventoryItem = null; + RemoveInventoryItem handlerRemoveInventoryItem = null; List uuids = new List(); foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) { @@ -7101,7 +7551,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnRemoveInventoryFolder != null) { - handlerRemoveInventoryFolder = null; + RemoveInventoryFolder handlerRemoveInventoryFolder = null; List uuids = new List(); foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) { @@ -7126,7 +7576,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion if (OnRemoveInventoryFolder != null) { - handlerRemoveInventoryFolder = null; + RemoveInventoryFolder handlerRemoveInventoryFolder = null; List uuids = new List(); foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData) { @@ -7141,7 +7591,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (OnRemoveInventoryItem != null) { - handlerRemoveInventoryItem = null; + RemoveInventoryItem handlerRemoveInventoryItem = null; List uuids = new List(); foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData) { @@ -7166,7 +7616,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRequestTaskInventory = OnRequestTaskInventory; + RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory; if (handlerRequestTaskInventory != null) { handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); @@ -7188,7 +7638,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (updatetask.UpdateData.Key == 0) { - handlerUpdateTaskInventory = OnUpdateTaskInventory; + UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory; if (handlerUpdateTaskInventory != null) { TaskInventoryItem newTaskItem = new TaskInventoryItem(); @@ -7232,7 +7682,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRemoveTaskItem = OnRemoveTaskItem; + RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem; if (handlerRemoveTaskItem != null) { @@ -7254,7 +7704,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerMoveTaskItem = OnMoveTaskItem; + MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem; if (handlerMoveTaskItem != null) { @@ -7279,7 +7729,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRezScript = OnRezScript; + RezScript handlerRezScript = OnRezScript; InventoryItemBase item = new InventoryItemBase(); item.ID = rezScriptx.InventoryBlock.ItemID; item.Folder = rezScriptx.InventoryBlock.FolderID; @@ -7322,7 +7772,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRequestMapBlocks = OnRequestMapBlocks; + RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks; if (handlerRequestMapBlocks != null) { handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, @@ -7343,7 +7793,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP string mapName = Util.UTF8.GetString(map.NameData.Name, 0, map.NameData.Name.Length - 1); - handlerMapNameRequest = OnMapNameRequest; + RequestMapName handlerMapNameRequest = OnMapNameRequest; if (handlerMapNameRequest != null) { handlerMapNameRequest(this, mapName); @@ -7394,7 +7844,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP else { // Teleport home request - handlerTeleportHomeRequest = OnTeleportHomeRequest; + UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest; if (handlerTeleportHomeRequest != null) { handlerTeleportHomeRequest(AgentId, this); @@ -7402,7 +7852,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP break; } - handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; + TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; if (handlerTeleportLandmarkRequest != null) { handlerTeleportLandmarkRequest(this, lm.RegionID, lm.Position); @@ -7433,7 +7883,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerTeleportLocationRequest = OnTeleportLocationRequest; + TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest; if (handlerTeleportLocationRequest != null) { handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, @@ -7456,7 +7906,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) { - handlerNameRequest = OnNameFromUUIDRequest; + UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest; if (handlerNameRequest != null) { handlerNameRequest(UUIDBlock.ID, this); @@ -7469,7 +7919,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.RegionHandleRequest: RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack; - handlerRegionHandleRequest = OnRegionHandleRequest; + RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest; if (handlerRegionHandleRequest != null) { handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID); @@ -7488,7 +7938,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelInfoRequest = OnParcelInfoRequest; + ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest; if (handlerParcelInfoRequest != null) { handlerParcelInfoRequest(this, pirPack.Data.ParcelID); @@ -7507,7 +7957,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelAccessListRequest = OnParcelAccessListRequest; + ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest; if (handlerParcelAccessListRequest != null) { @@ -7539,7 +7989,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP entries.Add(entry); } - handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; + ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; if (handlerParcelAccessListUpdateRequest != null) { handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, @@ -7560,7 +8010,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelPropertiesRequest = OnParcelPropertiesRequest; + ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest; if (handlerParcelPropertiesRequest != null) { handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), @@ -7583,7 +8033,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelDivideRequest = OnParcelDivideRequest; + ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest; if (handlerParcelDivideRequest != null) { handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), @@ -7604,7 +8054,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelJoinRequest = OnParcelJoinRequest; + ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest; if (handlerParcelJoinRequest != null) { @@ -7626,7 +8076,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; + ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; if (handlerParcelPropertiesUpdateRequest != null) { @@ -7672,7 +8122,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP returnIDs.Add(rb.ReturnID); } - handlerParcelSelectObjects = OnParcelSelectObjects; + ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects; if (handlerParcelSelectObjects != null) { @@ -7693,7 +8143,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; + ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; if (handlerParcelObjectOwnerRequest != null) { @@ -7712,7 +8162,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelGodForceOwner = OnParcelGodForceOwner; + ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner; if (handlerParcelGodForceOwner != null) { handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this); @@ -7730,7 +8180,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelAbandonRequest = OnParcelAbandonRequest; + ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest; if (handlerParcelAbandonRequest != null) { handlerParcelAbandonRequest(releasePacket.Data.LocalID, this); @@ -7748,7 +8198,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelReclaim = OnParcelReclaim; + ParcelReclaim handlerParcelReclaim = OnParcelReclaim; if (handlerParcelReclaim != null) { handlerParcelReclaim(reclaimPacket.Data.LocalID, this); @@ -7777,7 +8227,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++) puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID; - handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest; + ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest; if (handlerParcelReturnObjectsRequest != null) { handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this); @@ -7797,7 +8247,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime; + ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime; if (handlerParcelSetOtherCleanTime != null) { handlerParcelSetOtherCleanTime(this, @@ -7818,7 +8268,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerLandStatRequest = OnLandStatRequest; + GodLandStatRequest handlerLandStatRequest = OnLandStatRequest; if (handlerLandStatRequest != null) { handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this); @@ -7838,7 +8288,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerParcelDwellRequest = OnParcelDwellRequest; + ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest; if (handlerParcelDwellRequest != null) { handlerParcelDwellRequest(dwellrq.Data.LocalID, this); @@ -8082,7 +8532,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake") { - handlerBakeTerrain = OnBakeTerrain; + BakeTerrain handlerBakeTerrain = OnBakeTerrain; if (handlerBakeTerrain != null) { handlerBakeTerrain(this); @@ -8092,7 +8542,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (messagePacket.ParamList.Length > 1) { - handlerRequestTerrain = OnRequestTerrain; + RequestTerrain handlerRequestTerrain = OnRequestTerrain; if (handlerRequestTerrain != null) { handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); @@ -8103,7 +8553,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { if (messagePacket.ParamList.Length > 1) { - handlerUploadTerrain = OnUploadTerrain; + RequestTerrain handlerUploadTerrain = OnUploadTerrain; if (handlerUploadTerrain != null) { handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter)); @@ -8125,7 +8575,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter)); - handlerEstateChangeInfo = OnEstateChangeInfo; + EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo; if (handlerEstateChangeInfo != null) { handlerEstateChangeInfo(this, invoice, SenderID, param1, param2); @@ -8159,7 +8609,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRegionInfoRequest = OnRegionInfoRequest; + RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest; if (handlerRegionInfoRequest != null) { handlerRegionInfoRequest(this); @@ -8170,7 +8620,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP //EstateCovenantRequestPacket.AgentDataBlock epack = // ((EstateCovenantRequestPacket)Pack).AgentData; - handlerEstateCovenantRequest = OnEstateCovenantRequest; + EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest; if (handlerEstateCovenantRequest != null) { handlerEstateCovenantRequest(this); @@ -8188,7 +8638,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; - handlerReqGodlikePowers = OnRequestGodlikePowers; + RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers; if (handlerReqGodlikePowers != null) { @@ -8201,7 +8651,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) { - handlerGodKickUser = OnGodKickUser; + GodKickUser handlerGodKickUser = OnGodKickUser; if (handlerGodKickUser != null) { handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, @@ -8241,7 +8691,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerMoneyBalanceRequest = OnMoneyBalanceRequest; + MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest; if (handlerMoneyBalanceRequest != null) { @@ -8252,7 +8702,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.EconomyDataRequest: - handlerEconomoyDataRequest = OnEconomyDataRequest; + EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest; if (handlerEconomoyDataRequest != null) { handlerEconomoyDataRequest(AgentId); @@ -8261,7 +8711,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.RequestPayPrice: RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; - handlerRequestPayPrice = OnRequestPayPrice; + RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice; if (handlerRequestPayPrice != null) { handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); @@ -8280,7 +8730,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectSaleInfo = OnObjectSaleInfo; + ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo; if (handlerObjectSaleInfo != null) { foreach (ObjectSaleInfoPacket.ObjectDataBlock d @@ -8308,7 +8758,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerObjectBuy = OnObjectBuy; + ObjectBuy handlerObjectBuy = OnObjectBuy; if (handlerObjectBuy != null) { @@ -8334,7 +8784,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP case PacketType.GetScriptRunning: GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack; - handlerGetScriptRunning = OnGetScriptRunning; + GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning; if (handlerGetScriptRunning != null) { handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID); @@ -8353,7 +8803,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerSetScriptRunning = OnSetScriptRunning; + SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning; if (handlerSetScriptRunning != null) { handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running); @@ -8372,7 +8822,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerScriptReset = OnScriptReset; + ScriptReset handlerScriptReset = OnScriptReset; if (handlerScriptReset != null) { handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID); @@ -8395,7 +8845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerActivateGesture = OnActivateGesture; + ActivateGesture handlerActivateGesture = OnActivateGesture; if (handlerActivateGesture != null) { handlerActivateGesture(this, @@ -8418,7 +8868,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDeactivateGesture = OnDeactivateGesture; + DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture; if (handlerDeactivateGesture != null) { handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID); @@ -8441,7 +8891,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData) localIDs.Add(d.ObjectLocalID); - handlerObjectOwner = OnObjectOwner; + ObjectOwner handlerObjectOwner = OnObjectOwner; if (handlerObjectOwner != null) { handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs); @@ -8482,7 +8932,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion //m_log.Debug(mirpk.ToString()); - handlerMapItemRequest = OnMapItemRequest; + MapItemRequest handlerMapItemRequest = OnMapItemRequest; if (handlerMapItemRequest != null) { handlerMapItemRequest(this,mirpk.AgentData.Flags, mirpk.AgentData.EstateID, @@ -8509,7 +8959,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerMuteListRequest = OnMuteListRequest; + MuteListRequest handlerMuteListRequest = OnMuteListRequest; if (handlerMuteListRequest != null) { handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC); @@ -8546,7 +8996,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDirPlacesQuery = OnDirPlacesQuery; + DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery; if (handlerDirPlacesQuery != null) { handlerDirPlacesQuery(this, @@ -8572,7 +9022,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDirFindQuery = OnDirFindQuery; + DirFindQuery handlerDirFindQuery = OnDirFindQuery; if (handlerDirFindQuery != null) { handlerDirFindQuery(this, @@ -8595,7 +9045,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDirLandQuery = OnDirLandQuery; + DirLandQuery handlerDirLandQuery = OnDirLandQuery; if (handlerDirLandQuery != null) { handlerDirLandQuery(this, @@ -8619,7 +9069,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDirPopularQuery = OnDirPopularQuery; + DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery; if (handlerDirPopularQuery != null) { handlerDirPopularQuery(this, @@ -8639,7 +9089,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerDirClassifiedQuery = OnDirClassifiedQuery; + DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery; if (handlerDirClassifiedQuery != null) { handlerDirClassifiedQuery(this, @@ -9155,7 +9605,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack; if (m_GroupsModule != null) { - handlerParcelDeedToGroup = OnParcelDeedToGroup; + ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup; if (handlerParcelDeedToGroup != null) { handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID,this); @@ -9399,7 +9849,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerStartLure = OnStartLure; + StartLure handlerStartLure = OnStartLure; if (handlerStartLure != null) handlerStartLure(startLureRequest.Info.LureType, Utils.BytesToString( @@ -9421,7 +9871,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerTeleportLureRequest = OnTeleportLureRequest; + TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest; if (handlerTeleportLureRequest != null) handlerTeleportLureRequest( teleportLureRequest.Info.LureID, @@ -9442,7 +9892,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerClassifiedInfoRequest = OnClassifiedInfoRequest; + ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest; if (handlerClassifiedInfoRequest != null) handlerClassifiedInfoRequest( classifiedInfoRequest.Data.ClassifiedID, @@ -9462,7 +9912,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate; + ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate; if (handlerClassifiedInfoUpdate != null) handlerClassifiedInfoUpdate( classifiedInfoUpdate.Data.ClassifiedID, @@ -9494,7 +9944,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerClassifiedDelete = OnClassifiedDelete; + ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete; if (handlerClassifiedDelete != null) handlerClassifiedDelete( classifiedDelete.Data.ClassifiedID, @@ -9514,7 +9964,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerClassifiedGodDelete = OnClassifiedGodDelete; + ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete; if (handlerClassifiedGodDelete != null) handlerClassifiedGodDelete( classifiedGodDelete.Data.ClassifiedID, @@ -9534,7 +9984,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerEventGodDelete = OnEventGodDelete; + EventGodDelete handlerEventGodDelete = OnEventGodDelete; if (handlerEventGodDelete != null) handlerEventGodDelete( eventGodDelete.EventData.EventID, @@ -9559,7 +10009,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerEventNotificationAddRequest = OnEventNotificationAddRequest; + EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest; if (handlerEventNotificationAddRequest != null) handlerEventNotificationAddRequest( eventNotificationAdd.EventData.EventID, this); @@ -9578,7 +10028,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest; + EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest; if (handlerEventNotificationRemoveRequest != null) handlerEventNotificationRemoveRequest( eventNotificationRemove.EventData.EventID, this); @@ -9596,7 +10046,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerRetrieveInstantMessages = OnRetrieveInstantMessages; + RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages; if (handlerRetrieveInstantMessages != null) handlerRetrieveInstantMessages(this); break; @@ -9614,7 +10064,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerPickDelete = OnPickDelete; + PickDelete handlerPickDelete = OnPickDelete; if (handlerPickDelete != null) handlerPickDelete(this, pickDelete.Data.PickID); break; @@ -9631,7 +10081,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerPickGodDelete = OnPickGodDelete; + PickGodDelete handlerPickGodDelete = OnPickGodDelete; if (handlerPickGodDelete != null) handlerPickGodDelete(this, pickGodDelete.AgentData.AgentID, @@ -9651,7 +10101,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerPickInfoUpdate = OnPickInfoUpdate; + PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate; if (handlerPickInfoUpdate != null) handlerPickInfoUpdate(this, pickInfoUpdate.Data.PickID, @@ -9676,7 +10126,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #endregion - handlerAvatarNotesUpdate = OnAvatarNotesUpdate; + AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate; if (handlerAvatarNotesUpdate != null) handlerAvatarNotesUpdate(this, avatarNotesUpdate.Data.TargetID, @@ -9693,7 +10143,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP PlacesQueryPacket placesQueryPacket = (PlacesQueryPacket)Pack; - handlerPlacesQuery = OnPlacesQuery; + PlacesQuery handlerPlacesQuery = OnPlacesQuery; if (handlerPlacesQuery != null) handlerPlacesQuery(placesQueryPacket.AgentData.QueryID, @@ -9747,291 +10197,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP //shape.Textures = ntex; return shape; } - - /// - /// Send the client an Estate message blue box pop-down with a single OK button - /// - /// - /// - /// - /// - public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message) - { - if (!ChildAgentStatus()) - SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3())); - - //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch()); - } - - public void SendLogoutPacket() - { - // I know this is a bit of a hack, however there are times when you don't - // want to send this, but still need to do the rest of the shutdown process - // this method gets called from the packet server.. which makes it practically - // impossible to do any other way. - - if (m_SendLogoutPacketWhenClosing) - { - LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); - // TODO: don't create new blocks if recycling an old packet - logReply.AgentData.AgentID = AgentId; - logReply.AgentData.SessionID = SessionId; - logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; - logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); - logReply.InventoryData[0].ItemID = UUID.Zero; - - OutPacket(logReply, ThrottleOutPacketType.Task); - } - } - - public void SendHealth(float health) - { - HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage); - healthpacket.HealthData.Health = health; - OutPacket(healthpacket, ThrottleOutPacketType.Task); - } - - public void SendAgentOnline(UUID[] agentIDs) - { - OnlineNotificationPacket onp = new OnlineNotificationPacket(); - OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length]; - for (int i = 0; i < agentIDs.Length; i++) - { - OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock(); - onpbl.AgentID = agentIDs[i]; - onpb[i] = onpbl; - } - onp.AgentBlock = onpb; - onp.Header.Reliable = true; - OutPacket(onp, ThrottleOutPacketType.Task); - } - - public void SendAgentOffline(UUID[] agentIDs) - { - OfflineNotificationPacket offp = new OfflineNotificationPacket(); - OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length]; - for (int i = 0; i < agentIDs.Length; i++) - { - OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock(); - onpbl.AgentID = agentIDs[i]; - offpb[i] = onpbl; - } - offp.AgentBlock = offpb; - offp.Header.Reliable = true; - OutPacket(offp, ThrottleOutPacketType.Task); - } - - public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, - Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) - { - AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); - avatarSitResponse.SitObject.ID = TargetID; - if (CameraAtOffset != Vector3.Zero) - { - avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset; - avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset; - } - avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook; - avatarSitResponse.SitTransform.AutoPilot = autopilot; - avatarSitResponse.SitTransform.SitPosition = OffsetPos; - avatarSitResponse.SitTransform.SitRotation = SitOrientation; - - OutPacket(avatarSitResponse, ThrottleOutPacketType.Task); - } - - public void SendAdminResponse(UUID Token, uint AdminLevel) - { - GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket(); - GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock(); - GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock(); - - adb.AgentID = AgentId; - adb.SessionID = SessionId; // More security - gdb.GodLevel = (byte)AdminLevel; - gdb.Token = Token; - //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock; - respondPacket.GrantData = gdb; - respondPacket.AgentData = adb; - OutPacket(respondPacket, ThrottleOutPacketType.Task); - } - - public void SendGroupMembership(GroupMembershipData[] GroupMembership) - { - m_groupPowers.Clear(); - - AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket(); - AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length]; - for (int i = 0; i < GroupMembership.Length; i++) - { - m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers; - - AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock(); - Group.AcceptNotices = GroupMembership[i].AcceptNotices; - Group.Contribution = GroupMembership[i].Contribution; - Group.GroupID = GroupMembership[i].GroupID; - Group.GroupInsigniaID = GroupMembership[i].GroupPicture; - Group.GroupName = Utils.StringToBytes(GroupMembership[i].GroupName); - Group.GroupPowers = GroupMembership[i].GroupPowers; - Groups[i] = Group; - - - } - Groupupdate.GroupData = Groups; - Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock(); - Groupupdate.AgentData.AgentID = AgentId; - OutPacket(Groupupdate, ThrottleOutPacketType.Task); - - try - { - IEventQueue eq = Scene.RequestModuleInterface(); - if (eq != null) - { - eq.GroupMembership(Groupupdate, this.AgentId); - } - } - catch (Exception ex) - { - m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString()); - m_log.Warn("sending group membership data via UDP"); - OutPacket(Groupupdate, ThrottleOutPacketType.Task); - } - } - - - public void SendGroupNameReply(UUID groupLLUID, string GroupName) - { - UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket(); - UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1]; - UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock(); - uidnamebloc.ID = groupLLUID; - uidnamebloc.GroupName = Utils.StringToBytes(GroupName); - uidnameblock[0] = uidnamebloc; - pack.UUIDNameBlock = uidnameblock; - OutPacket(pack, ThrottleOutPacketType.Task); - } - - public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) - { - LandStatReplyPacket lsrp = new LandStatReplyPacket(); - // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock(); - LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length]; - //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); - // lsrepdb. - lsrp.RequestData.ReportType = reportType; - lsrp.RequestData.RequestFlags = requestFlags; - lsrp.RequestData.TotalObjectCount = resultCount; - for (int i = 0; i < lsrpia.Length; i++) - { - LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock(); - lsrepdb.LocationX = lsrpia[i].LocationX; - lsrepdb.LocationY = lsrpia[i].LocationY; - lsrepdb.LocationZ = lsrpia[i].LocationZ; - lsrepdb.Score = lsrpia[i].Score; - lsrepdb.TaskID = lsrpia[i].TaskID; - lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID; - lsrepdb.TaskName = Utils.StringToBytes(lsrpia[i].TaskName); - lsrepdb.OwnerName = Utils.StringToBytes(lsrpia[i].OwnerName); - lsrepdba[i] = lsrepdb; - } - lsrp.ReportData = lsrepdba; - OutPacket(lsrp, ThrottleOutPacketType.Task); - } - - public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running) - { - ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket(); - scriptRunningReply.Script.ObjectID = objectID; - scriptRunningReply.Script.ItemID = itemID; - scriptRunningReply.Script.Running = running; - - OutPacket(scriptRunningReply, ThrottleOutPacketType.Task); - } - - public void SendAsset(AssetRequestToClient req) - { - //m_log.Debug("sending asset " + req.RequestAssetID); - TransferInfoPacket Transfer = new TransferInfoPacket(); - Transfer.TransferInfo.ChannelType = 2; - Transfer.TransferInfo.Status = 0; - Transfer.TransferInfo.TargetType = 0; - if (req.AssetRequestSource == 2) - { - Transfer.TransferInfo.Params = new byte[20]; - Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - int assType = req.AssetInf.Type; - Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); - } - else if (req.AssetRequestSource == 3) - { - Transfer.TransferInfo.Params = req.Params; - // Transfer.TransferInfo.Params = new byte[100]; - //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); - //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); - } - Transfer.TransferInfo.Size = req.AssetInf.Data.Length; - Transfer.TransferInfo.TransferID = req.TransferRequestID; - Transfer.Header.Zerocoded = true; - OutPacket(Transfer, ThrottleOutPacketType.Asset); - - if (req.NumPackets == 1) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = 0; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - TransferPacket.TransferData.Data = req.AssetInf.Data; - TransferPacket.TransferData.Status = 1; - TransferPacket.Header.Zerocoded = true; - OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - } - else - { - int processedLength = 0; - int maxChunkSize = Settings.MAX_PACKET_SIZE - 100; - int packetNumber = 0; - - while (processedLength < req.AssetInf.Data.Length) - { - TransferPacketPacket TransferPacket = new TransferPacketPacket(); - TransferPacket.TransferData.Packet = packetNumber; - TransferPacket.TransferData.ChannelType = 2; - TransferPacket.TransferData.TransferID = req.TransferRequestID; - - int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); - byte[] chunk = new byte[chunkSize]; - Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); - - TransferPacket.TransferData.Data = chunk; - - // 0 indicates more packets to come, 1 indicates last packet - if (req.AssetInf.Data.Length - processedLength > maxChunkSize) - { - TransferPacket.TransferData.Status = 0; - } - else - { - TransferPacket.TransferData.Status = 1; - } - TransferPacket.Header.Zerocoded = true; - OutPacket(TransferPacket, ThrottleOutPacketType.Asset); - - processedLength += chunkSize; - packetNumber++; - } - } - } - - public void SendTexture(AssetBase TextureAsset) - { - - } - + public ClientInfo GetClientInfo() { - ClientInfo info = m_PacketHandler.GetClientInfo(); + ClientInfo info = m_udpClient.GetClientInfo(); info.userEP = m_userEndPoint; - info.proxyEP = m_proxyEndPoint; + info.proxyEP = null; info.agentcircuit = new sAgentCircuitData(RequestClientInfo()); return info; @@ -10044,7 +10216,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SetClientInfo(ClientInfo info) { - m_PacketHandler.SetClientInfo(info); + m_udpClient.SetClientInfo(info); } #region Media Parcel Members @@ -10079,7 +10251,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion - #region Camera public void SendSetFollowCamProperties (UUID objectID, SortedDictionary parameters) @@ -10109,70 +10280,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion - public void SendRegionHandle(UUID regionID, ulong handle) { - RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply); - reply.ReplyBlock.RegionID = regionID; - reply.ReplyBlock.RegionHandle = handle; - OutPacket(reply, ThrottleOutPacketType.Land); - } - - public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y) - { - ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply); - reply.AgentData.AgentID = m_agentId; - reply.Data.ParcelID = parcelID; - reply.Data.OwnerID = land.OwnerID; - reply.Data.Name = Utils.StringToBytes(land.Name); - reply.Data.Desc = Utils.StringToBytes(land.Description); - reply.Data.ActualArea = land.Area; - reply.Data.BillableArea = land.Area; // TODO: what is this? - - // Bit 0: Mature, bit 7: on sale, other bits: no idea - reply.Data.Flags = (byte)( - ((land.Flags & (uint)ParcelFlags.MaturePublish) != 0 ? (1 << 0) : 0) + - ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0)); - - Vector3 pos = land.UserLocation; - if (pos.Equals(Vector3.Zero)) - { - pos = (land.AABBMax + land.AABBMin) * 0.5f; - } - reply.Data.GlobalX = info.RegionLocX * Constants.RegionSize + x; - reply.Data.GlobalY = info.RegionLocY * Constants.RegionSize + y; - reply.Data.GlobalZ = pos.Z; - reply.Data.SimName = Utils.StringToBytes(info.RegionName); - reply.Data.SnapshotID = land.SnapshotID; - reply.Data.Dwell = land.Dwell; - reply.Data.SalePrice = land.SalePrice; - reply.Data.AuctionID = (int)land.AuctionID; - - OutPacket(reply, ThrottleOutPacketType.Land); - } - - public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt) - { - ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest); - - packet.Data.ObjectName = Utils.StringToBytes(objName); - packet.Data.SimName = Utils.StringToBytes(simName); - packet.Data.SimPosition = pos; - packet.Data.LookAt = lookAt; - - OutPacket(packet, ThrottleOutPacketType.Task); - } - public void SetClientOption(string option, string value) { switch (option) { - case "ReliableIsImportant": - bool val; - - if (bool.TryParse(value, out val)) - m_PacketHandler.ReliableIsImportant = val; - break; - default: - break; + default: + break; } } @@ -10180,571 +10293,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP { switch (option) { - case "ReliableIsImportant": - return m_PacketHandler.ReliableIsImportant.ToString(); - default: break; } return string.Empty; } - public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data) - { - DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply); - - packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock(); - - packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1]; - packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock(); - - packet.QueryReplies = - new DirPlacesReplyPacket.QueryRepliesBlock[data.Length]; - - packet.StatusData = new DirPlacesReplyPacket.StatusDataBlock[ - data.Length]; - - packet.AgentData.AgentID = AgentId; - - packet.QueryData[0].QueryID = queryID; - - int i = 0; - foreach (DirPlacesReplyData d in data) - { - packet.QueryReplies[i] = - new DirPlacesReplyPacket.QueryRepliesBlock(); - packet.StatusData[i] = new DirPlacesReplyPacket.StatusDataBlock(); - packet.QueryReplies[i].ParcelID = d.parcelID; - packet.QueryReplies[i].Name = Utils.StringToBytes(d.name); - packet.QueryReplies[i].ForSale = d.forSale; - packet.QueryReplies[i].Auction = d.auction; - packet.QueryReplies[i].Dwell = d.dwell; - packet.StatusData[i].Status = d.Status; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data) - { - DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply); - - packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock(); - packet.QueryData.QueryID = queryID; - - packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[ - data.Length]; - - int i = 0; - foreach (DirPeopleReplyData d in data) - { - packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock(); - packet.QueryReplies[i].AgentID = d.agentID; - packet.QueryReplies[i].FirstName = - Utils.StringToBytes(d.firstName); - packet.QueryReplies[i].LastName = - Utils.StringToBytes(d.lastName); - packet.QueryReplies[i].Group = - Utils.StringToBytes(d.group); - packet.QueryReplies[i].Online = d.online; - packet.QueryReplies[i].Reputation = d.reputation; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data) - { - DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply); - - packet.AgentData = new DirEventsReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.QueryData = new DirEventsReplyPacket.QueryDataBlock(); - packet.QueryData.QueryID = queryID; - - packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[ - data.Length]; - - packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[ - data.Length]; - - int i = 0; - foreach (DirEventsReplyData d in data) - { - packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock(); - packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock(); - packet.QueryReplies[i].OwnerID = d.ownerID; - packet.QueryReplies[i].Name = - Utils.StringToBytes(d.name); - packet.QueryReplies[i].EventID = d.eventID; - packet.QueryReplies[i].Date = - Utils.StringToBytes(d.date); - packet.QueryReplies[i].UnixTime = d.unixTime; - packet.QueryReplies[i].EventFlags = d.eventFlags; - packet.StatusData[i].Status = d.Status; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data) - { - DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply); - - packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock(); - packet.QueryData.QueryID = queryID; - - packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[ - data.Length]; - - int i = 0; - foreach (DirGroupsReplyData d in data) - { - packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock(); - packet.QueryReplies[i].GroupID = d.groupID; - packet.QueryReplies[i].GroupName = - Utils.StringToBytes(d.groupName); - packet.QueryReplies[i].Members = d.members; - packet.QueryReplies[i].SearchOrder = d.searchOrder; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data) - { - DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply); - - packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock(); - packet.QueryData.QueryID = queryID; - - packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[ - data.Length]; - packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[ - data.Length]; - - int i = 0; - foreach (DirClassifiedReplyData d in data) - { - packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock(); - packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock(); - packet.QueryReplies[i].ClassifiedID = d.classifiedID; - packet.QueryReplies[i].Name = - Utils.StringToBytes(d.name); - packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags; - packet.QueryReplies[i].CreationDate = d.creationDate; - packet.QueryReplies[i].ExpirationDate = d.expirationDate; - packet.QueryReplies[i].PriceForListing = d.price; - packet.StatusData[i].Status = d.Status; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendDirLandReply(UUID queryID, DirLandReplyData[] data) - { - DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply); - - packet.AgentData = new DirLandReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.QueryData = new DirLandReplyPacket.QueryDataBlock(); - packet.QueryData.QueryID = queryID; - - packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[ - data.Length]; - - int i = 0; - foreach (DirLandReplyData d in data) - { - packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock(); - packet.QueryReplies[i].ParcelID = d.parcelID; - packet.QueryReplies[i].Name = - Utils.StringToBytes(d.name); - packet.QueryReplies[i].Auction = d.auction; - packet.QueryReplies[i].ForSale = d.forSale; - packet.QueryReplies[i].SalePrice = d.salePrice; - packet.QueryReplies[i].ActualArea = d.actualArea; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data) - { - DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply); - - packet.AgentData = new DirPopularReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.QueryData = new DirPopularReplyPacket.QueryDataBlock(); - packet.QueryData.QueryID = queryID; - - packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[ - data.Length]; - - int i = 0; - foreach (DirPopularReplyData d in data) - { - packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock(); - packet.QueryReplies[i].ParcelID = d.parcelID; - packet.QueryReplies[i].Name = - Utils.StringToBytes(d.name); - packet.QueryReplies[i].Dwell = d.dwell; - i++; - } - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendEventInfoReply(EventData data) - { - EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply); - - packet.AgentData = new EventInfoReplyPacket.AgentDataBlock(); - packet.AgentData.AgentID = AgentId; - - packet.EventData = new EventInfoReplyPacket.EventDataBlock(); - packet.EventData.EventID = data.eventID; - packet.EventData.Creator = Utils.StringToBytes(data.creator); - packet.EventData.Name = Utils.StringToBytes(data.name); - packet.EventData.Category = Utils.StringToBytes(data.category); - packet.EventData.Desc = Utils.StringToBytes(data.description); - packet.EventData.Date = Utils.StringToBytes(data.date); - packet.EventData.DateUTC = data.dateUTC; - packet.EventData.Duration = data.duration; - packet.EventData.Cover = data.cover; - packet.EventData.Amount = data.amount; - packet.EventData.SimName = Utils.StringToBytes(data.simName); - packet.EventData.GlobalPos = new Vector3d(data.globalPos); - packet.EventData.EventFlags = data.eventFlags; - - OutPacket(packet, ThrottleOutPacketType.Task); - } - - public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) - { - MapItemReplyPacket mirplk = new MapItemReplyPacket(); - mirplk.AgentData.AgentID = AgentId; - mirplk.RequestData.ItemType = mapitemtype; - mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length]; - for (int i = 0; i < replies.Length; i++) - { - MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock(); - mrdata.X = replies[i].x; - mrdata.Y = replies[i].y; - mrdata.ID = replies[i].id; - mrdata.Extra = replies[i].Extra; - mrdata.Extra2 = replies[i].Extra2; - mrdata.Name = Utils.StringToBytes(replies[i].name); - mirplk.Data[i] = mrdata; - } - //m_log.Debug(mirplk.ToString()); - OutPacket(mirplk, ThrottleOutPacketType.Task); - - } - - public void SendOfferCallingCard(UUID srcID, UUID transactionID) - { - // a bit special, as this uses AgentID to store the source instead - // of the destination. The destination (the receiver) goes into destID - OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard); - p.AgentData.AgentID = srcID; - p.AgentData.SessionID = UUID.Zero; - p.AgentBlock.DestID = AgentId; - p.AgentBlock.TransactionID = transactionID; - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendAcceptCallingCard(UUID transactionID) - { - AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard); - p.AgentData.AgentID = AgentId; - p.AgentData.SessionID = UUID.Zero; - p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1]; - p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock(); - p.FolderData[0].FolderID = UUID.Zero; - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendDeclineCallingCard(UUID transactionID) - { - DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard); - p.AgentData.AgentID = AgentId; - p.AgentData.SessionID = UUID.Zero; - p.TransactionBlock.TransactionID = transactionID; - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendTerminateFriend(UUID exFriendID) - { - TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship); - p.AgentData.AgentID = AgentId; - p.AgentData.SessionID = SessionId; - p.ExBlock.OtherID = exFriendID; - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) - { - AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply); - - p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock(); - p.AgentData.AgentID = AgentId; - p.AgentData.AvatarID = avatarID; - - p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length]; - int i = 0; - foreach (GroupMembershipData m in data) - { - p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock(); - p.GroupData[i].GroupPowers = m.GroupPowers; - p.GroupData[i].AcceptNotices = m.AcceptNotices; - p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle); - p.GroupData[i].GroupID = m.GroupID; - p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName); - p.GroupData[i].GroupInsigniaID = m.GroupPicture; - i++; - } - - p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock(); - p.NewGroupData.ListInProfile = true; - - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendJoinGroupReply(UUID groupID, bool success) - { - JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply); - - p.AgentData = new JoinGroupReplyPacket.AgentDataBlock(); - p.AgentData.AgentID = AgentId; - - p.GroupData = new JoinGroupReplyPacket.GroupDataBlock(); - p.GroupData.GroupID = groupID; - p.GroupData.Success = success; - - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) - { - EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply); - - p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock(); - p.AgentData.AgentID = agentID; - - p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock(); - p.GroupData.GroupID = groupID; - - p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock(); - p.EjectData.Success = success; - - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendLeaveGroupReply(UUID groupID, bool success) - { - LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply); - - p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock(); - p.AgentData.AgentID = AgentId; - - p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock(); - p.GroupData.GroupID = groupID; - p.GroupData.Success = success; - - OutPacket(p, ThrottleOutPacketType.Task); - } - - public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) - { - if (classifiedID.Length != name.Length) - return; - - AvatarClassifiedReplyPacket ac = - (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( - PacketType.AvatarClassifiedReply); - - ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); - ac.AgentData.AgentID = AgentId; - ac.AgentData.TargetID = targetID; - - ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length]; - int i; - for (i = 0 ; i < classifiedID.Length ; i++) - { - ac.Data[i].ClassifiedID = classifiedID[i]; - ac.Data[i].Name = Utils.StringToBytes(name[i]); - } - - OutPacket(ac, ThrottleOutPacketType.Task); - } - - public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price) - { - ClassifiedInfoReplyPacket cr = - (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket( - PacketType.ClassifiedInfoReply); - - cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock(); - cr.AgentData.AgentID = AgentId; - - cr.Data = new ClassifiedInfoReplyPacket.DataBlock(); - cr.Data.ClassifiedID = classifiedID; - cr.Data.CreatorID = creatorID; - cr.Data.CreationDate = creationDate; - cr.Data.ExpirationDate = expirationDate; - cr.Data.Category = category; - cr.Data.Name = Utils.StringToBytes(name); - cr.Data.Desc = Utils.StringToBytes(description); - cr.Data.ParcelID = parcelID; - cr.Data.ParentEstate = parentEstate; - cr.Data.SnapshotID = snapshotID; - cr.Data.SimName = Utils.StringToBytes(simName); - cr.Data.PosGlobal = new Vector3d(globalPos); - cr.Data.ParcelName = Utils.StringToBytes(parcelName); - cr.Data.ClassifiedFlags = classifiedFlags; - cr.Data.PriceForListing = price; - - OutPacket(cr, ThrottleOutPacketType.Task); - } - - public void SendAgentDropGroup(UUID groupID) - { - AgentDropGroupPacket dg = - (AgentDropGroupPacket)PacketPool.Instance.GetPacket( - PacketType.AgentDropGroup); - - dg.AgentData = new AgentDropGroupPacket.AgentDataBlock(); - dg.AgentData.AgentID = AgentId; - dg.AgentData.GroupID = groupID; - - OutPacket(dg, ThrottleOutPacketType.Task); - } - - public void SendAvatarNotesReply(UUID targetID, string text) - { - AvatarNotesReplyPacket an = - (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket( - PacketType.AvatarNotesReply); - - an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock(); - an.AgentData.AgentID = AgentId; - - an.Data = new AvatarNotesReplyPacket.DataBlock(); - an.Data.TargetID = targetID; - an.Data.Notes = Utils.StringToBytes(text); - - OutPacket(an, ThrottleOutPacketType.Task); - } - - public void SendAvatarPicksReply(UUID targetID, Dictionary picks) - { - AvatarPicksReplyPacket ap = - (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket( - PacketType.AvatarPicksReply); - - ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock(); - ap.AgentData.AgentID = AgentId; - ap.AgentData.TargetID = targetID; - - ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count]; - - int i = 0; - foreach (KeyValuePair pick in picks) - { - ap.Data[i] = new AvatarPicksReplyPacket.DataBlock(); - ap.Data[i].PickID = pick.Key; - ap.Data[i].PickName = Utils.StringToBytes(pick.Value); - i++; - } - - OutPacket(ap, ThrottleOutPacketType.Task); - } - - public void SendAvatarClassifiedReply(UUID targetID, Dictionary classifieds) - { - AvatarClassifiedReplyPacket ac = - (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket( - PacketType.AvatarClassifiedReply); - - ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock(); - ac.AgentData.AgentID = AgentId; - ac.AgentData.TargetID = targetID; - - ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count]; - - int i = 0; - foreach (KeyValuePair classified in classifieds) - { - ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock(); - ac.Data[i].ClassifiedID = classified.Key; - ac.Data[i].Name = Utils.StringToBytes(classified.Value); - i++; - } - - OutPacket(ac, ThrottleOutPacketType.Task); - } - - public void SendParcelDwellReply(int localID, UUID parcelID, float dwell) - { - ParcelDwellReplyPacket pd = - (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket( - PacketType.ParcelDwellReply); - - pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock(); - pd.AgentData.AgentID = AgentId; - - pd.Data = new ParcelDwellReplyPacket.DataBlock(); - pd.Data.LocalID = localID; - pd.Data.ParcelID = parcelID; - pd.Data.Dwell = dwell; - - OutPacket(pd, ThrottleOutPacketType.Land); - } - - public void SendUserInfoReply(bool imViaEmail, bool visible, string email) - { - UserInfoReplyPacket ur = - (UserInfoReplyPacket)PacketPool.Instance.GetPacket( - PacketType.UserInfoReply); - - string Visible = "hidden"; - if (visible) - Visible = "default"; - - ur.AgentData = new UserInfoReplyPacket.AgentDataBlock(); - ur.AgentData.AgentID = AgentId; - - ur.UserData = new UserInfoReplyPacket.UserDataBlock(); - ur.UserData.IMViaEMail = imViaEmail; - ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible); - ur.UserData.EMail = Utils.StringToBytes(email); - - OutPacket(ur, ThrottleOutPacketType.Task); - } - public void KillEndDone() { - KillPacket kp = new KillPacket(); - OutPacket(kp, ThrottleOutPacketType.Task | ThrottleOutPacketType.LowPriority); + m_udpClient.Shutdown(); } #region IClientCore @@ -10767,13 +10324,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - protected virtual void RegisterInterfaces() - { - RegisterInterface(this); - RegisterInterface(this); - RegisterInterface(this); - } - public bool TryGet(out T iface) { if (m_clientInterfaces.ContainsKey(typeof(T))) @@ -10821,78 +10371,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - public void SendCreateGroupReply(UUID groupID, bool success, string message) - { - CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply); - - createGroupReply.AgentData = - new CreateGroupReplyPacket.AgentDataBlock(); - createGroupReply.ReplyData = - new CreateGroupReplyPacket.ReplyDataBlock(); - - createGroupReply.AgentData.AgentID = AgentId; - createGroupReply.ReplyData.GroupID = groupID; - - createGroupReply.ReplyData.Success = success; - createGroupReply.ReplyData.Message = Utils.StringToBytes(message); - OutPacket(createGroupReply, ThrottleOutPacketType.Task); - } - - public void SendUseCachedMuteList() - { - UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList); - - useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock(); - useCachedMuteList.AgentData.AgentID = AgentId; - - OutPacket(useCachedMuteList, ThrottleOutPacketType.Task); - } - - public void SendMuteListUpdate(string filename) - { - MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate); - - muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock(); - muteListUpdate.MuteData.AgentID = AgentId; - muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename); - - OutPacket(muteListUpdate, ThrottleOutPacketType.Task); - } - - public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) - { - PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply); - - pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock(); - pickInfoReply.AgentData.AgentID = AgentId; - - pickInfoReply.Data = new PickInfoReplyPacket.DataBlock(); - pickInfoReply.Data.PickID = pickID; - pickInfoReply.Data.CreatorID = creatorID; - pickInfoReply.Data.TopPick = topPick; - pickInfoReply.Data.ParcelID = parcelID; - pickInfoReply.Data.Name = Utils.StringToBytes(name); - pickInfoReply.Data.Desc = Utils.StringToBytes(desc); - pickInfoReply.Data.SnapshotID = snapshotID; - pickInfoReply.Data.User = Utils.StringToBytes(user); - pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName); - pickInfoReply.Data.SimName = Utils.StringToBytes(simName); - pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal); - pickInfoReply.Data.SortOrder = sortOrder; - pickInfoReply.Data.Enabled = enabled; - - OutPacket(pickInfoReply, ThrottleOutPacketType.Task); - } - public string Report() { - LLPacketHandler handler = (LLPacketHandler) m_PacketHandler; - return handler.PacketQueue.GetStats(); + return m_udpClient.GetStats(); } public string XReport(string uptime, string version) { - return ""; + return String.Empty; } public void MakeAssetRequest(TransferRequestPacket transferRequest) @@ -10981,7 +10467,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP return numPackets; } - #region IClientIPEndpoint Members public IPAddress EndPoint diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index facfb9d2ed..5219df708d 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs @@ -172,7 +172,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_lastloopprocessed = DateTime.Now.Ticks; // This can happen during Close() - if (m_client == null || m_client.PacketHandler == null || m_client.PacketHandler.PacketQueue == null) + if (m_client == null) return false; while ((imagereq = GetHighestPriorityImage()) != null) diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index e98a360211..f30df4d7fa 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs @@ -39,7 +39,12 @@ using Timer=System.Timers.Timer; namespace OpenSim.Region.ClientStack.LindenUDP { - public class LLPacketHandler : ILLPacketHandler + public delegate void PacketStats(int inPackets, int outPackets, int unAckedBytes); + public delegate void PacketDrop(Packet pack, Object id); + public delegate void QueueEmpty(ThrottleOutPacketType queue); + public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, UUID agentID, ThrottleOutPacketType throttlePacketType); + + public class LLPacketHandler { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs index 70d94e7777..f08b7be002 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // private static readonly log4net.ILog m_log // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - protected readonly ILLClientStackNetworkHandler m_networkHandler; + protected readonly LLUDPServer m_networkHandler; protected IScene m_scene; /// @@ -50,7 +50,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private ClientStackUserSettings m_userSettings; - public LLPacketServer(ILLClientStackNetworkHandler networkHandler, ClientStackUserSettings userSettings) + public LLPacketServer(LLUDPServer networkHandler, ClientStackUserSettings userSettings) { m_userSettings = userSettings; m_networkHandler = networkHandler; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index c779b08fa7..7964c505b3 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs @@ -26,616 +26,727 @@ */ using System; -using System.Collections; using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Reflection; +using System.Threading; using log4net; using Nini.Config; using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; namespace OpenSim.Region.ClientStack.LindenUDP { - /// - /// This class handles the initial UDP circuit setup with a client and passes on subsequent packets to the LLPacketServer - /// - public class LLUDPServer : ILLClientStackNetworkHandler, IClientNetworkServer + public class LLUDPServerShim : IClientNetworkServer { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + LLUDPServer m_udpServer; - /// - /// The client circuits established with this UDP server. If a client exists here we can also assume that - /// it is populated in clientCircuits_reverse and proxyCircuits (if relevant) - /// - protected Dictionary clientCircuits = new Dictionary(); - public Hashtable clientCircuits_reverse = Hashtable.Synchronized(new Hashtable()); - protected Dictionary proxyCircuits = new Dictionary(); - - private Socket m_socket; - protected IPEndPoint ServerIncoming; - protected byte[] RecvBuffer = new byte[4096]; - protected byte[] ZeroBuffer = new byte[8192]; - - /// - /// This is an endpoint that is reused where we don't need to protect the information from potentially - /// being stomped on by other threads. - /// - protected EndPoint reusedEpSender = new IPEndPoint(IPAddress.Any, 0); - - protected int proxyPortOffset; - - protected AsyncCallback ReceivedData; - protected LLPacketServer m_packetServer; - protected Location m_location; - - protected uint listenPort; - protected bool Allow_Alternate_Port; - protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); - protected IScene m_localScene; - protected int m_clientSocketReceiveBuffer = 0; - - /// - /// Manages authentication for agent circuits - /// - protected AgentCircuitManager m_circuitManager; - - public IScene LocalScene + public LLUDPServerShim() { - set - { - m_localScene = value; - m_packetServer.LocalScene = m_localScene; - - m_location = new Location(m_localScene.RegionInfo.RegionHandle); - } } - public ulong RegionHandle + public void Initialise(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) { - get { return m_location.RegionHandle; } + m_udpServer = new LLUDPServer(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager); } - Socket IClientNetworkServer.Server + public void NetworkStop() { - get { return m_socket; } + m_udpServer.Stop(); + } + + public void AddScene(IScene scene) + { + m_udpServer.AddScene(scene); } public bool HandlesRegion(Location x) { - //return x.RegionHandle == m_location.RegionHandle; - return x == m_location; - } - - public void AddScene(IScene x) - { - LocalScene = x; + return m_udpServer.HandlesRegion(x); } public void Start() { - ServerListener(); + m_udpServer.Start(); } public void Stop() { - m_socket.Close(); + m_udpServer.Stop(); } + } - public LLUDPServer() + public class LLUDPServer : UDPBase + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// Handlers for incoming packets + //PacketEventDictionary packetEvents = new PacketEventDictionary(); + /// Incoming packets that are awaiting handling + private OpenMetaverse.BlockingQueue packetInbox = new OpenMetaverse.BlockingQueue(); + /// + private UDPClientCollection clients = new UDPClientCollection(); + /// Bandwidth throttle for this UDP server + private TokenBucket m_throttle; + /// Bandwidth throttle rates for this UDP server + private ThrottleRates m_throttleRates; + /// Manages authentication for agent circuits + private AgentCircuitManager m_circuitManager; + /// Reference to the scene this UDP server is attached to + private IScene m_scene; + /// The X/Y coordinates of the scene this UDP server is attached to + private Location m_location; + /// The measured resolution of Environment.TickCount + private float m_tickCountResolution; + + /// The measured resolution of Environment.TickCount + public float TickCountResolution { get { return m_tickCountResolution; } } + public Socket Server { get { return null; } } + + public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) + : base((int)port) { - } + #region Environment.TickCount Measurement - public LLUDPServer( - IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, IConfigSource configSource, - AgentCircuitManager authenticateClass) - { - Initialise(_listenIP, ref port, proxyPortOffset, allow_alternate_port, configSource, authenticateClass); - } - - /// - /// Initialize the server - /// - /// - /// - /// - /// - /// - /// - /// - public void Initialise( - IPAddress _listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, - AgentCircuitManager circuitManager) - { - ClientStackUserSettings userSettings = new ClientStackUserSettings(); - - IConfig config = configSource.Configs["ClientStack.LindenUDP"]; - - if (config != null) + // Measure the resolution of Environment.TickCount + m_tickCountResolution = 0f; + for (int i = 0; i < 5; i++) { - if (config.Contains("client_throttle_max_bps")) - { - int maxBPS = config.GetInt("client_throttle_max_bps", 1500000); - userSettings.TotalThrottleSettings = new ThrottleSettings(0, maxBPS, - maxBPS > 28000 ? maxBPS : 28000); - } - - if (config.Contains("client_throttle_multiplier")) - userSettings.ClientThrottleMultipler = config.GetFloat("client_throttle_multiplier"); - if (config.Contains("client_socket_rcvbuf_size")) - m_clientSocketReceiveBuffer = config.GetInt("client_socket_rcvbuf_size"); + int start = Environment.TickCount; + int now = start; + while (now == start) + now = Environment.TickCount; + m_tickCountResolution += (float)(now - start) * 0.2f; } - - m_log.DebugFormat("[CLIENT]: client_throttle_multiplier = {0}", userSettings.ClientThrottleMultipler); - m_log.DebugFormat("[CLIENT]: client_socket_rcvbuf_size = {0}", (m_clientSocketReceiveBuffer != 0 ? - m_clientSocketReceiveBuffer.ToString() : "OS default")); - - proxyPortOffset = proxyPortOffsetParm; - listenPort = (uint) (port + proxyPortOffsetParm); - listenIP = _listenIP; - Allow_Alternate_Port = allow_alternate_port; + m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms"); + + #endregion Environment.TickCount Measurement + m_circuitManager = circuitManager; - CreatePacketServer(userSettings); - // Return new port - // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered. - // So the option allow_alternate_ports="true" was added to default.xml - port = (uint)(listenPort - proxyPortOffsetParm); + // TODO: Config support for throttling the entire connection + m_throttle = new TokenBucket(null, 0, 0); + m_throttleRates = new ThrottleRates(configSource); } - protected virtual void CreatePacketServer(ClientStackUserSettings userSettings) + public new void Start() { - new LLPacketServer(this, userSettings); + if (m_scene == null) + throw new InvalidOperationException("Cannot LLUDPServer.Start() without an IScene reference"); + + base.Start(); + + // Start the incoming packet processing thread + Thread incomingThread = new Thread(IncomingPacketHandler); + incomingThread.Name = "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")"; + incomingThread.Start(); + + Thread outgoingThread = new Thread(OutgoingPacketHandler); + outgoingThread.Name = "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")"; + outgoingThread.Start(); } - /// - /// This method is called every time that we receive new UDP data. - /// - /// - protected virtual void OnReceivedData(IAsyncResult result) + public new void Stop() { + base.Stop(); + } + + public void AddScene(IScene scene) + { + if (m_scene == null) + { + m_scene = scene; + m_location = new Location(m_scene.RegionInfo.RegionHandle); + } + else + { + m_log.Error("[LLUDPSERVER]: AddScene() called on an LLUDPServer that already has a scene"); + } + } + + public bool HandlesRegion(Location x) + { + return x == m_location; + } + + public void RemoveClient(IClientAPI client) + { + m_scene.ClientManager.Remove(client.CircuitCode); + client.Close(false); + + LLUDPClient udpClient; + if (clients.TryGetValue(client.AgentId, out udpClient)) + { + m_log.Debug("[LLUDPSERVER]: Removing LLUDPClient for " + client.Name); + udpClient.Shutdown(); + clients.Remove(client.AgentId, udpClient.RemoteEndPoint); + } + else + { + m_log.Warn("[LLUDPSERVER]: Failed to remove LLUDPClient for " + client.Name); + } + } + + public void RemoveClient(LLUDPClient udpClient) + { + IClientAPI client; + + if (m_scene.ClientManager.TryGetClient(udpClient.CircuitCode, out client)) + RemoveClient(client); + else + m_log.Warn("[LLUDPSERVER]: Failed to lookup IClientAPI for LLUDPClient " + udpClient.AgentID); + } + + public void SetClientPaused(UUID agentID, bool paused) + { + LLUDPClient client; + if (clients.TryGetValue(agentID, out client)) + { + client.IsPaused = paused; + } + else + { + m_log.Warn("[LLUDPSERVER]: Attempted to pause/unpause unknown agent " + agentID); + } + } + + public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting) + { + if (allowSplitting && packet.HasVariableBlocks) + { + byte[][] datas = packet.ToBytesMultiple(); + int packetCount = datas.Length; + + if (packetCount > 1) + m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); + + for (int i = 0; i < packetCount; i++) + { + byte[] data = datas[i]; + clients.ForEach( + delegate(LLUDPClient client) + { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); + } + } + else + { + byte[] data = packet.ToBytes(); + clients.ForEach( + delegate(LLUDPClient client) + { SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); }); + } + } + + public void SendPacket(UUID agentID, Packet packet, ThrottleOutPacketType category, bool allowSplitting) + { + LLUDPClient client; + if (clients.TryGetValue(agentID, out client)) + SendPacket(client, packet, category, allowSplitting); + else + m_log.Warn("[LLUDPSERVER]: Attempted to send a packet to unknown agentID " + agentID); + } + + public void SendPacket(LLUDPClient client, Packet packet, ThrottleOutPacketType category, bool allowSplitting) + { + if (allowSplitting && packet.HasVariableBlocks) + { + byte[][] datas = packet.ToBytesMultiple(); + int packetCount = datas.Length; + + if (packetCount > 1) + m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets"); + + for (int i = 0; i < packetCount; i++) + { + byte[] data = datas[i]; + SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); + } + } + else + { + byte[] data = packet.ToBytes(); + SendPacketData(client, data, data.Length, packet.Type, packet.Header.Zerocoded, category); + } + } + + public void SendPacketData(LLUDPClient client, byte[] data, int dataLength, PacketType type, bool doZerocode, ThrottleOutPacketType category) + { + // Frequency analysis of outgoing packet sizes shows a large clump of packets at each end of the spectrum. + // The vast majority of packets are less than 200 bytes, although due to asset transfers and packet splitting + // there are a decent number of packets in the 1000-1140 byte range. We allocate one of two sizes of data here + // to accomodate for both common scenarios and provide ample room for ACK appending in both + int bufferSize = (dataLength > 180) ? Packet.MTU : 200; + + UDPPacketBuffer buffer = new UDPPacketBuffer(client.RemoteEndPoint, bufferSize); + + // Zerocode if needed + if (doZerocode) + { + try { dataLength = Helpers.ZeroEncode(data, dataLength, buffer.Data); } + catch (IndexOutOfRangeException) + { + // The packet grew larger than the bufferSize while zerocoding. + // Remove the MSG_ZEROCODED flag and send the unencoded data + // instead + m_log.Info("[LLUDPSERVER]: Packet exceeded buffer size during zerocoding. Removing MSG_ZEROCODED flag"); + data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED); + Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); + } + } + else + { + Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); + } + buffer.DataLength = dataLength; + + #region Queue or Send + + // Look up the UDPClient this is going to + OutgoingPacket outgoingPacket = new OutgoingPacket(client, buffer, category); + + if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) + SendPacketFinal(outgoingPacket); + + #endregion Queue or Send + } + + public void SendAcks(LLUDPClient client) + { + uint ack; + + if (client.PendingAcks.Dequeue(out ack)) + { + List blocks = new List(); + PacketAckPacket.PacketsBlock block = new PacketAckPacket.PacketsBlock(); + block.ID = ack; + blocks.Add(block); + + while (client.PendingAcks.Dequeue(out ack)) + { + block = new PacketAckPacket.PacketsBlock(); + block.ID = ack; + blocks.Add(block); + } + + PacketAckPacket packet = new PacketAckPacket(); + packet.Header.Reliable = false; + packet.Packets = blocks.ToArray(); + + SendPacket(client, packet, ThrottleOutPacketType.Unknown, true); + } + } + + public void ResendUnacked(LLUDPClient client) + { + if (client.NeedAcks.Count > 0) + { + List expiredPackets = client.NeedAcks.GetExpiredPackets(client.RTO); + + if (expiredPackets != null) + { + // Resend packets + for (int i = 0; i < expiredPackets.Count; i++) + { + OutgoingPacket outgoingPacket = expiredPackets[i]; + + // FIXME: Make this an .ini setting + if (outgoingPacket.ResendCount < 3) + { + //Logger.Debug(String.Format("Resending packet #{0} (attempt {1}), {2}ms have passed", + // outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount)); + + // Set the resent flag + outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT); + outgoingPacket.Category = ThrottleOutPacketType.Resend; + + // The TickCount will be set to the current time when the packet + // is actually sent out again + outgoingPacket.TickCount = 0; + + Interlocked.Increment(ref outgoingPacket.ResendCount); + //Interlocked.Increment(ref Stats.ResentPackets); + + // Queue or (re)send the packet + if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) + SendPacketFinal(outgoingPacket); + } + else + { + m_log.DebugFormat("[LLUDPSERVER]: Dropping packet #{0} for agent {1} after {2} failed attempts", + outgoingPacket.SequenceNumber, outgoingPacket.Client.RemoteEndPoint, outgoingPacket.ResendCount); + + lock (client.NeedAcks.SyncRoot) + client.NeedAcks.RemoveUnsafe(outgoingPacket.SequenceNumber); + + //Interlocked.Increment(ref Stats.DroppedPackets); + + // Disconnect an agent if no packets are received for some time + //FIXME: Make 60 an .ini setting + if (Environment.TickCount - client.TickLastPacketReceived > 1000 * 60) + { + m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + client.RemoteEndPoint); + + RemoveClient(client); + return; + } + } + } + } + } + } + + public void Flush() + { + } + + protected override void PacketReceived(UDPPacketBuffer buffer) + { + // Debugging/Profiling + //try { Thread.CurrentThread.Name = "PacketReceived (" + scene.RegionName + ")"; } + //catch (Exception) { } + + LLUDPClient client = null; Packet packet = null; - int numBytes = 1; - EndPoint epSender = new IPEndPoint(IPAddress.Any, 0); - EndPoint epProxy = null; + int packetEnd = buffer.DataLength - 1; + IPEndPoint address = (IPEndPoint)buffer.RemoteEndPoint; + + #region Decoding try { - if (EndReceive(out numBytes, result, ref epSender)) - { - // Make sure we are getting zeroes when running off the - // end of grab / degrab packets from old clients - Array.Clear(RecvBuffer, numBytes, RecvBuffer.Length - numBytes); - - int packetEnd = numBytes - 1; - if (proxyPortOffset != 0) packetEnd -= 6; - - try - { - packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer); - } - catch (MalformedDataException e) - { - m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to MalformedDataException: {0}", e.StackTrace); - } - catch (IndexOutOfRangeException e) - { - m_log.DebugFormat("[CLIENT]: Dropped Malformed Packet due to IndexOutOfRangeException: {0}", e.StackTrace); - } - catch (Exception e) - { - m_log.Debug("[CLIENT]: " + e); - } - } - - - if (proxyPortOffset != 0) - { - // If we've received a use circuit packet, then we need to decode an endpoint proxy, if one exists, - // before allowing the RecvBuffer to be overwritten by the next packet. - if (packet != null && packet.Type == PacketType.UseCircuitCode) - { - epProxy = epSender; - } - - // Now decode the message from the proxy server - epSender = ProxyCodec.DecodeProxyMessage(RecvBuffer, ref numBytes); - } + packet = Packet.BuildPacket(buffer.Data, ref packetEnd, + // Only allocate a buffer for zerodecoding if the packet is zerocoded + ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null); } - catch (Exception ex) + catch (MalformedDataException) { - m_log.ErrorFormat("[CLIENT]: Exception thrown during EndReceive(): {0}", ex); + m_log.ErrorFormat("[LLUDPSERVER]: Malformed data, cannot parse packet:\n{0}", + Utils.BytesToHexString(buffer.Data, buffer.DataLength, null)); } - BeginRobustReceive(); - - if (packet != null) + // Fail-safe check + if (packet == null) { - if (packet.Type == PacketType.UseCircuitCode) - AddNewClient((UseCircuitCodePacket)packet, epSender, epProxy); + m_log.Warn("[LLUDPSERVER]: Couldn't build a message from the incoming data"); + return; + } + + //Stats.RecvBytes += (ulong)buffer.DataLength; + //++Stats.RecvPackets; + + #endregion Decoding + + #region UseCircuitCode Handling + + if (packet.Type == PacketType.UseCircuitCode) + { + UseCircuitCodePacket useCircuitCode = (UseCircuitCodePacket)packet; + IClientAPI newuser; + uint circuitCode = useCircuitCode.CircuitCode.Code; + + // Check if the client is already established + if (!m_scene.ClientManager.TryGetClient(circuitCode, out newuser)) + { + AddNewClient(useCircuitCode, (IPEndPoint)buffer.RemoteEndPoint); + } + } + + // Determine which agent this packet came from + if (!clients.TryGetValue(address, out client)) + { + m_log.Warn("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address); + return; + } + + #endregion UseCircuitCode Handling + + //if (packet.Header.Resent) + // Interlocked.Increment(ref Stats.ReceivedResends); + + #region ACK Receiving + + int now = Environment.TickCount; + client.TickLastPacketReceived = now; + + // Handle appended ACKs + if (packet.Header.AppendedAcks && packet.Header.AckList != null) + { + lock (client.NeedAcks.SyncRoot) + { + for (int i = 0; i < packet.Header.AckList.Length; i++) + AcknowledgePacket(client, packet.Header.AckList[i], now, packet.Header.Resent); + } + } + + // Handle PacketAck packets + if (packet.Type == PacketType.PacketAck) + { + PacketAckPacket ackPacket = (PacketAckPacket)packet; + + lock (client.NeedAcks.SyncRoot) + { + for (int i = 0; i < ackPacket.Packets.Length; i++) + AcknowledgePacket(client, ackPacket.Packets[i].ID, now, packet.Header.Resent); + } + } + + #endregion ACK Receiving + + #region ACK Sending + + if (packet.Header.Reliable) + client.PendingAcks.Enqueue((uint)packet.Header.Sequence); + + // This is a somewhat odd sequence of steps to pull the client.BytesSinceLastACK value out, + // add the current received bytes to it, test if 2*MTU bytes have been sent, if so remove + // 2*MTU bytes from the value and send ACKs, and finally add the local value back to + // client.BytesSinceLastACK. Lockless thread safety + int bytesSinceLastACK = Interlocked.Exchange(ref client.BytesSinceLastACK, 0); + bytesSinceLastACK += buffer.DataLength; + if (bytesSinceLastACK > Packet.MTU * 2) + { + bytesSinceLastACK -= Packet.MTU * 2; + SendAcks(client); + } + Interlocked.Add(ref client.BytesSinceLastACK, bytesSinceLastACK); + + #endregion ACK Sending + + #region Incoming Packet Accounting + + // Check the archive of received reliable packet IDs to see whether we already received this packet + if (packet.Header.Reliable && !client.PacketArchive.TryEnqueue(packet.Header.Sequence)) + { + if (packet.Header.Resent) + m_log.Debug("[LLUDPSERVER]: Received a resend of already processed packet #" + packet.Header.Sequence + ", type: " + packet.Type); else - ProcessInPacket(packet, epSender); + m_log.Warn("[LLUDPSERVER]: Received a duplicate (not marked as resend) of packet #" + packet.Header.Sequence + ", type: " + packet.Type); + + // Avoid firing a callback twice for the same packet + return; + } + + #endregion Incoming Packet Accounting + + // Don't bother clogging up the queue with PacketAck packets that are already handled here + if (packet.Type != PacketType.PacketAck) + { + // Inbox insertion + IncomingPacket incomingPacket; + incomingPacket.Client = client; + incomingPacket.Packet = packet; + + packetInbox.Enqueue(incomingPacket); } } - - /// - /// Process a successfully received packet. - /// - /// - /// - protected virtual void ProcessInPacket(Packet packet, EndPoint epSender) + + protected override void PacketSent(UDPPacketBuffer buffer, int bytesSent) { - try - { - // do we already have a circuit for this endpoint - uint circuit; - bool ret; - - lock (clientCircuits) - { - ret = clientCircuits.TryGetValue(epSender, out circuit); - } - - if (ret) - { - //if so then send packet to the packetserver - //m_log.DebugFormat( - // "[UDPSERVER]: For circuit {0} {1} got packet {2}", circuit, epSender, packet.Type); - - m_packetServer.InPacket(circuit, packet); - } - } - catch (Exception e) - { - m_log.Error("[CLIENT]: Exception in processing packet - ignoring: ", e); - } } - - /// - /// Begin an asynchronous receive of the next bit of raw data - /// - protected virtual void BeginReceive() + + private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) { - m_socket.BeginReceiveFrom( - RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref reusedEpSender, ReceivedData, null); + UUID agentID = useCircuitCode.CircuitCode.ID; + UUID sessionID = useCircuitCode.CircuitCode.SessionID; + uint circuitCode = useCircuitCode.CircuitCode.Code; + + sessionInfo = m_circuitManager.AuthenticateSession(sessionID, agentID, circuitCode); + return sessionInfo.Authorised; } - /// - /// Begin a robust asynchronous receive of the next bit of raw data. Robust means that SocketExceptions are - /// automatically dealt with until the next set of valid UDP data is received. - /// - private void BeginRobustReceive() - { - bool done = false; - - while (!done) - { - try - { - BeginReceive(); - done = true; - } - catch (SocketException e) - { - // ENDLESS LOOP ON PURPOSE! - // Reset connection and get next UDP packet off the buffer - // If the UDP packet is part of the same stream, this will happen several hundreds of times before - // the next set of UDP data is for a valid client. - - try - { - CloseCircuit(e); - } - catch (Exception e2) - { - m_log.ErrorFormat( - "[CLIENT]: Exception thrown when trying to close the circuit for {0} - {1}", reusedEpSender, - e2); - } - } - catch (ObjectDisposedException) - { - m_log.Info( - "[UDPSERVER]: UDP Object disposed. No need to worry about this if you're restarting the simulator."); - - done = true; - } - catch (Exception ex) - { - m_log.ErrorFormat("[CLIENT]: Exception thrown during BeginReceive(): {0}", ex); - } - } - } - - /// - /// Close a client circuit. This is done in response to an exception on receive, and should not be called - /// normally. - /// - /// The exception that caused the close. Can be null if there was no exception - private void CloseCircuit(Exception e) - { - uint circuit; - lock (clientCircuits) - { - if (clientCircuits.TryGetValue(reusedEpSender, out circuit)) - { - m_packetServer.CloseCircuit(circuit); - - if (e != null) - m_log.ErrorFormat( - "[CLIENT]: Closed circuit {0} {1} due to exception {2}", circuit, reusedEpSender, e); - } - } - } - - /// - /// Finish the process of asynchronously receiving the next bit of raw data - /// - /// The number of bytes received. Will return 0 if no bytes were recieved - /// - /// The sender of the data - /// - protected virtual bool EndReceive(out int numBytes, IAsyncResult result, ref EndPoint epSender) - { - bool hasReceivedOkay = false; - numBytes = 0; - - try - { - numBytes = m_socket.EndReceiveFrom(result, ref epSender); - hasReceivedOkay = true; - } - catch (SocketException e) - { - // TODO : Actually only handle those states that we have control over, re-throw everything else, - // TODO: implement cases as we encounter them. - //m_log.Error("[CLIENT]: Connection Error! - " + e.ToString()); - switch (e.SocketErrorCode) - { - case SocketError.AlreadyInProgress: - return hasReceivedOkay; - - case SocketError.NetworkReset: - case SocketError.ConnectionReset: - case SocketError.OperationAborted: - break; - - default: - throw; - } - } - catch (ObjectDisposedException e) - { - m_log.DebugFormat("[CLIENT]: ObjectDisposedException: Object {0} disposed.", e.ObjectName); - // Uhh, what object, and why? this needs better handling. - } - - return hasReceivedOkay; - } - - /// - /// Add a new client circuit. - /// - /// - /// - /// - protected virtual void AddNewClient(UseCircuitCodePacket useCircuit, EndPoint epSender, EndPoint epProxy) + private void AddNewClient(UseCircuitCodePacket useCircuitCode, IPEndPoint remoteEndPoint) { //Slave regions don't accept new clients - if (m_localScene.RegionStatus != RegionStatus.SlaveScene) + if (m_scene.RegionStatus != RegionStatus.SlaveScene) { AuthenticateResponse sessionInfo; - bool isNewCircuit = false; - - if (!m_packetServer.IsClientAuthorized(useCircuit, m_circuitManager, out sessionInfo)) + bool isNewCircuit = !clients.ContainsKey(remoteEndPoint); + + if (!IsClientAuthorized(useCircuitCode, out sessionInfo)) { m_log.WarnFormat( "[CONNECTION FAILURE]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", - useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code, epSender); - + useCircuitCode.CircuitCode.ID, useCircuitCode.CircuitCode.Code, remoteEndPoint); return; } - - lock (clientCircuits) - { - if (!clientCircuits.ContainsKey(epSender)) - { - clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); - isNewCircuit = true; - } - } if (isNewCircuit) { - // This doesn't need locking as it's synchronized data - clientCircuits_reverse[useCircuit.CircuitCode.Code] = epSender; + UUID agentID = useCircuitCode.CircuitCode.ID; + UUID sessionID = useCircuitCode.CircuitCode.SessionID; + uint circuitCode = useCircuitCode.CircuitCode.Code; - lock (proxyCircuits) - { - proxyCircuits[useCircuit.CircuitCode.Code] = epProxy; - } - - m_packetServer.AddNewClient(epSender, useCircuit, sessionInfo, epProxy); - - //m_log.DebugFormat( - // "[CONNECTION SUCCESS]: Incoming client {0} (circuit code {1}) received and authenticated for {2}", - // useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code, m_localScene.RegionInfo.RegionName); - } - } - - // Ack the UseCircuitCode packet - PacketAckPacket ack_it = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); - // TODO: don't create new blocks if recycling an old packet - ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; - ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); - ack_it.Packets[0].ID = useCircuit.Header.Sequence; - // ((useCircuit.Header.Sequence < uint.MaxValue) ? useCircuit.Header.Sequence : 0) is just a failsafe to ensure that we don't overflow. - ack_it.Header.Sequence = ((useCircuit.Header.Sequence < uint.MaxValue) ? useCircuit.Header.Sequence : 0) + 1; - ack_it.Header.Reliable = false; - - byte[] ackmsg = ack_it.ToBytes(); - - // Need some extra space in case we need to add proxy - // information to the message later - byte[] msg = new byte[4096]; - Buffer.BlockCopy(ackmsg, 0, msg, 0, ackmsg.Length); - - SendPacketTo(msg, ackmsg.Length, SocketFlags.None, useCircuit.CircuitCode.Code); - - PacketPool.Instance.ReturnPacket(useCircuit); - } - - public void ServerListener() - { - uint newPort = listenPort; - m_log.Info("[UDPSERVER]: Opening UDP socket on " + listenIP + " " + newPort + "."); - - ServerIncoming = new IPEndPoint(listenIP, (int)newPort); - m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - if (0 != m_clientSocketReceiveBuffer) - m_socket.ReceiveBufferSize = m_clientSocketReceiveBuffer; - m_socket.Bind(ServerIncoming); - // Add flags to the UDP socket to prevent "Socket forcibly closed by host" - // uint IOC_IN = 0x80000000; - // uint IOC_VENDOR = 0x18000000; - // uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12; - // TODO: this apparently works in .NET but not in Mono, need to sort out the right flags here. - // m_socket.IOControl((int)SIO_UDP_CONNRESET, new byte[] { Convert.ToByte(false) }, null); - - listenPort = newPort; - - m_log.Info("[UDPSERVER]: UDP socket bound, getting ready to listen"); - - ReceivedData = OnReceivedData; - BeginReceive(); - - m_log.Info("[UDPSERVER]: Listening on port " + newPort); - } - - public virtual void RegisterPacketServer(LLPacketServer server) - { - m_packetServer = server; - } - - public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) - //EndPoint packetSender) - { - // find the endpoint for this circuit - EndPoint sendto; - try - { - sendto = (EndPoint)clientCircuits_reverse[circuitcode]; - } - catch - { - // Exceptions here mean there is no circuit - m_log.Warn("[CLIENT]: Circuit not found, not sending packet"); - return; - } - - if (sendto != null) - { - //we found the endpoint so send the packet to it - if (proxyPortOffset != 0) - { - //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString()); - ProxyCodec.EncodeProxyMessage(buffer, ref size, sendto); - m_socket.SendTo(buffer, size, flags, proxyCircuits[circuitcode]); - } - else - { - //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo : client " + sendto.ToString()); - try - { - m_socket.SendTo(buffer, size, flags, sendto); - } - catch (SocketException SockE) - { - m_log.ErrorFormat("[UDPSERVER]: Caught Socket Error in the send buffer!. {0}",SockE.ToString()); - } + AddClient(circuitCode, agentID, sessionID, remoteEndPoint, sessionInfo); } } } - public virtual void RemoveClientCircuit(uint circuitcode) + private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo) { - EndPoint sendto; - if (clientCircuits_reverse.Contains(circuitcode)) + // Create the LLUDPClient + LLUDPClient client = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); + clients.Add(agentID, client.RemoteEndPoint, client); + + // Create the IClientAPI + IClientAPI clientApi = new LLClientView(remoteEndPoint, m_scene, this, client, sessionInfo, agentID, sessionID, circuitCode); + clientApi.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; + clientApi.OnLogout += LogoutHandler; + clientApi.OnConnectionClosed += RemoveClient; + + // Give LLUDPClient a reference to IClientAPI + client.ClientAPI = clientApi; + + // Start the IClientAPI + m_scene.ClientManager.Add(circuitCode, clientApi); + clientApi.Start(); + } + + private void AcknowledgePacket(LLUDPClient client, uint ack, int currentTime, bool fromResend) + { + OutgoingPacket ackedPacket; + if (client.NeedAcks.RemoveUnsafe(ack, out ackedPacket) && !fromResend) { - sendto = (EndPoint)clientCircuits_reverse[circuitcode]; - - clientCircuits_reverse.Remove(circuitcode); - - lock (clientCircuits) - { - if (sendto != null) - { - clientCircuits.Remove(sendto); - } - else - { - m_log.DebugFormat( - "[CLIENT]: endpoint for circuit code {0} in RemoveClientCircuit() was unexpectedly null!", circuitcode); - } - } - lock (proxyCircuits) - { - proxyCircuits.Remove(circuitcode); - } + // Calculate the round-trip time for this packet and its ACK + int rtt = currentTime - ackedPacket.TickCount; + if (rtt > 0) + client.UpdateRoundTrip(rtt); } } - public void RestoreClient(AgentCircuitData circuit, EndPoint userEP, EndPoint proxyEP) + private void IncomingPacketHandler() { - //MainLog.Instance.Verbose("UDPSERVER", "RestoreClient"); + IncomingPacket incomingPacket = new IncomingPacket(); + Packet packet = null; + LLUDPClient client = null; - UseCircuitCodePacket useCircuit = new UseCircuitCodePacket(); - useCircuit.CircuitCode.Code = circuit.circuitcode; - useCircuit.CircuitCode.ID = circuit.AgentID; - useCircuit.CircuitCode.SessionID = circuit.SessionID; - - AuthenticateResponse sessionInfo; - - if (!m_packetServer.IsClientAuthorized(useCircuit, m_circuitManager, out sessionInfo)) + while (base.IsRunning) { - m_log.WarnFormat( - "[CLIENT]: Restore request denied to avatar {0} connecting with unauthorized circuit code {1}", - useCircuit.CircuitCode.ID, useCircuit.CircuitCode.Code); - - return; - } + // Reset packet to null for the check below + packet = null; - lock (clientCircuits) - { - if (!clientCircuits.ContainsKey(userEP)) - clientCircuits.Add(userEP, useCircuit.CircuitCode.Code); - else - m_log.Error("[CLIENT]: clientCircuits already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); - } - - // This data structure is synchronized, so we don't need the lock - if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) - clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP); - else - m_log.Error("[CLIENT]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code + ". NOT adding."); - - lock (proxyCircuits) - { - if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) + if (packetInbox.Dequeue(100, ref incomingPacket)) { - proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP); - } - else - { - // re-set proxy endpoint - proxyCircuits.Remove(useCircuit.CircuitCode.Code); - proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP); + packet = incomingPacket.Packet; + client = incomingPacket.Client; + + if (packet != null && client != null) + client.ClientAPI.ProcessInPacket(packet); } } - m_packetServer.AddNewClient(userEP, useCircuit, sessionInfo, proxyEP); + if (packetInbox.Count > 0) + m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets"); + packetInbox.Clear(); + } + + private void OutgoingPacketHandler() + { + int now = Environment.TickCount; + int elapsedMS = 0; + int elapsed100MS = 0; + + while (base.IsRunning) + { + bool resendUnacked = false; + bool sendAcks = false; + bool packetSent = false; + + elapsedMS += Environment.TickCount - now; + + // Check for packets that need to be resent every 100ms + if (elapsedMS >= 100) + { + resendUnacked = true; + elapsedMS -= 100; + ++elapsed100MS; + } + // Check for ACKs that need to be sent out every 500ms + if (elapsed100MS >= 5) + { + sendAcks = true; + elapsed100MS = 0; + } + + clients.ForEach( + delegate(LLUDPClient client) + { + if (client.DequeueOutgoing()) + packetSent = true; + if (resendUnacked) + ResendUnacked(client); + if (sendAcks) + SendAcks(client); + } + ); + + if (!packetSent) + Thread.Sleep(20); + } + } + + private void LogoutHandler(IClientAPI client) + { + client.SendLogoutPacket(); + RemoveClient(client); + } + + internal void SendPacketFinal(OutgoingPacket outgoingPacket) + { + UDPPacketBuffer buffer = outgoingPacket.Buffer; + byte flags = buffer.Data[0]; + bool isResend = (flags & Helpers.MSG_RESENT) != 0; + bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; + LLUDPClient client = outgoingPacket.Client; + + // Keep track of when this packet was sent out (right now) + outgoingPacket.TickCount = Environment.TickCount; + + #region ACK Appending + + int dataLength = buffer.DataLength; + + // Keep appending ACKs until there is no room left in the packet or there are + // no more ACKs to append + uint ackCount = 0; + uint ack; + while (dataLength + 5 < buffer.Data.Length && client.PendingAcks.Dequeue(out ack)) + { + Utils.UIntToBytesBig(ack, buffer.Data, dataLength); + dataLength += 4; + ++ackCount; + } + + if (ackCount > 0) + { + // Set the last byte of the packet equal to the number of appended ACKs + buffer.Data[dataLength++] = (byte)ackCount; + // Set the appended ACKs flag on this packet + buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS); + } + + buffer.DataLength = dataLength; + + #endregion ACK Appending + + if (!isResend) + { + // Not a resend, assign a new sequence number + uint sequenceNumber = (uint)Interlocked.Increment(ref client.CurrentSequence); + Utils.UIntToBytesBig(sequenceNumber, buffer.Data, 1); + outgoingPacket.SequenceNumber = sequenceNumber; + + if (isReliable) + { + // Add this packet to the list of ACK responses we are waiting on from the server + client.NeedAcks.Add(outgoingPacket); + } + } + + // Put the UDP payload on the wire + AsyncBeginSend(buffer); } } } diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUtil.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUtil.cs index c45d11fb11..066b19d031 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUtil.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUtil.cs @@ -25,8 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Collections.Generic; +using System.Net; using OpenMetaverse; +using ReaderWriterLockImpl = OpenMetaverse.ReaderWriterLockSlim; + namespace OpenSim.Region.ClientStack.LindenUDP { public class LLUtil diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs index cde155b2e1..7d0757f3d1 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/PacketHandlerTests.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests TestClient testClient = new TestClient(agent, scene); - ILLPacketHandler packetHandler + LLPacketHandler packetHandler = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings()); packetHandler.InPacket(new AgentAnimationPacket()); diff --git a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs index 1fba8472ef..e995d65edb 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/Tests/TestLLPacketServer.cs @@ -37,7 +37,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests /// protected Dictionary m_packetsReceived = new Dictionary(); - public TestLLPacketServer(ILLClientStackNetworkHandler networkHandler, ClientStackUserSettings userSettings) + public TestLLPacketServer(LLUDPServer networkHandler, ClientStackUserSettings userSettings) : base(networkHandler, userSettings) {}