Bugsnag.Library.BugSnag.SendNotification C# (CSharp) Метод

SendNotification() приватный Метод

Sends current set of events to BugSnag via a JSON post
private SendNotification ( Bugsnag.Library.Data.ErrorNotification notification, bool useSSL ) : void
notification Bugsnag.Library.Data.ErrorNotification The notification to send
useSSL bool Indicates the post should use SSL when sending JSON data
Результат void
        private void SendNotification(ErrorNotification notification, bool useSSL)
        {
            string serializedJSON = notification.SerializeToString();

            //  Create a byte array:
            byte[] byteArray = Encoding.UTF8.GetBytes(serializedJSON);

            //  Post JSON to server:
            WebRequest request;
            if(useSSL)
                request = WebRequest.Create(httpsUrl);
            else
                request = WebRequest.Create(httpUrl);

            request.Method = WebRequestMethods.Http.Post;
            request.ContentType = "application/json";
            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            //  Get the response.  See https://bugsnag.com/docs/notifier-api for response codes
            var response = request.GetResponse();
        }