Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ using System.Text.Json;
using TwitchLib.EventSub.Websockets.Core.EventArgs;
using TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;

namespace TwitchLib.EventSub.Websockets.Test
namespace TwitchLib.EventSub.Websockets.Example
{
public class WebsocketHostedService : IHostedService
{
Expand Down
29 changes: 13 additions & 16 deletions TwitchLib.EventSub.Websockets.Example.NetStandard/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.IO;
using TwitchLib.EventSub.Websockets.Extensions;

namespace TwitchLib.EventSub.Websockets.Example.NetStandard
Expand All @@ -10,21 +10,18 @@ internal class Program
{
private static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
var builder = Host.CreateApplicationBuilder(args);

builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"));

private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(configure =>
{
configure.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"));
})
.ConfigureServices((hostContext, services) =>
{
services.AddLogging();
services.AddTwitchLibEventSubWebsockets();
//Add services to the container.
builder.Services.AddLogging();
builder.Services.AddTwitchLibEventSubWebsockets();
builder.Services.AddHostedService<WebsocketHostedService>();

services.AddHostedService<WebsocketHostedServiceWithoutDI>();
});
var app = builder.Build();

app.Run();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
Expand All @@ -11,13 +10,11 @@ namespace TwitchLib.EventSub.Websockets.Example.NetStandard
{
public class WebsocketHostedService : IHostedService
{
private readonly IConfiguration _configuration;
private readonly ILogger<WebsocketHostedService> _logger;
private readonly EventSubWebsocketClient _eventSubWebsocketClient;

public WebsocketHostedService(IConfiguration configuration ,ILogger<WebsocketHostedService> logger, EventSubWebsocketClient eventSubWebsocketClient)
public WebsocketHostedService(ILogger<WebsocketHostedService> logger, EventSubWebsocketClient eventSubWebsocketClient)
{
_configuration = configuration;
_logger = logger ?? throw new ArgumentNullException(nameof(logger));

_eventSubWebsocketClient = eventSubWebsocketClient ?? throw new ArgumentNullException(nameof(eventSubWebsocketClient));
Expand Down