-
Notifications
You must be signed in to change notification settings - Fork 22
/
Program.cs
45 lines (38 loc) · 1.57 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNet.WebHooks;
using Microsoft.AspNet.WebHooks.Services;
using Microsoft.Owin.Hosting;
using WebApiHost.Models;
namespace WebApiHost
{
class Program
{
static async Task Main(string[] args)
{
const string webHookSenderBaseAddress = "http://localhost:9002";
var handler = new HttpClientHandler
{
UseDefaultCredentials = true
};
// Microsoft.AspNet.WebHooks.Custom.SqlStorage
// Microsoft.AspNet.WebHooks.Custom.AzureStorage
// Microsoft.AspNet.WebHooks.Custom.MongoStorage
//CustomServices.SetStore(new MemoryWebHookStore());
// Start OWIN host
using (WebApp.Start<Startup>(webHookSenderBaseAddress))
using (var client = new HttpClient(handler))
{
Console.WriteLine("Webhook sender up and running. Waiting for webhook receiver to register");
// User should wait until the webhook receiver has completed the registration.
Console.WriteLine("Press any key to trigger the webhook by sending a message");
Console.ReadKey();
// trigger a webhook call
await client.PostAsJsonAsync($"{webHookSenderBaseAddress}/api/messages", new Message { Sender = "WebApiHost", Body = "Hello From Sender" });
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
}
}