Beispiel #1
0
 private async Task SendStats(StatsPing sendPacket)
 {
     try
     {
         Log.Debug("Send: {@data}", sendPacket);
         var request = WebWrapper
                       .Request("https://splamy.de/api/tab/stats")
                       .WithMethod(HttpMethod.Post);
         request.Content = new StringContent(JsonConvert.SerializeObject(sendPacket), Tools.Utf8Encoder, "application/json");
         await request.ToAction(response =>
         {
             Log.Debug("Stats response {0}", response.StatusCode);
             return(Task.CompletedTask);
         });
     }
     catch (Exception ex) { Log.Debug(ex, "Could not upload stats"); }
 }
Beispiel #2
0
 private void SendStats(StatsPing sendPacket)
 {
     try
     {
         Log.Debug("Send: {@data}", sendPacket);
         var request = WebWrapper.CreateRequest(new Uri("https://splamy.de/api/tab/stats")).Unwrap();
         request.Timeout     = 2000;             // ms
         request.Method      = "POST";
         request.ContentType = "application/json";
         using (var rStream = request.GetRequestStream())
             using (var sw = new StreamWriter(rStream, Tools.Utf8Encoder))
             {
                 JsonSer.Serialize(sw, sendPacket);
             }
         request.GetResponse().Dispose();
     }
     catch (Exception ex) { Log.Debug(ex, "Could not upload stats"); }
 }