This project is no longer maintained.
An almost-dropin replacement for the GAE channels API using Firebase.
pip install firechannel
- Include the firebase web init snippet in your app
- Include
static/firechannel.js
in your app
Given an implementation like
var channel = new goog.appengine.Channel("{{token}}");
var socket = channel.open();
socket.onmessage = function(data) { console.log(data); };
change the first line to
var channel = new Firechannel("{{token}}");
Change your imports from
from google.appengine.api.channel import create_channel, send_message
to
from firechannel import create_channel, send_message
Add the following rule using your Firebase console:
{
"rules": {
".read": false,
".write": false,
"firechannels": {
"$channelId": {
".read": "auth.uid == $channelId",
".write": false
}
}
}
}
And that's about it.
You can call delete_channel
after you're done sending messages on
it. This will remove it from Firebase immediately.
If that's not feasible, you can set up an hourly (or daily) cron job and delete all channels that have last received a message some amount of time ago like this:
from firechannel import find_all_expired_channels, delete_channel
# All channels that have last received a message over a day ago
expired_channels = find_all_expired_channels(max_age=86400)
for channel_id in expired_channels:
delete_channel(channel_id)
To run the tests, create a service account and point an env var
called GOOGLE_APPLICATION_CREDENTIALS
to it and another one called
FIREBASE_PROJECT
to the name of your project. Finally, run py.test
.
To run the AppEngine tests, point an env var called APPENGINE_SDK_PATH
to the base path of your GAE SDK and run py.test tests_appengine
.
firechannel
was authored at Leadpages. You can find
out more about contributors here. We welcome
contributions, and we're always looking for more
engineering talent!
Please read our contributor's guide.