printer discovery in print service
This commit is contained in:
@@ -11,17 +11,17 @@ using Inspectron.Epson.PrintServer.JobSources;
|
||||
using Inspectron.Epson.PrintServer.PrinterAssinment;
|
||||
using Inspectron.Epson.PrintServer.Printers;
|
||||
using Inspectron.Epson.PrintServer.PrintServices;
|
||||
using EpsonPrintService;
|
||||
|
||||
StandardKernel kernel = new StandardKernel();
|
||||
|
||||
//var config = new EpsonPrintServiceConfiguration()
|
||||
//{
|
||||
// GroupId = "67e534f8e86e816689323023",
|
||||
// RestaurantId = "63e37295bd6f26dbd36164c0"
|
||||
//};
|
||||
//File.WriteAllText("config.json",JsonSerializer.Serialize(config,new JsonSerializerOptions(){WriteIndented = true}));
|
||||
|
||||
var config = JsonSerializer.Deserialize<EpsonPrintServiceConfiguration>(
|
||||
File.ReadAllText("config.json"));
|
||||
|
||||
kernel.Bind<IDiscoveryService>().To<DiscoveryService>().InSingletonScope();
|
||||
|
||||
|
||||
kernel.Bind<EpsonPrintServiceConfiguration>().ToConstant(config);
|
||||
|
||||
kernel.Bind<IPrintJobSource, SignalRPrintJobSource>().To<SignalRPrintJobSource>().InSingletonScope();
|
||||
@@ -38,8 +38,12 @@ kernel.Bind<IAssignedPrinterRepository>().ToConstant(config);
|
||||
kernel.Bind<IPrinterFactory>().To<PrinterFactory>().InSingletonScope();
|
||||
kernel.Bind<IPrinterConfigurationSource>().To<FixedConfigurationSource>();
|
||||
kernel.Bind<PrintServer>().ToSelf().InSingletonScope();
|
||||
kernel.Bind<IDiscoveredPrintersReceiver>().To<ConsoleDiscoveredPrintersReceiver>().InSingletonScope();
|
||||
kernel.Bind<PrinterDiscoveryBackgroundTask>().ToSelf().InSingletonScope();
|
||||
|
||||
var printLoop = kernel.Get<PrintLoop>();
|
||||
var printServer = kernel.Get<PrintServer>();
|
||||
var discoveryTask = kernel.Get<PrinterDiscoveryBackgroundTask>();
|
||||
|
||||
printServer.RegisterPrinter("127.0.0.1");
|
||||
|
||||
@@ -55,6 +59,9 @@ Console.CancelKeyPress += (sender, e) =>
|
||||
cts.Cancel();
|
||||
};
|
||||
|
||||
// Start the printer discovery background task
|
||||
_ = discoveryTask.StartAsync(cts.Token);
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(Timeout.Infinite, cts.Token);
|
||||
|
||||
Reference in New Issue
Block a user