Ejemplo n.º 1
0
        void send(C2dmNotification msg, string googleLoginAuthorizationToken, string senderID, string applicationID)
        {
            C2dmMessageTransportResponse result = new C2dmMessageTransportResponse();

            result.Message = msg;

            var postData = msg.GetPostData();

            var webReq = (HttpWebRequest)WebRequest.Create(C2DM_SEND_URL);

            //webReq.ContentLength = postData.Length;
            webReq.Method      = "POST";
            webReq.ContentType = "application/x-www-form-urlencoded";
            webReq.UserAgent   = "PushSharp (version: 1.0)";
            webReq.Headers.Add("Authorization: GoogleLogin auth=" + googleLoginAuthorizationToken);

            webReq.BeginGetRequestStream(new AsyncCallback(requestStreamCallback), new C2dmAsyncParameters()
            {
                WebRequest      = webReq,
                WebResponse     = null,
                Message         = msg,
                GoogleAuthToken = googleLoginAuthorizationToken,
                SenderId        = senderID,
                ApplicationId   = applicationID
            });
        }
Ejemplo n.º 2
0
        void responseCallback(IAsyncResult result)
        {
            var msg = new C2dmNotification();

            try
            {
                var asyncParam = result.AsyncState as C2dmAsyncParameters;
                msg = asyncParam.Message;

                try
                {
                    asyncParam.WebResponse = asyncParam.WebRequest.EndGetResponse(result) as HttpWebResponse;
                    processResponseOk(asyncParam);
                }
                catch (WebException wex)
                {
                    asyncParam.WebResponse = wex.Response as HttpWebResponse;
                    processResponseError(asyncParam);
                }
            }
            catch (Exception ex)
            {
                if (UnhandledException != null)
                {
                    UnhandledException(msg, ex);
                }
                else
                {
                    throw ex;
                }
            }
        }
 public void Send(C2dmNotification msg, string googleLoginAuthorizationToken, string senderID, string applicationID)
 {
     try
     {
         send(msg, googleLoginAuthorizationToken, senderID, applicationID);
     }
     catch (Exception ex)
     {
         if (UnhandledException != null)
             UnhandledException(msg, ex);
         else
             throw ex;
     }
 }
Ejemplo n.º 4
0
 public void Send(C2dmNotification msg, string googleLoginAuthorizationToken, string senderID, string applicationID)
 {
     try
     {
         send(msg, googleLoginAuthorizationToken, senderID, applicationID);
     }
     catch (Exception ex)
     {
         if (UnhandledException != null)
         {
             UnhandledException(msg, ex);
         }
         else
         {
             throw ex;
         }
     }
 }
Ejemplo n.º 5
0
        void requestStreamCallback(IAsyncResult result)
        {
            var msg = new C2dmNotification();

            try
            {
                var asyncParam = result.AsyncState as C2dmAsyncParameters;
                msg = asyncParam.Message;

                if (asyncParam != null)
                {
                    var wrStream = asyncParam.WebRequest.EndGetRequestStream(result);

                    using (var webReqStream = new StreamWriter(wrStream))
                    {
                        var data = asyncParam.Message.GetPostData();
                        webReqStream.Write(data);
                        webReqStream.Close();
                    }

                    try
                    {
                        asyncParam.WebRequest.BeginGetResponse(new AsyncCallback(responseCallback), asyncParam);
                    }
                    catch (WebException wex)
                    {
                        asyncParam.WebResponse = wex.Response as HttpWebResponse;
                        processResponseError(asyncParam);
                    }
                }
            }
            catch (Exception ex)
            {
                if (UnhandledException != null)
                {
                    UnhandledException(msg, ex);
                }
                else
                {
                    throw ex;
                }
            }
        }
        void send(C2dmNotification msg, string googleLoginAuthorizationToken, string senderID, string applicationID)
        {
            C2dmMessageTransportResponse result = new C2dmMessageTransportResponse();
            result.Message = msg;

            var postData = msg.GetPostData();

            var webReq = (HttpWebRequest)WebRequest.Create(C2DM_SEND_URL);
            //webReq.ContentLength = postData.Length;
            webReq.Method = "POST";
            webReq.ContentType = "application/x-www-form-urlencoded";
            webReq.UserAgent = "PushSharp (version: 1.0)";
            webReq.Headers.Add("Authorization: GoogleLogin auth=" + googleLoginAuthorizationToken);

            webReq.BeginGetRequestStream(new AsyncCallback(requestStreamCallback), new C2dmAsyncParameters()
            {
                WebRequest = webReq,
                WebResponse = null,
                Message = msg,
                GoogleAuthToken = googleLoginAuthorizationToken,
                SenderId = senderID,
                ApplicationId = applicationID
            });
        }
        void responseCallback(IAsyncResult result)
        {
            var msg = new C2dmNotification();

            try
            {
                var asyncParam = result.AsyncState as C2dmAsyncParameters;
                msg = asyncParam.Message;

                try
                {
                    asyncParam.WebResponse = asyncParam.WebRequest.EndGetResponse(result) as HttpWebResponse;
                    processResponseOk(asyncParam);
                }
                catch (WebException wex)
                {
                    asyncParam.WebResponse = wex.Response as HttpWebResponse;
                    processResponseError(asyncParam);
                }
            }
            catch (Exception ex)
            {
                if (UnhandledException != null)
                    UnhandledException(msg, ex);
                else
                    throw ex;
            }
        }
        void requestStreamCallback(IAsyncResult result)
        {
            var msg = new C2dmNotification();

            try
            {
                var asyncParam = result.AsyncState as C2dmAsyncParameters;
                msg = asyncParam.Message;

                if (asyncParam != null)
                {
                    var wrStream = asyncParam.WebRequest.EndGetRequestStream(result);

                    using (var webReqStream = new StreamWriter(wrStream))
                    {
                        var data = asyncParam.Message.GetPostData();
                        webReqStream.Write(data);
                        webReqStream.Close();
                    }

                    try
                    {
                        asyncParam.WebRequest.BeginGetResponse(new AsyncCallback(responseCallback), asyncParam);
                    }
                    catch (WebException wex)
                    {
                        asyncParam.WebResponse = wex.Response as HttpWebResponse;
                        processResponseError(asyncParam);
                    }
                }
            }
            catch (Exception ex)
            {
                if (UnhandledException != null)
                    UnhandledException(msg, ex);
                else
                    throw ex;
            }
        }
Ejemplo n.º 9
0
        void transport_UnhandledException(C2dmNotification notification, Exception exception)
        {
            this.Events.RaiseChannelException(exception, PlatformType.AndroidC2dm);

            Interlocked.Decrement(ref waitCounter);
        }
Ejemplo n.º 10
0
        void transport_UnhandledException(C2dmNotification notification, Exception exception)
        {
            this.Events.RaiseChannelException(exception, PlatformType.AndroidC2dm);

            Interlocked.Decrement(ref waitCounter);
        }
Ejemplo n.º 11
0
 void transport_UnhandledException(C2dmNotification notification, Exception exception)
 {
     this.Events.RaiseChannelException(exception);
 }