示例#1
0
        private IEnumerator publishItemStateopenHAB_Async(ItemStateOpenHAB toPublish)
        {
            byte[] stateAsByte = Encoding.UTF8.GetBytes(toPublish.state);
            string url         = restURL + "items/" + toPublish.name;



            //UnityWebRequest uwr_post = UnityWebRequest.Post(url, toPublish.state);

            UnityWebRequest uwr_post = new UnityWebRequest(url);

            uwr_post.uploadHandler   = new UploadHandlerRaw(stateAsByte);
            uwr_post.downloadHandler = new DownloadHandlerBuffer();
            uwr_post.method          = UnityWebRequest.kHttpVerbPOST;


            uwr_post.SetRequestHeader("Content-Type", "text/plain");

            yield return(uwr_post.SendWebRequest());
        }
示例#2
0
 /// <summary>
 /// A Fire and forget send State
 /// </summary>
 /// <param name="toPublish"></param>
 public void publishItemStateopenHAB(ItemStateOpenHAB toPublish)
 {
     StartCoroutine(publishItemStateopenHAB_Async(toPublish));
 }