-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* しばらくアイドルだとLINEからのリクエストを捌くのが間に合わないのを修正 (#5) * LINEスタンプ(LINE→Slack)に対応 * LINEのユーザアイコン(LINE→Slack)に対応 * LINEのBOTアカウントを友達登録していないユーザのプロフィール情報の取得に対応
- Loading branch information
Showing
5 changed files
with
147 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace SlackLineBridge.Services | ||
{ | ||
public class BackgroundAccessingService : BackgroundService | ||
{ | ||
private readonly ILogger<BackgroundAccessingService> _logger; | ||
private readonly IHttpClientFactory _clientFactory; | ||
|
||
public BackgroundAccessingService(ILogger<BackgroundAccessingService> logger, IHttpClientFactory clientFactory) | ||
{ | ||
_logger = logger; | ||
_clientFactory = clientFactory; | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
_logger.LogDebug($"BackgroundAccessingService is starting."); | ||
|
||
stoppingToken.Register(() => _logger.LogDebug($" BackgroundAccessing background task is stopping.")); | ||
|
||
var client = _clientFactory.CreateClient(); | ||
while (!stoppingToken.IsCancellationRequested) | ||
{ | ||
try | ||
{ | ||
var response = await client.PostAsync("http://localhost/line", new StringContent("")); | ||
} | ||
catch | ||
{ | ||
// ignore | ||
} | ||
|
||
await Task.Delay(1000 * 60, stoppingToken); | ||
} | ||
|
||
_logger.LogDebug($"BackgroundAccessing background task is stopped."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters