BeaconLib 1.0.1

dotnet add package BeaconLib --version 1.0.1
NuGet\Install-Package BeaconLib -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BeaconLib" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BeaconLib --version 1.0.1
#r "nuget: BeaconLib, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BeaconLib as a Cake Addin
#addin nuget:?package=BeaconLib&version=1.0.1

// Install BeaconLib as a Cake Tool
#tool nuget:?package=BeaconLib&version=1.0.1

[TOC]

EXTENSION OF:

https://github.com/rix0rrr/beacon

Why this fork:


Discovery of Beacon on remote PC, assuming that both Probe and Beacons may have more than 1 interface available.


To discover services on same PC, please use Local(Probe/Beacon).

Or just use Factory by setting IsLocal boolean appropriately.


Features

  • Local Machine discovery support (wont work in multi network)
  • Multiple adapters support (Multi Network)
  • Helping function to get your Machine public IP
  • Simplified communication by chamber concept (so you cannot process beacons and probes arriving from other chambers)
  • Easy samples
  • Net 5.0
  • Cross platform (Windows / Linux / RaspberryPI) maybe even MAC
  • UDP broadcasting
  • Probes and Beacons are listening on fixed ports (35890 [Probe], 35891 [Beacon]) [in multinetwork context]

Beacon: automatic network discovery

Beacon is a small C# library that helps remove some of the user annoyances involved in writing client-server applications: finding the address of the server to connect to (because messing around putting in IP addresses is so much fun, eh?)

In that sense, it fills the same niche as other tools like Apple's Bonjour, but with minimal dependencies.

How it works

UDP broadcasts, what else did you expect? 😃 It doesn't work outside your own network range without an external server (support for something like this could be added...!) but inside one network it works quite well.

The current Beacon implementation has support for local advertising based on application type (so different programs both using Beacon don't interfere with each other), and advertising server-specific data, which can be used to distinguish different servers from each other (for example, by presenting a display name to the user).

Starting a Beacon server

Starting a beacon (to make a server discoverable) is simple:

var beacon = new LocalBeacon("myApp", 1234);
//or
//var beacon = new RemoteBeacon("myApp", 1234);

beacon.BeaconData = "My Application Server on " + Dns.GetHostName();
beacon.Start();

// ...

beacon.Stop();

1234 is the port number that you want to advertise to clients. Typically, this is the port clients should connect to for your actual network service. You can fill in a bogus value if you don't need it.

Scanning for servers using a Probe

Clients can find beacons using a Probe:

var probe = new LocalProbe("myApp");
//or
//var probe = new RemoteProbe("myApp");

// Event is raised on separate thread so need synchronization
probe.BeaconsUpdated += beacons =>
{
    try
    {
        //normally this should be only 1
        foreach (var beacon in beacons)
        {
            log.Debug(beacon.Address + ": " + beacon.Data);
        }

    }
    catch (Exception ex)
    {
        log.Error(ex);
    }
};

probe.Start();

// ...

probe.Stop();

Factory Pattern

Allows you to initiate transparently Local or Remote Beacon / Probe so you can choose what suits your needs.

Both Remotes and Locals are using same interface so nothing changes for end user.

The only thing to keep in mind: LocalProbe must be used with LocalBeacon and RemoteProbe must be used with RemoteBeacon.

You can also instantiate Local and Remote classes manually and bypass Factory pattern in case of need.

//Local Discovery Probe
bool isLocal = true;
var probe = new ProbeFactory().Get(isLocal, "myApp");

//Remote Discovery Probe
bool isLocal = false;
var probe = new ProbeFactory().Get(isLocal, "myApp");


//Local Discovery Beacon
bool isLocal = true;
var beacon = new BeaconFactory().Get(isLocal, "myApp");

//Remote Discovery Beacon
bool isLocal = false;
var beacon = new BeaconFactory().Get(isLocal, "myApp");

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

  • net5.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 347 3/31/2021