Stubs for WebSocket push notifications.
This commit is contained in:
parent
bb713abeed
commit
0da15ef102
41
www/js/ts.js
41
www/js/ts.js
@ -584,7 +584,19 @@ $(document).ready(function(){
|
|||||||
// render views
|
// render views
|
||||||
this.user.view.render();
|
this.user.view.render();
|
||||||
this.timelines.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() {
|
loadInitialData: function() {
|
||||||
// assume we are authenticated
|
// assume we are authenticated
|
||||||
@ -653,7 +665,32 @@ $(document).ready(function(){
|
|||||||
this.timelines.view.render();
|
this.timelines.view.render();
|
||||||
|
|
||||||
// fetch the new EntryList records
|
// 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({
|
TS.LoginView = Backbone.View.extend({
|
||||||
el: $("#login")[0],
|
el: $("#login")[0],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user