Have server broadcast its address to the local network for easy sign in
This commit is contained in:
parent
b7df636fc7
commit
1fc07ca194
7 changed files with 64 additions and 1 deletions
|
@ -31,6 +31,9 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BeaconLib, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\rix0rrr.BeaconLib.1.0.2\lib\net40\BeaconLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.4.1.12, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpZipLib.1.4.1\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LANCommander.SDK.Models;
|
||||
using BeaconLib;
|
||||
using LANCommander.SDK.Models;
|
||||
using Playnite.SDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -27,6 +28,22 @@ namespace LANCommander.PlaynitePlugin.Views
|
|||
Plugin = plugin;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var probe = new Probe("LANCommander");
|
||||
|
||||
probe.BeaconsUpdated += beacons => Dispatcher.BeginInvoke((System.Action)(() =>
|
||||
{
|
||||
var beacon = beacons.First();
|
||||
|
||||
Context.ServerAddress = $"http://{beacon.Address.Address}:{beacon.Address.Port}";
|
||||
|
||||
this.ServerAddress.Text = Context.ServerAddress;
|
||||
|
||||
probe.Stop();
|
||||
}));
|
||||
|
||||
probe.Start();
|
||||
|
||||
}
|
||||
|
||||
private void TextBox_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net462" />
|
||||
<package id="NuGet.CommandLine" version="4.4.3" targetFramework="net462" developmentDependency="true" />
|
||||
<package id="PlayniteSDK" version="6.8.0" targetFramework="net462" />
|
||||
<package id="PowerShellStandard.Library" version="5.1.1" targetFramework="net462" />
|
||||
<package id="RestSharp" version="106.15.0" targetFramework="net462" />
|
||||
<package id="rix0rrr.BeaconLib" version="1.0.2" targetFramework="net462" />
|
||||
<package id="SharpZipLib" version="1.4.1" targetFramework="net462" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net462" />
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.11" />
|
||||
<PackageReference Include="rix0rrr.BeaconLib" Version="1.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="12.3.1" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
public class LANCommanderSettings
|
||||
{
|
||||
public int Port { get; set; }
|
||||
public bool Beacon { get; set; }
|
||||
public string TokenSecret { get; set; }
|
||||
public int TokenLifetime { get; set; }
|
||||
public string DatabaseConnectionString { get; set; }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using BeaconLib;
|
||||
using LANCommander.Data;
|
||||
using LANCommander.Data.Models;
|
||||
using LANCommander.Services;
|
||||
|
@ -77,6 +78,9 @@ builder.Services.AddScoped<TagService>();
|
|||
builder.Services.AddScoped<CompanyService>();
|
||||
builder.Services.AddScoped<IGDBService>();
|
||||
|
||||
if (settings.Beacon)
|
||||
builder.Services.AddHostedService<BeaconService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
|
35
LANCommander/Services/BeaconService.cs
Normal file
35
LANCommander/Services/BeaconService.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using BeaconLib;
|
||||
using LANCommander.Models;
|
||||
|
||||
namespace LANCommander.Services
|
||||
{
|
||||
public class BeaconService : IHostedService, IDisposable
|
||||
{
|
||||
private Beacon Beacon;
|
||||
private LANCommanderSettings Settings;
|
||||
|
||||
public BeaconService() {
|
||||
Settings = SettingService.GetSettings();
|
||||
Beacon = new Beacon("LANCommander", Convert.ToUInt16(Settings.Port));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Beacon?.Dispose();
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Beacon.BeaconData = "Acknowledged HQ";
|
||||
Beacon.Start();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Beacon.Stop();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue