I’ve done few simple projects in Unity using networking protocols but this one has been very very different!
I am working on a project to create a 3D interface by reading and visualizing live information from dweet.io.
I can read the latest value by sending a request and show it on the screen like the below code. BUT instead of one value, I would like to read constantly (like a stream) from the server.
Dweet suggests to use “https://dweet.io/listen/for/dweets/from/{thing}” and HTTPS chunked responses in your code instead of sending multiple requests. Dweet keeps the channel opens while the application reads from it.
I am trying to read from this source for example:
https://dweet.io:443/get/latest/dweet/for/arduino-lviv-weather-flash
but I don’t know how to implement HTTPS chunked responses in Unity!
Any thoughts?
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class ExampleClass : MonoBehaviour
{
string url = @"https://dweet.io:443/get/latest/dweet/for/arduino-lviv-weather-flash";
void Start()
{
StartCoroutine(GetText());
}
IEnumerator GetText()
{
UnityWebRequest request = UnityWebRequest.Get(url);
yield return request.Send();
Debug.Log(request.downloadHandler.text);
}
}