Stubs for WebSocket push notifications.

This commit is contained in:
Jonathan Bernard 2014-12-22 09:57:31 -06:00
parent bb713abeed
commit 0da15ef102

View File

@ -584,7 +584,19 @@ $(document).ready(function(){
// render views
this.user.view.render();
this.timelines.view.render();
this.entries.view.render(); },
this.entries.view.render();
// create our WebSocket for receiving push notifications of changed
// content.
if (false) { // (Modernizr.websockets)
TS.updateConnection = new WebSocket('wss://' +
window.location.hostname +
(window.location.port ? ":" window.location.port : "") +
'/ts_api/update_service?user_id=' +
this.user.model.get("id"));
TS.updateConnection.onopen = this.syncConnected;
TS.updateConnection.onmessage = this.syncUpdate;
TS.updateConnection.onclose = this.syncDisconnected; } },
loadInitialData: function() {
// assume we are authenticated
@ -653,7 +665,32 @@ $(document).ready(function(){
this.timelines.view.render();
// fetch the new EntryList records
this.entries.collection.fetch() } } });
this.entries.collection.fetch() } },
syncConnected: function() { },
syncDisconnected: function() {err) {
// TODO: reconnect. Possibly display a button for the user to
// manually reconnect if we've already tried and failed too many
// times.
},
syncUpdate: function(message) {
if (!message.data) return;
var data = JSON.parse(message.data);
if (data.record_type == "ts_entry") {
// Check to see if the record is for the same timeline we are
// currently using.
//
}
if (data.record_type == "ts_timeline") {
}
} });
TS.LoginView = Backbone.View.extend({
el: $("#login")[0],