-
-
Save ferretnt/4eb61d17b6e8a45a3ea9c3d0b932ac4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using BestHTTP; | |
using BestHTTP.ServerSentEvents; | |
using System; | |
public class GetRequest : MonoBehaviour | |
{ | |
// Start is called before the first frame update | |
void Start() | |
{ | |
string firebaseHost = "https://fir-testdatabase-<REMOVED>.firebaseio.com/foo.json"; | |
Debug.Log("Opening Event Source"); | |
var eventSource = new EventSource(new Uri(firebaseHost), 1); | |
// Start to connect to the server | |
eventSource.OnMessage += OnMessage; | |
eventSource.OnOpen += OnOpen; | |
eventSource.Open(); | |
} | |
private void OnMessage(EventSource eventSource, Message message) | |
{ | |
Debug.Log(string.Format("Message: <color=yellow>{0}</color>", message)); | |
} | |
private void OnOpen(EventSource eventSource) | |
{ | |
Debug.Log("EventSource.Open() callback"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment