Skip to content

Instantly share code, notes, and snippets.

@ferretnt
Created February 6, 2020 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferretnt/4eb61d17b6e8a45a3ea9c3d0b932ac4f to your computer and use it in GitHub Desktop.
Save ferretnt/4eb61d17b6e8a45a3ea9c3d0b932ac4f to your computer and use it in GitHub Desktop.
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