Skip to content
Open
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
21 changes: 13 additions & 8 deletions PushSharp.Google/GcmServiceConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public async Task Send (GcmNotification notification)
{
var json = notification.GetJson ();

var content = new StringContent (json, System.Text.Encoding.UTF8, "application/json");

var response = await http.PostAsync (Configuration.GcmUrl, content);

if (response.IsSuccessStatusCode) {
await processResponseOk (response, notification).ConfigureAwait (false);
} else {
await processResponseError (response, notification).ConfigureAwait (false);
using (var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json"))
using (var response = await http.PostAsync(Configuration.GcmUrl, content))
{
if (response.IsSuccessStatusCode) {
await processResponseOk(response, notification).ConfigureAwait(false);
} else {
await processResponseError(response, notification).ConfigureAwait(false);
}
}
}

Expand Down Expand Up @@ -212,5 +212,10 @@ static GcmResponseStatus GetGcmResponseStatus (string str)
//Default
return GcmResponseStatus.Error;
}

~GcmServiceConnection()
{
http.Dispose();
}
}
}