Reputation: 103
I need to get data from firebase realtime database dynamic with out refresh page so, how to do listener on realtime firebase database for get data dynamically by backend laravel and websocket, not from frontend as javascript.
public function onMessage(ConnectionInterface $conn, $msg)
{
echo $msg;
// $data = json_decode($msg);
$payload = json_decode($msg);
if (method_exists($this, $method = 'handle' . ucfirst($payload->event))) {
$this->{$method}($connection, $payload);
}
// if (isset($data->command)) {
// // $user = $this->users[$conn->resourceId];
// $message = $payload->data;
// }
}
Upvotes: 2
Views: 2763
Reputation: 599176
While the Firebase Realtime Database uses web sockets to communicate between the server and its SDKs, this protocol is not documented. The closest you can get with a public API, is to implement Firebase's REST Streaming API.
But you'll have a much easier time if you stick to one of the supported server-side or client-side SDKs. For the server-side such SDKs currently exists for Java, Node.js, Python, and Go.
Upvotes: 2