From aedd42ccca44c90ad4516665c7df308528b63143 Mon Sep 17 00:00:00 2001 From: l3ender Date: Sun, 15 Jun 2014 18:36:24 -0500 Subject: [PATCH] Added programmatic web proxy configuration for GCM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Didn’t know how applicable this was for all push types (not all are HTTP I believe?), so I kept it specific to GCM. --- PushSharp.Android/Gcm/GcmPushChannel.cs | 9 +++++++++ PushSharp.Android/Gcm/GcmPushChannelSettings.cs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/PushSharp.Android/Gcm/GcmPushChannel.cs b/PushSharp.Android/Gcm/GcmPushChannel.cs index b3a44e24..b190627b 100644 --- a/PushSharp.Android/Gcm/GcmPushChannel.cs +++ b/PushSharp.Android/Gcm/GcmPushChannel.cs @@ -51,6 +51,7 @@ public void SendNotification(INotification notification, SendNotificationCallbac //var postData = msg.GetJson(); var webReq = (HttpWebRequest)WebRequest.Create(gcmSettings.GcmUrl); + ConfigureProxy (webReq); //webReq.ContentLength = postData.Length; webReq.Method = "POST"; webReq.ContentType = "application/json"; @@ -70,6 +71,14 @@ public void SendNotification(INotification notification, SendNotificationCallbac }); } + void ConfigureProxy(HttpWebRequest request) + { + if (gcmSettings.Proxy != null) + { + request.Proxy = gcmSettings.Proxy; + } + } + void requestStreamCallback(IAsyncResult result) { var asyncParam = result.AsyncState as GcmAsyncParameters; diff --git a/PushSharp.Android/Gcm/GcmPushChannelSettings.cs b/PushSharp.Android/Gcm/GcmPushChannelSettings.cs index ac525f56..54ea7ba0 100644 --- a/PushSharp.Android/Gcm/GcmPushChannelSettings.cs +++ b/PushSharp.Android/Gcm/GcmPushChannelSettings.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using PushSharp.Core; +using System.Net; namespace PushSharp.Android { @@ -31,6 +32,7 @@ public GcmPushChannelSettings(string optionalSenderID, string senderAuthToken, s public string SenderID { get; private set; } public string SenderAuthToken { get; private set; } public string ApplicationIdPackageName { get; private set; } + public WebProxy Proxy { get; set; } public bool ValidateServerCertificate { get; set; }