Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Server-Sent Events / EventSource Protocol #80

Open
shaoyuancc opened this issue Jun 24, 2019 · 5 comments
Open

Support for Server-Sent Events / EventSource Protocol #80

shaoyuancc opened this issue Jun 24, 2019 · 5 comments
Labels
cool Nice info! discussion 🔥 Discussions about this asset

Comments

@shaoyuancc
Copy link

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

@jdnichollsc
Copy link
Member

jdnichollsc commented Jun 25, 2019

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

@shaoyuancc
Copy link
Author

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!

@selalipop
Copy link

selalipop commented Oct 26, 2020

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)

@jdnichollsc
Copy link
Member

Wow this is awesome! Thanks for sharing mate! ❤️

@jdnichollsc jdnichollsc added discussion 🔥 Discussions about this asset and removed investigate question labels Oct 26, 2020
@jdnichollsc jdnichollsc reopened this Oct 26, 2020
@jdnichollsc jdnichollsc added the cool Nice info! label Oct 26, 2020
@Morgan-6Freedom
Copy link

Morgan-6Freedom commented Apr 21, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cool Nice info! discussion 🔥 Discussions about this asset
Projects
None yet
Development

No branches or pull requests

4 participants