diff --git a/libsecondlife-cs/AssetSystem/AssetManager.cs b/libsecondlife-cs/AssetSystem/AssetManager.cs index 74aecc4a..edf5dbe8 100644 --- a/libsecondlife-cs/AssetSystem/AssetManager.cs +++ b/libsecondlife-cs/AssetSystem/AssetManager.cs @@ -60,23 +60,13 @@ namespace libsecondlife.AssetSystem slClient = client; // Used to upload small assets, or as an initial start packet for large transfers - PacketCallback AssetUploadCompleteCallback = new PacketCallback(AssetUploadCompleteCallbackHandler); - slClient.Network.RegisterCallback(PacketType.AssetUploadComplete, AssetUploadCompleteCallback); - - // Transfer Packets for downloading large assets - PacketCallback TransferInfoCallback = new PacketCallback(TransferInfoCallbackHandler); - slClient.Network.RegisterCallback(PacketType.TransferInfo, TransferInfoCallback); - - PacketCallback TransferPacketCallback = new PacketCallback(TransferPacketCallbackHandler); - slClient.Network.RegisterCallback(PacketType.TransferPacket, TransferPacketCallback); - + slClient.Network.RegisterCallback(PacketType.AssetUploadComplete, new NetworkManager.PacketCallback(AssetUploadCompleteCallbackHandler)); + // Transfer Packets for downloading large assets + slClient.Network.RegisterCallback(PacketType.TransferInfo, new NetworkManager.PacketCallback(TransferInfoCallbackHandler)); + slClient.Network.RegisterCallback(PacketType.TransferPacket, new NetworkManager.PacketCallback(TransferPacketCallbackHandler)); // XFer packets for uploading large assets - PacketCallback ConfirmXferPacketCallback = new PacketCallback(ConfirmXferPacketCallbackHandler); - slClient.Network.RegisterCallback(PacketType.ConfirmXferPacket, ConfirmXferPacketCallback); - - PacketCallback RequestXferCallback = new PacketCallback(RequestXferCallbackHandler); - slClient.Network.RegisterCallback(PacketType.RequestXfer, RequestXferCallback); - + slClient.Network.RegisterCallback(PacketType.ConfirmXferPacket, new NetworkManager.PacketCallback(ConfirmXferPacketCallbackHandler)); + slClient.Network.RegisterCallback(PacketType.RequestXfer, new NetworkManager.PacketCallback(RequestXferCallbackHandler)); } diff --git a/libsecondlife-cs/AssetSystem/ImageManager.cs b/libsecondlife-cs/AssetSystem/ImageManager.cs index ac9d5de1..2db21811 100644 --- a/libsecondlife-cs/AssetSystem/ImageManager.cs +++ b/libsecondlife-cs/AssetSystem/ImageManager.cs @@ -152,9 +152,9 @@ namespace libsecondlife.AssetSystem ImagePacketHelper = new ImagePacketHelpers(client); // Image Callbacks - slClient.Network.RegisterCallback(PacketType.ImageData, new PacketCallback(ImageDataCallbackHandler)); - slClient.Network.RegisterCallback(PacketType.ImagePacket, new PacketCallback(ImagePacketCallbackHandler)); - slClient.Network.RegisterCallback(PacketType.ImageNotInDatabase, new PacketCallback(ImageNotInDatabaseCallbackHandler)); + slClient.Network.RegisterCallback(PacketType.ImageData, new NetworkManager.PacketCallback(ImageDataCallbackHandler)); + slClient.Network.RegisterCallback(PacketType.ImagePacket, new NetworkManager.PacketCallback(ImagePacketCallbackHandler)); + slClient.Network.RegisterCallback(PacketType.ImageNotInDatabase, new NetworkManager.PacketCallback(ImageNotInDatabaseCallbackHandler)); } private void CacheImage(LLUUID ImageID, byte[] ImageData) diff --git a/libsecondlife-cs/Avatar.cs b/libsecondlife-cs/Avatar.cs index e5ef84b8..805b7a04 100644 --- a/libsecondlife-cs/Avatar.cs +++ b/libsecondlife-cs/Avatar.cs @@ -94,6 +94,79 @@ namespace libsecondlife /// public class Avatar { + /// + /// + /// + [Flags] + public enum AgentUpdateFlags + { + /// Move Forward (SL Keybinding: W/Up Arrow) + AGENT_CONTROL_AT_POS = 0x1 << CONTROL_AT_POS_INDEX, + /// Move Backward (SL Keybinding: S/Down Arrow) + AGENT_CONTROL_AT_NEG = 0x1 << CONTROL_AT_NEG_INDEX, + /// Move Left (SL Keybinding: Shift-(A/Left Arrow)) + AGENT_CONTROL_LEFT_POS = 0x1 << CONTROL_LEFT_POS_INDEX, + /// Move Right (SL Keybinding: Shift-(D/Right Arrow)) + AGENT_CONTROL_LEFT_NEG = 0x1 << CONTROL_LEFT_NEG_INDEX, + /// Not Flying: Jump/Flying: Move Up (SL Keybinding: E) + AGENT_CONTROL_UP_POS = 0x1 << CONTROL_UP_POS_INDEX, + /// Not Flying: Croutch/Flying: Move Down (SL Keybinding: C) + AGENT_CONTROL_UP_NEG = 0x1 << CONTROL_UP_NEG_INDEX, + /// Unused + AGENT_CONTROL_PITCH_POS = 0x1 << CONTROL_PITCH_POS_INDEX, + /// Unused + AGENT_CONTROL_PITCH_NEG = 0x1 << CONTROL_PITCH_NEG_INDEX, + /// Unused + AGENT_CONTROL_YAW_POS = 0x1 << CONTROL_YAW_POS_INDEX, + /// Unused + AGENT_CONTROL_YAW_NEG = 0x1 << CONTROL_YAW_NEG_INDEX, + /// ORed with AGENT_CONTROL_AT_* if the keyboard is being used + AGENT_CONTROL_FAST_AT = 0x1 << CONTROL_FAST_AT_INDEX, + /// ORed with AGENT_CONTROL_LEFT_* if the keyboard is being used + AGENT_CONTROL_FAST_LEFT = 0x1 << CONTROL_FAST_LEFT_INDEX, + /// ORed with AGENT_CONTROL_UP_* if the keyboard is being used + AGENT_CONTROL_FAST_UP = 0x1 << CONTROL_FAST_UP_INDEX, + /// + AGENT_CONTROL_FLY = 0x1 << CONTROL_FLY_INDEX, + /// + AGENT_CONTROL_STOP = 0x1 << CONTROL_STOP_INDEX, + /// + AGENT_CONTROL_FINISH_ANIM = 0x1 << CONTROL_FINISH_ANIM_INDEX, + /// + AGENT_CONTROL_STAND_UP = 0x1 << CONTROL_STAND_UP_INDEX, + /// + AGENT_CONTROL_SIT_ON_GROUND = 0x1 << CONTROL_SIT_ON_GROUND_INDEX, + /// + AGENT_CONTROL_MOUSELOOK = 0x1 << CONTROL_MOUSELOOK_INDEX, + /// Legacy, used if a key was pressed for less than a certain amount of time + AGENT_CONTROL_NUDGE_AT_POS = 0x1 << CONTROL_NUDGE_AT_POS_INDEX, + /// Legacy, used if a key was pressed for less than a certain amount of time + AGENT_CONTROL_NUDGE_AT_NEG = 0x1 << CONTROL_NUDGE_AT_NEG_INDEX, + /// Legacy, used if a key was pressed for less than a certain amount of time + AGENT_CONTROL_NUDGE_LEFT_POS = 0x1 << CONTROL_NUDGE_LEFT_POS_INDEX, + /// Legacy, used if a key was pressed for less than a certain amount of time + AGENT_CONTROL_NUDGE_LEFT_NEG = 0x1 << CONTROL_NUDGE_LEFT_NEG_INDEX, + /// Legacy, used if a key was pressed for less than a certain amount of time + AGENT_CONTROL_NUDGE_UP_POS = 0x1 << CONTROL_NUDGE_UP_POS_INDEX, + /// Legacy, used if a key was pressed for less than a certain amount of time + AGENT_CONTROL_NUDGE_UP_NEG = 0x1 << CONTROL_NUDGE_UP_NEG_INDEX, + /// + AGENT_CONTROL_TURN_LEFT = 0x1 << CONTROL_TURN_LEFT_INDEX, + /// + AGENT_CONTROL_TURN_RIGHT = 0x1 << CONTROL_TURN_RIGHT_INDEX, + /// Set when the avatar is idled or set to away. Note that the away animation is + /// activated separately from setting this flag + AGENT_CONTROL_AWAY = 0x1 << CONTROL_AWAY_INDEX, + /// + AGENT_CONTROL_LBUTTON_DOWN = 0x1 << CONTROL_LBUTTON_DOWN_INDEX, + /// + AGENT_CONTROL_LBUTTON_UP = 0x1 << CONTROL_LBUTTON_UP_INDEX, + /// + AGENT_CONTROL_ML_LBUTTON_DOWN = 0x1 << CONTROL_ML_LBUTTON_DOWN_INDEX, + /// + AGENT_CONTROL_ML_LBUTTON_UP = 0x1 << CONTROL_ML_LBUTTON_UP_INDEX + } + /// The Avatar's UUID, asset server public LLUUID ID; /// Avatar ID in Region (sim) it is in @@ -110,48 +183,82 @@ namespace libsecondlife public LLQuaternion Rotation; /// Region (aka sim) the Avatar is in public Region CurrentRegion; - + /// public string BornOn; - + /// public LLUUID ProfileImage; - + /// public LLUUID PartnerID; - + /// public string AboutText; - + /// public uint WantToMask; - + /// public string WantToText; - + /// public uint SkillsMask; - + /// public string SkillsText; - + /// public string FirstLifeText; - + /// public LLUUID FirstLifeImage; - + /// public bool Identified; - + /// public bool Transacted; - + /// public bool AllowPublish; - + /// public bool MaturePublish; - + /// public string CharterMember; - + /// public float Behavior; - + /// public float Appearance; - + /// public float Building; - + /// public string LanguagesText; - + /// public TextureEntry Textures; - + /// public string ProfileURL; + + protected const int CONTROL_AT_POS_INDEX = 0; + protected const int CONTROL_AT_NEG_INDEX = 1; + protected const int CONTROL_LEFT_POS_INDEX = 2; + protected const int CONTROL_LEFT_NEG_INDEX = 3; + protected const int CONTROL_UP_POS_INDEX = 4; + protected const int CONTROL_UP_NEG_INDEX = 5; + protected const int CONTROL_PITCH_POS_INDEX = 6; + protected const int CONTROL_PITCH_NEG_INDEX = 7; + protected const int CONTROL_YAW_POS_INDEX = 8; + protected const int CONTROL_YAW_NEG_INDEX = 9; + protected const int CONTROL_FAST_AT_INDEX = 10; + protected const int CONTROL_FAST_LEFT_INDEX = 11; + protected const int CONTROL_FAST_UP_INDEX = 12; + protected const int CONTROL_FLY_INDEX = 13; + protected const int CONTROL_STOP_INDEX = 14; + protected const int CONTROL_FINISH_ANIM_INDEX = 15; + protected const int CONTROL_STAND_UP_INDEX = 16; + protected const int CONTROL_SIT_ON_GROUND_INDEX = 17; + protected const int CONTROL_MOUSELOOK_INDEX = 18; + protected const int CONTROL_NUDGE_AT_POS_INDEX = 19; + protected const int CONTROL_NUDGE_AT_NEG_INDEX = 20; + protected const int CONTROL_NUDGE_LEFT_POS_INDEX = 21; + protected const int CONTROL_NUDGE_LEFT_NEG_INDEX = 22; + protected const int CONTROL_NUDGE_UP_POS_INDEX = 23; + protected const int CONTROL_NUDGE_UP_NEG_INDEX = 24; + protected const int CONTROL_TURN_LEFT_INDEX = 25; + protected const int CONTROL_TURN_RIGHT_INDEX = 26; + protected const int CONTROL_AWAY_INDEX = 27; + protected const int CONTROL_LBUTTON_DOWN_INDEX = 28; + protected const int CONTROL_LBUTTON_UP_INDEX = 29; + protected const int CONTROL_ML_LBUTTON_DOWN_INDEX = 30; + protected const int CONTROL_ML_LBUTTON_UP_INDEX = 31; + protected const int TOTAL_CONTROLS = 32; } /// @@ -216,38 +323,38 @@ namespace libsecondlife /// public MainAvatar(SecondLife client) { - PacketCallback callback; + NetworkManager.PacketCallback callback; Client = client; TeleportMessage = ""; // Coarse location callback - Client.Network.RegisterCallback(PacketType.CoarseLocationUpdate, new PacketCallback(CoarseLocationHandler)); + Client.Network.RegisterCallback(PacketType.CoarseLocationUpdate, new NetworkManager.PacketCallback(CoarseLocationHandler)); // Teleport callbacks - callback = new PacketCallback(TeleportHandler); + callback = new NetworkManager.PacketCallback(TeleportHandler); Client.Network.RegisterCallback(PacketType.TeleportStart, callback); Client.Network.RegisterCallback(PacketType.TeleportProgress, callback); Client.Network.RegisterCallback(PacketType.TeleportFailed, callback); Client.Network.RegisterCallback(PacketType.TeleportFinish, callback); // Instant Message callback - Client.Network.RegisterCallback(PacketType.ImprovedInstantMessage, new PacketCallback(InstantMessageHandler)); + Client.Network.RegisterCallback(PacketType.ImprovedInstantMessage, new NetworkManager.PacketCallback(InstantMessageHandler)); // Chat callback - Client.Network.RegisterCallback(PacketType.ChatFromSimulator, new PacketCallback(ChatHandler)); + Client.Network.RegisterCallback(PacketType.ChatFromSimulator, new NetworkManager.PacketCallback(ChatHandler)); TeleportTimer = new Timer(18000); TeleportTimer.Elapsed += new ElapsedEventHandler(TeleportTimerEvent); TeleportTimeout = false; // Movement complete callback - Client.Network.RegisterCallback(PacketType.AgentMovementComplete, new PacketCallback(MovementCompleteHandler)); + Client.Network.RegisterCallback(PacketType.AgentMovementComplete, new NetworkManager.PacketCallback(MovementCompleteHandler)); // Health callback - Client.Network.RegisterCallback(PacketType.HealthMessage, new PacketCallback(HealthHandler)); + Client.Network.RegisterCallback(PacketType.HealthMessage, new NetworkManager.PacketCallback(HealthHandler)); // Money callbacks - callback = new PacketCallback(BalanceHandler); + callback = new NetworkManager.PacketCallback(BalanceHandler); Client.Network.RegisterCallback(PacketType.MoneyBalanceReply, callback); Client.Network.RegisterCallback(PacketType.MoneySummaryReply, callback); Client.Network.RegisterCallback(PacketType.AdjustBalance, callback); diff --git a/libsecondlife-cs/AvatarManager.cs b/libsecondlife-cs/AvatarManager.cs index 2d5453aa..25cfd337 100644 --- a/libsecondlife-cs/AvatarManager.cs +++ b/libsecondlife-cs/AvatarManager.cs @@ -31,27 +31,43 @@ using libsecondlife.Packets; namespace libsecondlife { - /// - /// Triggered after friend request packet is sent out - /// - /// - /// - public delegate void FriendNotificationCallback(LLUUID agentID, bool online); - - /// - /// Triggered when a UUIDNameReply is received - /// - /// - public delegate void AgentNamesCallback(Dictionary names); - public delegate void AvatarPropertiesCallback(Avatar avatar); - public delegate void AvatarNameCallback(Avatar avatar); - public delegate void AvatarStatisticsCallback(Avatar avatar); - public delegate void AvatarIntrestsCallback(Avatar avatar); /// /// /// public class AvatarManager { + /// + /// Triggered after friend request packet is sent out + /// + /// + /// + public delegate void FriendNotificationCallback(LLUUID agentID, bool online); + /// + /// Triggered when a UUIDNameReply is received + /// + /// + public delegate void AgentNamesCallback(Dictionary names); + /// + /// + /// + /// + public delegate void AvatarPropertiesCallback(Avatar avatar); + /// + /// + /// + /// + public delegate void AvatarNameCallback(Avatar avatar); + /// + /// + /// + /// + public delegate void AvatarStatisticsCallback(Avatar avatar); + /// + /// + /// + /// + public delegate void AvatarInterestsCallback(Avatar avatar); + /// Triggered whenever a friend comes online or goes offline public event FriendNotificationCallback OnFriendNotification; @@ -60,7 +76,12 @@ namespace libsecondlife private AgentNamesCallback OnAgentNames; private Dictionary AvatarPropertiesCallbacks; private Dictionary AvatarStatisticsCallbacks; - private Dictionary AvatarIntrestsCallbacks; + private Dictionary AvatarInterestsCallbacks; + + /// + /// + /// + /// public AvatarManager(SecondLife client) { Client = client; @@ -68,15 +89,15 @@ namespace libsecondlife //Callback Dictionaries AvatarPropertiesCallbacks = new Dictionary(); AvatarStatisticsCallbacks = new Dictionary(); - AvatarIntrestsCallbacks = new Dictionary(); + AvatarInterestsCallbacks = new Dictionary(); // Friend notification callback - PacketCallback callback = new PacketCallback(FriendNotificationHandler); + NetworkManager.PacketCallback callback = new NetworkManager.PacketCallback(FriendNotificationHandler); Client.Network.RegisterCallback(PacketType.OnlineNotification, callback); Client.Network.RegisterCallback(PacketType.OfflineNotification, callback); - Client.Network.RegisterCallback(PacketType.UUIDNameReply, new PacketCallback(GetAgentNameHandler)); - Client.Network.RegisterCallback(PacketType.AvatarPropertiesReply, new PacketCallback(AvatarPropertiesHandler)); - Client.Network.RegisterCallback(PacketType.AvatarStatisticsReply, new PacketCallback(AvatarStatisticsHandler)); - Client.Network.RegisterCallback(PacketType.AvatarInterestsReply, new PacketCallback(AvatarIntrestsHandler)); + Client.Network.RegisterCallback(PacketType.UUIDNameReply, new NetworkManager.PacketCallback(GetAgentNameHandler)); + Client.Network.RegisterCallback(PacketType.AvatarPropertiesReply, new NetworkManager.PacketCallback(AvatarPropertiesHandler)); + Client.Network.RegisterCallback(PacketType.AvatarStatisticsReply, new NetworkManager.PacketCallback(AvatarStatisticsHandler)); + Client.Network.RegisterCallback(PacketType.AvatarInterestsReply, new NetworkManager.PacketCallback(AvatarInterestsHandler)); } @@ -92,11 +113,20 @@ namespace libsecondlife } } + /// + /// + /// + /// + /// public bool Contains(LLUUID id) { return Avatars.ContainsKey(id); } + /// + /// + /// + /// public void UpdateAvatar(Avatar a) { //Basic profile properties @@ -384,12 +414,12 @@ namespace libsecondlife } } - public void BeginAvatarPropertiesRequest(LLUUID avatarid, AvatarPropertiesCallback apc, AvatarStatisticsCallback asc, AvatarIntrestsCallback aic) + public void BeginAvatarPropertiesRequest(LLUUID avatarid, AvatarPropertiesCallback apc, AvatarStatisticsCallback asc, AvatarInterestsCallback aic) { //Set teh callback! AvatarPropertiesCallbacks[avatarid] = apc; AvatarStatisticsCallbacks[avatarid] = asc; - AvatarIntrestsCallbacks[avatarid] = aic; + AvatarInterestsCallbacks[avatarid] = aic; //Oh noes //Packet construction, good times AvatarPropertiesRequestPacket aprp = new AvatarPropertiesRequestPacket(); @@ -402,7 +432,7 @@ namespace libsecondlife Client.Network.SendPacket(aprp); } - public void AvatarIntrestsHandler(Packet packet, Simulator simulator) + private void AvatarInterestsHandler(Packet packet, Simulator simulator) { AvatarInterestsReplyPacket airp = (AvatarInterestsReplyPacket)packet; Avatar av; @@ -426,8 +456,8 @@ namespace libsecondlife av.SkillsText = Helpers.FieldToString(airp.PropertiesData.SkillsText); av.LanguagesText = Helpers.FieldToString(airp.PropertiesData.LanguagesText); } - if (AvatarIntrestsCallbacks.ContainsKey(airp.AgentData.AvatarID) && AvatarIntrestsCallbacks[airp.AgentData.AvatarID] != null) - AvatarIntrestsCallbacks[airp.AgentData.AvatarID](av); + if (AvatarInterestsCallbacks.ContainsKey(airp.AgentData.AvatarID) && AvatarInterestsCallbacks[airp.AgentData.AvatarID] != null) + AvatarInterestsCallbacks[airp.AgentData.AvatarID](av); } } } diff --git a/libsecondlife-cs/GridManager.cs b/libsecondlife-cs/GridManager.cs index 0dcad0a3..88206bee 100644 --- a/libsecondlife-cs/GridManager.cs +++ b/libsecondlife-cs/GridManager.cs @@ -114,8 +114,8 @@ namespace libsecondlife Regions = new Dictionary(); SunDirection = LLVector3.Zero; - Client.Network.RegisterCallback(PacketType.MapBlockReply, new PacketCallback(MapBlockReplyHandler)); - Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new PacketCallback(TimeMessageHandler)); + Client.Network.RegisterCallback(PacketType.MapBlockReply, new NetworkManager.PacketCallback(MapBlockReplyHandler)); + Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new NetworkManager.PacketCallback(TimeMessageHandler)); } /// diff --git a/libsecondlife-cs/GroupManager.cs b/libsecondlife-cs/GroupManager.cs index f22c3d96..aaa1b580 100644 --- a/libsecondlife-cs/GroupManager.cs +++ b/libsecondlife-cs/GroupManager.cs @@ -397,17 +397,17 @@ namespace libsecondlife GroupRolesCaches = new Dictionary>(); GroupRolesMembersCaches = new Dictionary>>(); - Client.Network.RegisterCallback(PacketType.AgentGroupDataUpdate, new PacketCallback(GroupDataHandler)); - Client.Network.RegisterCallback(PacketType.GroupTitlesReply, new PacketCallback(GroupTitlesHandler)); - Client.Network.RegisterCallback(PacketType.GroupProfileReply, new PacketCallback(GroupProfileHandler)); - Client.Network.RegisterCallback(PacketType.GroupMembersReply, new PacketCallback(GroupMembersHandler)); - Client.Network.RegisterCallback(PacketType.GroupRoleDataReply, new PacketCallback(GroupRoleDataHandler)); - Client.Network.RegisterCallback(PacketType.GroupRoleMembersReply, new PacketCallback(GroupRoleMembersHandler)); - Client.Network.RegisterCallback(PacketType.GroupActiveProposalItemReply, new PacketCallback(GroupActiveProposalItemHandler)); - Client.Network.RegisterCallback(PacketType.GroupVoteHistoryItemReply, new PacketCallback(GroupVoteHistoryItemHandler)); - Client.Network.RegisterCallback(PacketType.GroupAccountSummaryReply, new PacketCallback(GroupAccountSummaryHandler)); - Client.Network.RegisterCallback(PacketType.GroupAccountDetailsReply, new PacketCallback(GroupAccountDetailsHandler)); - Client.Network.RegisterCallback(PacketType.GroupAccountTransactionsReply, new PacketCallback(GroupAccountTransactionsHandler)); + Client.Network.RegisterCallback(PacketType.AgentGroupDataUpdate, new NetworkManager.PacketCallback(GroupDataHandler)); + Client.Network.RegisterCallback(PacketType.GroupTitlesReply, new NetworkManager.PacketCallback(GroupTitlesHandler)); + Client.Network.RegisterCallback(PacketType.GroupProfileReply, new NetworkManager.PacketCallback(GroupProfileHandler)); + Client.Network.RegisterCallback(PacketType.GroupMembersReply, new NetworkManager.PacketCallback(GroupMembersHandler)); + Client.Network.RegisterCallback(PacketType.GroupRoleDataReply, new NetworkManager.PacketCallback(GroupRoleDataHandler)); + Client.Network.RegisterCallback(PacketType.GroupRoleMembersReply, new NetworkManager.PacketCallback(GroupRoleMembersHandler)); + Client.Network.RegisterCallback(PacketType.GroupActiveProposalItemReply, new NetworkManager.PacketCallback(GroupActiveProposalItemHandler)); + Client.Network.RegisterCallback(PacketType.GroupVoteHistoryItemReply, new NetworkManager.PacketCallback(GroupVoteHistoryItemHandler)); + Client.Network.RegisterCallback(PacketType.GroupAccountSummaryReply, new NetworkManager.PacketCallback(GroupAccountSummaryHandler)); + Client.Network.RegisterCallback(PacketType.GroupAccountDetailsReply, new NetworkManager.PacketCallback(GroupAccountDetailsHandler)); + Client.Network.RegisterCallback(PacketType.GroupAccountTransactionsReply, new NetworkManager.PacketCallback(GroupAccountTransactionsHandler)); } /// diff --git a/libsecondlife-cs/InventorySystem/InventoryManager.cs b/libsecondlife-cs/InventorySystem/InventoryManager.cs index 60366092..4125dcb9 100644 --- a/libsecondlife-cs/InventorySystem/InventoryManager.cs +++ b/libsecondlife-cs/InventorySystem/InventoryManager.cs @@ -88,12 +88,10 @@ namespace libsecondlife.InventorySystem resetFoldersByUUID(); // Setup the callback for Inventory Downloads - PacketCallback InventoryDescendentsCallback = new PacketCallback(InventoryDescendentsHandler); - slClient.Network.RegisterCallback(PacketType.InventoryDescendents, InventoryDescendentsCallback); + slClient.Network.RegisterCallback(PacketType.InventoryDescendents, new NetworkManager.PacketCallback(InventoryDescendentsHandler)); // Setup the callback for Inventory Creation Update - PacketCallback UpdateCreateInventoryItemCallback = new PacketCallback(UpdateCreateInventoryItemHandler); - slClient.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, UpdateCreateInventoryItemCallback); + slClient.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, new NetworkManager.PacketCallback(UpdateCreateInventoryItemHandler)); } diff --git a/libsecondlife-cs/NetworkManager.cs b/libsecondlife-cs/NetworkManager.cs index 5fbcf415..ca0f5e48 100644 --- a/libsecondlife-cs/NetworkManager.cs +++ b/libsecondlife-cs/NetworkManager.cs @@ -35,38 +35,6 @@ using libsecondlife.Packets; namespace libsecondlife { - /// - /// - /// - /// - /// - public delegate void PacketCallback(Packet packet, Simulator simulator); - /// - /// - /// - /// - /// - public delegate void SimDisconnectCallback(Simulator simulator, DisconnectType reason); - /// - /// - /// - /// - /// - public delegate void DisconnectCallback(DisconnectType reason, string message); - - /// - /// - /// - public enum DisconnectType - { - /// - ClientInitiated, - /// - ServerInitiated, - /// - NetworkTimeout - } - /// /// This exception is thrown whenever a network operation is attempted /// without a network connection. @@ -122,7 +90,7 @@ namespace libsecondlife private SecondLife Client; private NetworkManager Network; - private Dictionary> Callbacks; + private Dictionary> Callbacks; private ushort Sequence; private byte[] RecvBuffer; private Socket Connection; @@ -144,8 +112,8 @@ namespace libsecondlife /// /// /// - public Simulator(SecondLife client, Dictionary> callbacks, uint circuit, - IPAddress ip, int port) + public Simulator(SecondLife client, Dictionary> callbacks, + uint circuit, IPAddress ip, int port) { Client = client; Network = client.Network; @@ -520,10 +488,10 @@ namespace libsecondlife { if (Callbacks.ContainsKey(packet.Type)) { - List callbackArray = Callbacks[packet.Type]; + List callbackArray = Callbacks[packet.Type]; // Fire any registered callbacks - foreach (PacketCallback callback in callbackArray) + foreach (NetworkManager.PacketCallback callback in callbackArray) { if (callback != null) { @@ -534,10 +502,10 @@ namespace libsecondlife if (Callbacks.ContainsKey(PacketType.Default)) { - List callbackArray = Callbacks[PacketType.Default]; + List callbackArray = Callbacks[PacketType.Default]; // Fire any registered callbacks - foreach (PacketCallback callback in callbackArray) + foreach (NetworkManager.PacketCallback callback in callbackArray) { if (callback != null) { @@ -573,6 +541,43 @@ namespace libsecondlife /// public class NetworkManager { + /// + /// Coupled with RegisterCallback(), this is triggered whenever a packet + /// of a registered type is received + /// + /// + /// + public delegate void PacketCallback(Packet packet, Simulator simulator); + /// + /// Triggered when a simulator other than the simulator that is currently + /// being occupied disconnects for whatever reason + /// + /// The simulator that disconnected, which will become a null + /// reference after the callback is finished + /// Enumeration explaining the reason for the disconnect + public delegate void SimDisconnectCallback(Simulator simulator, DisconnectType reason); + /// + /// Triggered when we are logged out of the grid due to a simulator request, + /// client request, network timeout, or any other cause + /// + /// Enumeration explaining the reason for the disconnect + /// If we were logged out by the simulator, this + /// is a message explaining why + public delegate void DisconnectCallback(DisconnectType reason, string message); + + /// + /// Explains why a simulator or the grid disconnected from us + /// + public enum DisconnectType + { + /// The client requested the logout or simulator disconnect + ClientInitiated, + /// The server notified us that it is disconnecting + ServerInitiated, + /// Either a socket was closed or network traffic timed out + NetworkTimeout + } + /// /// The permanent UUID for the logged in avatar /// diff --git a/libsecondlife-cs/ObjectManager.cs b/libsecondlife-cs/ObjectManager.cs index 613b3fa8..88556f61 100644 --- a/libsecondlife-cs/ObjectManager.cs +++ b/libsecondlife-cs/ObjectManager.cs @@ -31,54 +31,6 @@ using libsecondlife.Packets; namespace libsecondlife { - /// - /// - /// - /// - /// - /// - /// - public delegate void NewPrimCallback(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - /// - /// - public delegate void NewAvatarCallback(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - /// - /// - public delegate void PrimMovedCallback(Simulator simulator, PrimUpdate prim, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - /// - /// - public delegate void AvatarMovedCallback(Simulator simulator, AvatarUpdate avatar, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - public delegate void KillObjectCallback(Simulator simulator, uint objectID); - - public enum PCode - { - Prim = 9, - Avatar = 47, - Grass = 95, - ParticleSystem = 143, - Tree = 255 - } - /// /// Contains all of the variables sent in an object update packet for a /// prim object. Used to track position and movement of prims. @@ -131,6 +83,68 @@ namespace libsecondlife /// public class ObjectManager { + /// + /// + /// + /// + /// + /// + /// + public delegate void NewPrimCallback(Simulator simulator, PrimObject prim, ulong regionHandle, + ushort timeDilation); + /// + /// + /// + /// + /// + /// + /// + public delegate void NewAvatarCallback(Simulator simulator, Avatar avatar, ulong regionHandle, + ushort timeDilation); + /// + /// + /// + /// + /// + /// + /// + public delegate void PrimMovedCallback(Simulator simulator, PrimUpdate prim, ulong regionHandle, + ushort timeDilation); + /// + /// + /// + /// + /// + /// + /// + public delegate void AvatarMovedCallback(Simulator simulator, AvatarUpdate avatar, ulong regionHandle, + ushort timeDilation); + /// + /// + /// + /// + /// + public delegate void KillObjectCallback(Simulator simulator, uint objectID); + + /// + /// + /// + public enum PCode + { + /// + Prim = 9, + /// + Avatar = 47, + /// + Grass = 95, + /// + NewTree = 111, + /// + ParticleSystem = 143, + /// + Tree = 255 + } + /// /// This event will be raised for every ObjectUpdate block that /// contains a new prim. @@ -184,11 +198,11 @@ namespace libsecondlife { Client = client; - Client.Network.RegisterCallback(PacketType.ObjectUpdate, new PacketCallback(UpdateHandler)); - Client.Network.RegisterCallback(PacketType.ImprovedTerseObjectUpdate, new PacketCallback(TerseUpdateHandler)); - Client.Network.RegisterCallback(PacketType.ObjectUpdateCompressed, new PacketCallback(CompressedUpdateHandler)); - Client.Network.RegisterCallback(PacketType.ObjectUpdateCached, new PacketCallback(CachedUpdateHandler)); - Client.Network.RegisterCallback(PacketType.KillObject, new PacketCallback(KillObjectHandler)); + Client.Network.RegisterCallback(PacketType.ObjectUpdate, new NetworkManager.PacketCallback(UpdateHandler)); + Client.Network.RegisterCallback(PacketType.ImprovedTerseObjectUpdate, new NetworkManager.PacketCallback(TerseUpdateHandler)); + Client.Network.RegisterCallback(PacketType.ObjectUpdateCompressed, new NetworkManager.PacketCallback(CompressedUpdateHandler)); + Client.Network.RegisterCallback(PacketType.ObjectUpdateCached, new NetworkManager.PacketCallback(CachedUpdateHandler)); + Client.Network.RegisterCallback(PacketType.KillObject, new NetworkManager.PacketCallback(KillObjectHandler)); } public void RequestObject(Simulator simulator, uint localID) @@ -280,15 +294,15 @@ namespace libsecondlife prim.ProfileCurve = block.ProfileCurve; prim.PathBegin = PrimObject.PathBeginFloat(block.PathBegin); prim.PathEnd = PrimObject.PathEndFloat(block.PathEnd); - prim.PathTaperX = PrimObject.PathScaleFloat(block.PathScaleX); - prim.PathTaperY = PrimObject.PathScaleFloat(block.PathScaleY); + prim.PathScaleX = PrimObject.PathScaleFloat(block.PathScaleX); + prim.PathScaleY = PrimObject.PathScaleFloat(block.PathScaleY); prim.PathShearX = PrimObject.PathShearFloat(block.PathShearX); prim.PathShearY = PrimObject.PathShearFloat(block.PathShearY); prim.PathTwist = block.PathTwist; //PrimObject.PathTwistFloat(block.PathTwist); prim.PathTwistBegin = block.PathTwistBegin; //PrimObject.PathTwistFloat(block.PathTwistBegin); prim.PathRadiusOffset = PrimObject.PathRadiusOffsetFloat(block.PathRadiusOffset); - //prim.PathTaperX = PrimObject.PathTaperFloat((byte)block.PathTaperX); - //prim.PathTaperY = PrimObject.PathTaperFloat((byte)block.PathTaperY); + prim.PathTaperX = PrimObject.PathTaperFloat((byte)block.PathTaperX); + prim.PathTaperY = PrimObject.PathTaperFloat((byte)block.PathTaperY); prim.PathRevolutions = PrimObject.PathRevolutionsFloat(block.PathRevolutions); prim.PathSkew = PrimObject.PathSkewFloat((byte)block.PathSkew); prim.ProfileBegin = PrimObject.ProfileBeginFloat(block.ProfileBegin); diff --git a/libsecondlife-cs/Parcel.cs b/libsecondlife-cs/Parcel.cs index 562b353b..1063a9b9 100644 --- a/libsecondlife-cs/Parcel.cs +++ b/libsecondlife-cs/Parcel.cs @@ -372,10 +372,10 @@ namespace libsecondlife DirLandTimeout = false; // Setup the callbacks - Client.Network.RegisterCallback(PacketType.DirLandReply, new PacketCallback(DirLandReplyHandler)); - Client.Network.RegisterCallback(PacketType.ParcelInfoReply, new PacketCallback(ParcelInfoReplyHandler)); - Client.Network.RegisterCallback(PacketType.ParcelProperties, new PacketCallback(ParcelPropertiesHandler)); - Client.Network.RegisterCallback(PacketType.ParcelDwellReply, new PacketCallback(ParcelDwellReplyHandler)); + Client.Network.RegisterCallback(PacketType.DirLandReply, new NetworkManager.PacketCallback(DirLandReplyHandler)); + Client.Network.RegisterCallback(PacketType.ParcelInfoReply, new NetworkManager.PacketCallback(ParcelInfoReplyHandler)); + Client.Network.RegisterCallback(PacketType.ParcelProperties, new NetworkManager.PacketCallback(ParcelPropertiesHandler)); + Client.Network.RegisterCallback(PacketType.ParcelDwellReply, new NetworkManager.PacketCallback(ParcelDwellReplyHandler)); ParcelInfoParcel = null; } diff --git a/libsecondlife-cs/ParticleSystem.cs b/libsecondlife-cs/ParticleSystem.cs index e59fe507..a2449d85 100644 --- a/libsecondlife-cs/ParticleSystem.cs +++ b/libsecondlife-cs/ParticleSystem.cs @@ -4,6 +4,9 @@ using System.Text; namespace libsecondlife { + /// + /// + /// public class ParticleSystem { public uint PartStartRGBA; @@ -47,6 +50,9 @@ namespace libsecondlife AngleConeEmpty = 0x10 } + /// + /// + /// [Flags] public enum ParticleFlags : ushort { @@ -62,11 +68,21 @@ namespace libsecondlife Emissive = 0x100 } + /// + /// + /// + /// + /// public ParticleSystem(byte[] data, int pos) { FromBytes(data, pos); } + /// + /// + /// + /// + /// private void FromBytes(byte[] data, int pos) { int i = pos; diff --git a/libsecondlife-cs/Prims.cs b/libsecondlife-cs/Prims.cs index a704b92d..0eb25d6b 100644 --- a/libsecondlife-cs/Prims.cs +++ b/libsecondlife-cs/Prims.cs @@ -84,7 +84,7 @@ namespace libsecondlife /// public int PathTwist = 0; /// - public PCode PCode; + public ObjectManager.PCode PCode; /// public TextureEntry Textures; /// @@ -114,7 +114,7 @@ namespace libsecondlife public PrimObject(SecondLife client) { Client = client; - PCode = PCode.Prim; + PCode = ObjectManager.PCode.Prim; Textures = new TextureEntry(); } @@ -125,7 +125,7 @@ namespace libsecondlife public PrimObject(SecondLife client, LLUUID texture) { Client = client; - PCode = PCode.Prim; + PCode = ObjectManager.PCode.Prim; Textures = new TextureEntry(); Textures.DefaultTexture.TextureID = texture; } diff --git a/libsecondlife-cs/Types.cs b/libsecondlife-cs/Types.cs index a175e1a6..76701278 100644 --- a/libsecondlife-cs/Types.cs +++ b/libsecondlife-cs/Types.cs @@ -418,7 +418,7 @@ namespace libsecondlife } /// - /// An LLVector3 with a value of <0,0,0> + /// An LLVector3 with a value of 0,0,0 /// public readonly static LLVector3 Zero = new LLVector3(); } @@ -505,7 +505,7 @@ namespace libsecondlife } /// - /// An LLVector3d with a value of <0,0,0> + /// An LLVector3d with a value of 0,0,0 /// public readonly static LLVector3d Zero = new LLVector3d(); } @@ -585,7 +585,7 @@ namespace libsecondlife } /// - /// An LLVector4 with a value of <0,0,0,0> + /// An LLVector4 with a value of 0,0,0,0 /// public readonly static LLVector4 Zero = new LLVector4(); } @@ -725,7 +725,7 @@ namespace libsecondlife } /// - /// An LLQuaternion with a value of <0,0,0,1> + /// An LLQuaternion with a value of 0,0,0,1 /// public readonly static LLQuaternion Identity = new LLQuaternion(); } diff --git a/libsecondlife-cs/examples/IA_TestAsyncImage/IA_TestAsyncImage.cs b/libsecondlife-cs/examples/IA_TestAsyncImage/IA_TestAsyncImage.cs index 993857f7..0d7a6e61 100644 --- a/libsecondlife-cs/examples/IA_TestAsyncImage/IA_TestAsyncImage.cs +++ b/libsecondlife-cs/examples/IA_TestAsyncImage/IA_TestAsyncImage.cs @@ -24,8 +24,8 @@ namespace IA_TestAsyncImage TestAsync app = new TestAsync(); app.DownloadInventoryOnConnect = false; - app.client.Objects.OnNewPrim += new NewPrimCallback(app.Objects_OnNewPrim); - app.client.Objects.OnNewAvatar += new NewAvatarCallback(app.Objects_OnNewAvatar); + app.client.Objects.OnNewPrim += new ObjectManager.NewPrimCallback(app.Objects_OnNewPrim); + app.client.Objects.OnNewAvatar += new ObjectManager.NewAvatarCallback(app.Objects_OnNewAvatar); app.Connect(args[0], args[1], args[2]); diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs index 9addf921..054cfa21 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs @@ -84,7 +84,7 @@ namespace groupmanager numFee.Value = Profile.MembershipFee; chkMature.Checked = Profile.MaturePublish; - Client.Avatars.BeginGetAvatarName(Profile.FounderID, new AgentNamesCallback(AgentNamesHandler)); + Client.Avatars.BeginGetAvatarName(Profile.FounderID, new AvatarManager.AgentNamesCallback(AgentNamesHandler)); } private void AgentNamesHandler(Dictionary names) @@ -209,7 +209,7 @@ namespace groupmanager } } - Client.Avatars.BeginGetAvatarNames(requestids, new AgentNamesCallback(AgentNamesHandler)); + Client.Avatars.BeginGetAvatarNames(requestids, new AvatarManager.AgentNamesCallback(AgentNamesHandler)); } private void GroupTitlesHandler(Dictionary titles) diff --git a/libsecondlife-cs/examples/name2key/name2key.cs b/libsecondlife-cs/examples/name2key/name2key.cs index 066c5151..86ac2194 100644 --- a/libsecondlife-cs/examples/name2key/name2key.cs +++ b/libsecondlife-cs/examples/name2key/name2key.cs @@ -73,7 +73,7 @@ namespace name2key client = new SecondLife(); // Setup the callback - client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(QueryHandler)); + client.Network.RegisterCallback(PacketType.DirPeopleReply, new NetworkManager.PacketCallback(QueryHandler)); // Setup the login values Dictionary loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], diff --git a/libsecondlife-cs/examples/primexport/frmPrimExport.cs b/libsecondlife-cs/examples/primexport/frmPrimExport.cs index 444141ff..22db002a 100644 --- a/libsecondlife-cs/examples/primexport/frmPrimExport.cs +++ b/libsecondlife-cs/examples/primexport/frmPrimExport.cs @@ -28,7 +28,7 @@ namespace primexport private System.ComponentModel.IContainer components = null; private SecondLife client; - private NewPrimCallback primCallback; + private ObjectManager.NewPrimCallback primCallback; private string currentText; private Dictionary Prims; private string Filename = ""; @@ -191,7 +191,7 @@ namespace primexport { InitializeComponent(); - primCallback = new NewPrimCallback(PrimSeen); + primCallback = new ObjectManager.NewPrimCallback(PrimSeen); Prims = new Dictionary(); client = new SecondLife(); diff --git a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs index 06d7fcd3..f29fa271 100644 --- a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs +++ b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs @@ -381,9 +381,8 @@ namespace SLAccountant client = new SecondLife(); // Install our packet handlers - //client.Network.RegisterCallback(PacketType.AvatarAppearance, new PacketCallback(AvatarAppearanceHandler)); - client.Network.RegisterCallback(PacketType.MoneyBalanceReply, new PacketCallback(BalanceHandler)); - client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(DirPeopleHandler)); + client.Network.RegisterCallback(PacketType.MoneyBalanceReply, new NetworkManager.PacketCallback(BalanceHandler)); + client.Network.RegisterCallback(PacketType.DirPeopleReply, new NetworkManager.PacketCallback(DirPeopleHandler)); grpLogin.Enabled = true; } @@ -395,11 +394,8 @@ namespace SLAccountant cmdConnect.Text = "Disconnect"; txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - Dictionary loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, - txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", - "Win", "0", "accountant", "jhurliman@wsu.edu"); - - if (client.Network.Login(loginParams)) + if (client.Network.Login(txtFirstName.Text, txtLastName.Text, txtPassword.Text, + "accountant", "jhurliman@wsu.edu")) { Random rand = new Random(); diff --git a/libsecondlife-cs/examples/sldump/sldump.cs b/libsecondlife-cs/examples/sldump/sldump.cs index 7164c68e..52537c3d 100644 --- a/libsecondlife-cs/examples/sldump/sldump.cs +++ b/libsecondlife-cs/examples/sldump/sldump.cs @@ -40,13 +40,13 @@ namespace sldump //Console.WriteLine(packet.ToString()); } - public static void DisconnectHandler(DisconnectType type, string message) + public static void DisconnectHandler(NetworkManager.DisconnectType type, string message) { - if (type == DisconnectType.NetworkTimeout) + if (type == NetworkManager.DisconnectType.NetworkTimeout) { Console.WriteLine("Network connection timed out, disconnected"); } - else if (type == DisconnectType.ServerInitiated) + else if (type == NetworkManager.DisconnectType.ServerInitiated) { Console.WriteLine("Server disconnected us: " + message); } @@ -103,17 +103,10 @@ namespace sldump } // Setup the packet callback and disconnect event handler - client.Network.RegisterCallback(PacketType.Default, new PacketCallback(DefaultHandler)); - client.Network.OnDisconnected += new DisconnectCallback(DisconnectHandler); + client.Network.RegisterCallback(PacketType.Default, new NetworkManager.PacketCallback(DefaultHandler)); + client.Network.OnDisconnected += new NetworkManager.DisconnectCallback(DisconnectHandler); - Dictionary loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], - "0", "last", "Win", "0", "sldump", "contact@libsecondlife.org"); - - // An example of how to pass additional options to the login server - //loginParams["id0"] = "65e142a8d3c1ee6632259f111cb168c9"; - //loginParams["viewer_digest"] = "0e63550f-0991-a092-3158-b4206e728ffa"; - - if (!client.Network.Login(loginParams/*, "http://127.0.0.1:8080/"*/)) + if (!client.Network.Login(args[0], args[1], args[2], "sldump", "contact@libsecondlife.org")) { // Login failed Console.WriteLine("Error logging in: " + client.Network.LoginError); diff --git a/libsecondlife-cs/tests/Tests.cs b/libsecondlife-cs/tests/Tests.cs index 7c90641c..6f07c1ab 100644 --- a/libsecondlife-cs/tests/Tests.cs +++ b/libsecondlife-cs/tests/Tests.cs @@ -22,7 +22,7 @@ namespace libsecondlife.Tests //string startLoc = NetworkManager.StartLocation("ahern", 128, 128, 32); // Register callbacks - Client.Network.RegisterCallback(PacketType.ObjectUpdate, new PacketCallback(ObjectUpdateHandler)); + Client.Network.RegisterCallback(PacketType.ObjectUpdate, new NetworkManager.PacketCallback(ObjectUpdateHandler)); bool result = Client.Network.Login("Testing", "Anvil", "testinganvil", "Unit Test Framework", "contact@libsecondlife.org");