/// <summary> /// Get grid region information using the region name, this function /// will block until it can find the region or gives up /// </summary> /// <param name="name">Name of sim you're looking for</param> /// <param name="layer">Layer that you are requesting</param> /// <param name="region">Will contain a GridRegion for the sim you're /// looking for if successful, otherwise an empty structure</param> /// <returns>True if the GridRegion was successfully fetched, otherwise /// false</returns> public bool GetGridRegion(string name, GridLayerType layer, out GridRegion region) { if (String.IsNullOrEmpty(name)) { Logger.Log("GetGridRegion called with a null or empty region name", Helpers.LogLevel.Error, Client); region = new GridRegion(); return(false); } // All lookups are done using lowercase sim names name = name.ToLower(); if (Regions.ContainsKey(name)) { // We already have this GridRegion structure region = Regions[name]; return(true); } else { AutoResetEvent regionEvent = new AutoResetEvent(false); GridRegionCallback callback = delegate(GridRegion gridRegion) { if (gridRegion.Name == name) { regionEvent.Set(); } }; OnGridRegion += callback; RequestMapRegion(name, layer); regionEvent.WaitOne(Client.Settings.MAP_REQUEST_TIMEOUT, false); OnGridRegion -= callback; if (Regions.ContainsKey(name)) { // The region was found after our request region = Regions[name]; return(true); } else { Logger.Log("Couldn't find region " + name, Helpers.LogLevel.Warning, Client); region = new GridRegion(); return(false); } } }
/// <summary> /// /// </summary> /// <param name="name">Region Name you're requesting data for</param> /// <param name="grc">CallBack being used to process the response</param> public void BeginGetGridRegion(string name, GridRegionCallback grc) { OnRegionAddInternal = grc; BeginGetGridRegionName = name.ToLower(); if (Regions.ContainsKey(BeginGetGridRegionName)) { OnRegionAdd(Regions[BeginGetGridRegionName]); } else { MapNameRequestPacket map = new MapNameRequestPacket(); map.AgentData.AgentID = Client.Network.AgentID; map.AgentData.SessionID = Client.Network.SessionID; map.NameData.Name = Helpers.StringToField(BeginGetGridRegionName); Client.Network.SendPacket(map); } }
/// <summary> /// Begin process to get information for a Region /// </summary> /// <param name="name">Region Name you're requesting data for</param> /// <param name="grc">CallBack being used to process the response</param> public void BeginGetGridRegion(string name, GridRegionCallback grc) { OnRegionAddInternal = grc; BeginGetGridRegionName = name.ToLower(); if (Regions.ContainsKey(BeginGetGridRegionName)) { OnRegionAdd(Regions[BeginGetGridRegionName]); } else { MapNameRequestPacket map = new MapNameRequestPacket(); map.AgentData.AgentID = Client.Network.AgentID; map.AgentData.SessionID = Client.Network.SessionID; map.NameData.Name = Helpers.StringToField(BeginGetGridRegionName); Client.Network.SendPacket(map); } }