Ejemplo n.º 1
0
        ///<summary>
        /// Create a <see cref="PUTContent"/> object, that includes raw byte content.
        ///</summary>
        ///<param name="data">A byte[] array containing data to be sent to the server.</param>
        ///<returns>A <see cref="PUTContent"/> object encapsulating the byte array data, formatted for PUT requests.</returns>
        new public static PUTContent CreateBinaryBasedContent(byte[] data)
        {
            POSTContent post = POSTContent.CreateBinaryBasedContent(data);
            PUTContent  put  = new PUTContent();

            put.ByteContent = post.ByteContent;
            return(put);
        }
Ejemplo n.º 2
0
        ///<summary>
        /// Create a <see cref="PUTContent"/> object, that is typically used for html forms.
        ///</summary>
        ///<param name="keyValuePairs">A <see cref="T:System.Collection.IDictionary"/> object containing key/value pairs for the http body.</param>
        ///<returns>A <see cref="PUTContent"/> object encapsulating the key/value pairs as a byte array, formatted for PUT requests.</returns>
        new public static PUTContent CreateWebFormData(IDictionary keyValuePairs)
        {
            POSTContent post = POSTContent.CreateWebFormData(keyValuePairs);
            PUTContent  put  = new PUTContent();

            put.ByteContent = post.ByteContent;
            return(put);
        }
Ejemplo n.º 3
0
        ///<summary>
        /// Create a <see cref="PUTContent"/> object, that includes text content, typically used for JSON, XML, or plan text.
        ///</summary>
        ///<param name="content">String data that will be sent to the server.</param>
        ///<returns>A <see cref="PUTContent"/> object encapsulating the string data, formatted for PUT requests.</returns>
        new public static PUTContent CreateTextBasedContent(string content)
        {
            POSTContent post = POSTContent.CreateTextBasedContent(content);
            PUTContent  put  = new PUTContent();

            put.ByteContent = post.ByteContent;
            return(put);
        }
Ejemplo n.º 4
0
 void button_ButtonPressed(Button sender, Button.ButtonState state)
 {
     sensorState = (sensorState.Equals("0")) ? "1" : "0";
     Debug.Print(sensorState);
     PUTContent emptyPut = new PUTContent();
     Gadgeteer.Networking.HttpRequest req = HttpHelper.CreateHttpPutRequest("http://" + rpi + ":9090/gadgeteer/state/" + sensorState + "/", emptyPut, null);
     req.SendRequest();
 }
Ejemplo n.º 5
0
        void pollState()
        {
            while (true)
            {
                String newState = (pir.SensorStillActive) ? "1" : "0";

                if (!newState.Equals(sensorState))
                {
                    sensorState = newState;
                    Debug.Print(sensorState);
                    PUTContent emptyPut = new PUTContent();
                    Gadgeteer.Networking.HttpRequest req = HttpHelper.CreateHttpPutRequest("http://" + rpi + ":9090/gadgeteer/state/" + sensorState + "/", emptyPut, null);
                    req.SendRequest();
                }
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 6
0
 void pollLight()
 {
     while (true)
     {
         double lightPercent = lightSensor.ReadLightSensorPercentage();
         Debug.Print(lightPercent.ToString());
         String newState = (lightPercent >= 50) ? "1" : "0";
         Debug.Print(newState);
         if (!sensorState.Equals(newState))
         {
             sensorState = newState;
             Debug.Print(sensorState);
             PUTContent emptyPut = new PUTContent();
             Gadgeteer.Networking.HttpRequest req = HttpHelper.CreateHttpPutRequest("http://" + rpi + ":9090/gadgeteer/state/" + sensorState + "/", emptyPut, null);
             req.SendRequest();
         }
         Thread.Sleep(1000);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create an Http PUT request.
 /// </summary>
 /// <param name="Url">The Url of the web server to which the request will be sent.</param>
 /// <param name="Content">The <see cref="PUTContent"/> object to be sent to the Url.</param>
 /// <param name="ContentType">The MIME-Type of the message.</param>
 /// <returns>An <see cref="HttpRequest"/> object that can be used to make PUT request.</returns>
 public static HttpRequest CreateHttpPutRequest(string Url, PUTContent Content, string ContentType)
 {
     return new HttpRequest(HttpRequest.RequestMethod.PUT, Url, Content, ContentType, null, null);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Create an Http PUT request.
 /// </summary>
 /// <param name="url">The Url of the web server to which the request will be sent.</param>
 /// <param name="content">The <see cref="PUTContent"/> object to be sent to the Url.</param>
 /// <param name="contentType">The MIME-Type of the message.</param>
 /// <returns>An <see cref="HttpRequest"/> object that can be used to make PUT request.</returns>
 public static HttpRequest CreateHttpPutRequest(string url, PUTContent content, string contentType)
 {
     return(new HttpRequest(HttpRequest.RequestMethod.PUT, url, content, contentType, null, null));
 }
Ejemplo n.º 9
0
 ///<summary>
 /// Create a <see cref="PUTContent"/> object, that includes raw byte content.
 ///</summary>
 ///<param name="data">A byte[] array containing data to be sent to the server.</param>
 ///<returns>A <see cref="PUTContent"/> object encapsulating the byte array data, formatted for PUT requests.</returns>
 new public static PUTContent CreateBinaryBasedContent(byte[] data)
 {
     POSTContent post = POSTContent.CreateBinaryBasedContent(data);
     PUTContent put = new PUTContent();
     put.byteContent = post.byteContent;
     return put;
 }
Ejemplo n.º 10
0
 ///<summary>
 /// Create a <see cref="PUTContent"/> object, that includes text content, typically used for JSON, XML, or plan text.
 ///</summary>
 ///<param name="content">String data that will be sent to the server.</param>
 ///<returns>A <see cref="PUTContent"/> object encapsulating the string data, formatted for PUT requests.</returns>
 new public static PUTContent CreateTextBasedContent(string content)
 {
     POSTContent post = POSTContent.CreateTextBasedContent(content);
     PUTContent put = new PUTContent();
     put.byteContent = post.byteContent;
     return put;
 }
Ejemplo n.º 11
0
 ///<summary>
 /// Create a <see cref="PUTContent"/> object, that is typically used for html forms. 
 ///</summary>
 ///<param name="keyValuePairs">A <see cref="T:System.Collection.IDictionary"/> object containing key/value pairs for the http body.</param>
 ///<returns>A <see cref="PUTContent"/> object encapsulating the key/value pairs as a byte array, formatted for PUT requests.</returns>
 new public static PUTContent CreateWebFormData(IDictionary keyValuePairs)
 {
     POSTContent post = POSTContent.CreateWebFormData(keyValuePairs);
     PUTContent put = new PUTContent();
     put.byteContent = post.byteContent;
     return put;
 }
 /// <summary>
 /// Create an Http PUT request.
 /// </summary>
 /// <param name="Url">The Url of the web server to which the request will be sent.</param>
 /// <param name="Content">The <see cref="PUTContent"/> object to be sent to the Url.</param>
 /// <param name="ContentType">The MIME-Type of the message.</param>
 /// <returns>An <see cref="HttpRequest"/> object that can be used to make PUT request.</returns>
 public static HttpRequest CreateHttpPutRequest(string Url, PUTContent Content, string ContentType)
 {
     return(new HttpRequest(HttpRequest.RequestMethod.PUT, Url, Content, ContentType, null, null));
 }