private void DirLandReplyHandler(Packet packet, Simulator simulator) { if (OnDirLandReply != null) { List <DirectoryParcel> parcelsForSale = new List <DirectoryParcel>(); DirLandReplyPacket reply = (DirLandReplyPacket)packet; foreach (DirLandReplyPacket.QueryRepliesBlock block in reply.QueryReplies) { DirectoryParcel dirParcel = new DirectoryParcel(); dirParcel.ActualArea = block.ActualArea; dirParcel.ID = block.ParcelID; dirParcel.Name = Helpers.FieldToUTF8String(block.Name); dirParcel.SalePrice = block.SalePrice; dirParcel.Auction = block.Auction; dirParcel.ForSale = block.ForSale; parcelsForSale.Add(dirParcel); } try { OnDirLandReply(parcelsForSale); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } }
//private void ParcelInfoTimerEvent(object source, System.Timers.ElapsedEventArgs ea) //{ // ParcelInfoTimeout = true; //} private void DirLandReplyHandler(Packet packet, Simulator simulator) { if (!DirLandTimeout) { // Reset the timer DirLandTimer.Stop(); DirLandTimer.Start(); DirLandReplyPacket reply = (DirLandReplyPacket)packet; foreach (DirLandReplyPacket.QueryRepliesBlock block in reply.QueryReplies) { // if (block.ReservedNewbie == ReservedNewbie && // block.Auction == Auction && // block.ForSale == ForSale) // FIXME FIXME FIXME { DirectoryParcel parcel = new DirectoryParcel(); parcel.ActualArea = block.ActualArea; parcel.ID = block.ParcelID; parcel.Name = Helpers.FieldToString(block.Name); parcel.SalePrice = block.SalePrice; ParcelsForSale.Add(parcel); } } } else { Client.Log("Received a DirLandReply after the timeout, ignoring", Helpers.LogLevel.Warning); } }
/// <summary> /// Parcel (subdivided simulator lots) Subsystem /// </summary> /// <param name="client"></param> public ParcelManager(SecondLife client) { Client = client; ParcelsForSale = new List <DirectoryParcel>(); // Setup the timer DirLandTimer = new Timer(8000); DirLandTimer.Elapsed += new ElapsedEventHandler(DirLandTimerEvent); DirLandTimeout = false; // Setup the callbacks 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; }
/// <summary> /// /// </summary> /// <param name="parcel"></param> /// <returns></returns> public bool RequestParcelInfo(DirectoryParcel parcel) { int attempts = 0; Beginning: if (attempts++ > 3) { return(false); } Finished = false; ParcelInfoTimeout = false; ParcelInfoParcel = parcel; // // Setup the timer // Timer ParcelInfoTimer = new Timer(5000); // ParcelInfoTimer.Elapsed += new ElapsedEventHandler(ParcelInfoTimerEvent); // ParcelInfoTimeout = false; // // Build the ParcelInfoRequest packet // ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); // request.AgentData.AgentID = Client.Network.AgentID; // request.AgentData.SessionID = Client.Network.SessionID; // request.Data.ParcelID = parcel.ID; // // Start the timer // ParcelInfoTimer.Start(); // Client.Network.SendPacket((Packet)request); while (!Finished) { // FIXME: This can easily cause an infinite loop if (ParcelInfoTimeout) { goto Beginning; } Client.Tick(); } return(true); }
private void DirLandReplyHandler(Packet packet, Simulator simulator) { if (OnDirLandReply != null) { List<DirectoryParcel> parcelsForSale = new List<DirectoryParcel>(); DirLandReplyPacket reply = (DirLandReplyPacket)packet; foreach (DirLandReplyPacket.QueryRepliesBlock block in reply.QueryReplies) { DirectoryParcel dirParcel = new DirectoryParcel(); dirParcel.ActualArea = block.ActualArea; dirParcel.ID = block.ParcelID; dirParcel.Name = Helpers.FieldToUTF8String(block.Name); dirParcel.SalePrice = block.SalePrice; dirParcel.Auction = block.Auction; dirParcel.ForSale = block.ForSale; parcelsForSale.Add(dirParcel); } try { OnDirLandReply(parcelsForSale); } catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } }
/// <summary> /// /// </summary> /// <param name="parcel"></param> /// <returns></returns> public bool RequestParcelInfo(DirectoryParcel parcel) { int attempts = 0; Beginning: if (attempts++ > 3) { return false; } Finished = false; ParcelInfoTimeout = false; ParcelInfoParcel = parcel; // // Setup the timer // Timer ParcelInfoTimer = new Timer(5000); // ParcelInfoTimer.Elapsed += new ElapsedEventHandler(ParcelInfoTimerEvent); // ParcelInfoTimeout = false; // // Build the ParcelInfoRequest packet // ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); // request.AgentData.AgentID = Client.Network.AgentID; // request.AgentData.SessionID = Client.Network.SessionID; // request.Data.ParcelID = parcel.ID; // // Start the timer // ParcelInfoTimer.Start(); // Client.Network.SendPacket((Packet)request); while (!Finished) { // FIXME: This can easily cause an infinite loop if (ParcelInfoTimeout) { goto Beginning; } Client.Tick(); } return true; }
/// <summary> /// Parcel (subdivided simulator lots) Subsystem /// </summary> /// <param name="client"></param> public ParcelManager(SecondLife client) { Client = client; ParcelsForSale = new List<DirectoryParcel>(); // Setup the timer DirLandTimer = new Timer(8000); DirLandTimer.Elapsed += new ElapsedEventHandler(DirLandTimerEvent); DirLandTimeout = false; // Setup the callbacks 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; }