public void testUncompressWithDotInfoTLD() { String testURL = "http://google.info"; byte[] testBytes = { 0x02, (byte)'g', (byte)'o', (byte)'o', (byte)'g', (byte)'l', (byte)'e', 0x0b }; Assert.AreEqual(testURL, UrlBeaconUrlCompressor.Uncompress(testBytes)); }
public void testUncompressWithSubdomainsAndTrailingSlash() { String testURL = "http://www.forums.google.com/"; byte[] testBytes = { 0x00, (byte)'f', (byte)'o', (byte)'r', (byte)'u', (byte)'m', (byte)'s', (byte)'.', (byte)'g', (byte)'o', (byte)'o', (byte)'g', (byte)'l', (byte)'e', 0x00 }; Assert.AreEqual(testURL, UrlBeaconUrlCompressor.Uncompress(testBytes)); }
public void testUncompressWithSubdomainsAndSlashesInPath() { String testURL = "http://www.forums.google.com/123/456"; byte[] testBytes = { 0x00, (byte)'f', (byte)'o', (byte)'r', (byte)'u', (byte)'m', (byte)'s', (byte)'.', (byte)'g', (byte)'o', (byte)'o', (byte)'g', (byte)'l', (byte)'e', 0x00, (byte)'1', (byte)'2', (byte)'3', (byte)'/', (byte)'4', (byte)'5', (byte)'6' }; Assert.AreEqual(testURL, UrlBeaconUrlCompressor.Uncompress(testBytes)); }
public void testUncompressWithoutTLD() { String testURL = "http://xxx"; byte[] testBytes = { 0x02, (byte)'x', (byte)'x', (byte)'x' }; Assert.AreEqual(testURL, UrlBeaconUrlCompressor.Uncompress(testBytes)); }
public void testUncompressHttpsURLWithTrailingSlash() { String testURL = "https://www.radiusnetworks.com/"; byte[] testBytes = { 0x01, (byte)'r', (byte)'a', (byte)'d', (byte)'i', (byte)'u', (byte)'s', (byte)'n', (byte)'e', (byte)'t', (byte)'w', (byte)'o', (byte)'r', (byte)'k', (byte)'s', 0x00 }; Assert.AreEqual(testURL, UrlBeaconUrlCompressor.Uncompress(testBytes)); }
public void testDecompressWithPath() { String testURL = "http://google.com/123"; byte[] testBytes = { 0x02, (byte)'g', (byte)'o', (byte)'o', (byte)'g', (byte)'l', (byte)'e', 0x00, (byte)'1', (byte)'2', (byte)'3' }; Assert.AreEqual(testURL, UrlBeaconUrlCompressor.Uncompress(testBytes)); }
protected virtual async void RangingBeaconsInRegion(object sender, ICollection <AltBeaconOrg.BoundBeacon.Beacon> beacons) { MvxTrace.TaggedTrace(TAG, "RangingBeaconsInRegion"); if (beacons != null && beacons.Count > 0) { var foundBeacons = beacons.ToList(); foreach (var beacon in foundBeacons) { if (beacon.BeaconTypeCode == 0x10) //Eddystone URL { var url = UrlBeaconUrlCompressor.Uncompress(beacon.Id1.ToByteArray()); await BeaconsService.Instance.ActivateEddystoneUrl(url); } else if (beacon.BeaconTypeCode == 0x00) //Eddystone UID { var uid = beacon.Id1.ToString().Replace("0x", "") + beacon.Id2.ToString().Replace("0x", ""); await BeaconsService.Instance.ActivateEddystoneUrl(uid); } else if (beacon.BeaconTypeCode == 533) //iBeacon { await BeaconsService.Instance.ActivateiBeacon( beacon.Id1.ToString().Replace("-", ""), Int32.Parse(beacon.Id2.ToString()), Int32.Parse(beacon.Id3.ToString()) ); } } } }
public void TestDetectsUriBeacon() { //"https://goo.gl/hqBXE1" byte[] bytes = { 2, 1, 4, 3, 3, (byte)216, (byte)254, 19, 22, (byte)216, (byte)254, 0, (byte)242, 3, 103, 111, 111, 46, 103, 108, 47, 104, 113, 66, 88, 69, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; BeaconParser parser = new BeaconParser().SetBeaconLayout("s:0-1=fed8,m:2-2=00,p:3-3:-41,i:4-21v"); Beacon uriBeacon = parser.FromScanData(bytes, -55, null, DateTime.UtcNow.Ticks); AssertEx.NotNull("UriBeacon should be not null if parsed successfully", uriBeacon); AssertEx.AreEqual("UriBeacon identifier length should be correct", 14, uriBeacon.Id1.ToByteArray().Length); String urlString = UrlBeaconUrlCompressor.Uncompress(uriBeacon.Id1.ToByteArray()); AssertEx.AreEqual("URL should be decompressed successfully", "https://goo.gl/hqBXE1", urlString); }
public async void DidRangeBeaconsInRegion(ICollection <Beacon> beacons, Region region) { foreach (var beacon in beacons) { if (beacon.ServiceUuid == 0xfeaa && beacon.BeaconTypeCode == 0x10) { // This is a Eddystone-URL frame Uri url = new Uri(UrlBeaconUrlCompressor.Uncompress(beacon.Id1.ToByteArray())); //lookup beacons: if (url.Host == WhiteLabelConfig.BEACONHOST && url.PathAndQuery.StartsWith("/b/")) { //Console.WriteLine(url); var shortcode = url.Segments.Last(); if (!_shortcodes.Contains(shortcode)) { try { var shootid = await Bootlegger.BootleggerClient.GetEventFromShortcode(shortcode); var shoot = await Bootlegger.BootleggerClient.GetEventInfo(shootid, new CancellationTokenSource().Token); _shortcodes.Add(shortcode); NearbyShoots.Add(shoot); OnEventsFound?.Invoke(); } catch { Console.WriteLine("Cant find shoot from shortcode"); } } } } } }