RestClient
RestClient copied to clipboard
Support for Server-Sent Events / EventSource Protocol
Hi, I was wondering if this library has support for Server-Sent Events / EventSource Protocol https://www.w3.org/TR/eventsource/
I am trying to use this library to listen to changes in a Firebase Realtime Database using the Streaming functionality described here https://firebase.google.com/docs/reference/rest/database/#section-streaming
But i have had no success, i was just wondering if this library is able to do this, and if someone might be able to point be to some examples
Hi @shaoyuancc, That's new for me, I think the purpouse of this library is only to create HTTP requests (Working with RESTful APIs), but if you can share any Pseudocode that you want to do using this library, it would be very useful to understand how to implement that 👍 If you are looking for realtime updates with Firebase you can check the Firebase Unity SDK instead => https://firebase.google.com/docs/unity/setup
Hi sorry for the late reply! yes in the end we just used the SDK because we are looking for real time updates :) thanks for your help!
Hi, realize this is a very old topic but I came across it and found the library does already have everything needed to handle Server Sent Events if anyone else comes across this issue:
https://gist.github.com/SelaliAdobor/733202cc5b4631f55e116a1d3011d94c
ServerSentEventHandler
is an example implementation of DownloadHandlerScript
that returns messages as they're received
JSONServerSentEventHandler
parses these messages using either the built-in Unity JSON handling or Newtonsoft.JSON
The current implementation is based on fairly small message sizes so there's room for optimization (by finding the index of newline characters and using Array.Copy to copy the full message instead of going character by character) but it wouldn't be a bottleneck for anything but extremely long messages (multiple MBs of text per message)
Wow this is awesome! Thanks for sharing mate! ❤️
gist.github.com/SelaliAdobor/733202cc5b4631f55e116a1d3011d94c is down. Does anyone have a solution ?
I found this : https://gist.github.com/XEonAX/9de1c697e7c114732556ff3a6927285f I will try to use It.