I am trying to integrate real time event listeners into my application that utilizes firebase realtime database.
I came across this post that discussed this but it seems that it will not be implemented in the official SDK.
I also came across the firebase REST/Streaming endpoints and was considering using this to integrate realtime listeners.
My question is, is there a recommended way to achieve this? (Websockets, callbacks, channels ect.) Is there already a library that does this so I don't have to write code from scratch to achieve this functionality?
CodePudding user response:
Firebase's native web socket wire protocol is not documented. The closest you can get to the behavior of the native SDKs (outside of using those) with a public API is by using the REST Streaming API that Hiranya also linked in the Github issue. I've done this for various projects in various languages (though never in Go), and it's often a reasonable approach though slightly less efficient than the native web sockets, as it needs separate connections for reading and writing data.
To get started, I recommend checking out:
- The blog post announcing the REST streaming API for Realtime Database
- The sample clients for Python and Ruby.
- REST SSE implementations for Go.