示例#1
0
 public async Task NewBlock(NewBlockEvent evt)
 {
     var repo  = Configuration.CreateCallbackRepository();
     var tasks = repo
                 .GetCallbacks("onnewblock")
                 .Select(c => Call(c, evt))
                 .ToArray();
     await Task.WhenAll(tasks);
 }
示例#2
0
        private async Task Call(CallbackRegistration registration, NewBlockEvent evt)
        {
            CancellationTokenSource cancel = new CancellationTokenSource();

            cancel.CancelAfter(Timeout);

            HttpClient client = new HttpClient();

            try
            {
                var url = registration.Url;
                await client.SendAsync(new HttpRequestMessage(HttpMethod.Post, registration.Url)
                {
                    Content = new ObjectContent <NewBlockEvent>(evt, Serializer.JsonMediaTypeFormatter)
                }, cancel.Token);
            }
            catch (Exception) //TODO : Debug log + Persistent registration
            {
            }
        }