webXMPP

Check-in [30ef720dc6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Don't waste data and battery on background long polling if you don't have the ability to post notifications. (On Ubuntu Touch, we instead run a notification daemon.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:30ef720dc6d1807a9c5d47a67aba4ced73b614491295bce681beea5b2efda113
User & Date: ajv-899-334-8894@vsta.org 2017-07-01 00:02:24
Context
2017-07-01
00:03
Merge branch 'master' of https://github.com/vandys/webXMPP check-in: bbd719910e user: ajv-899-334-8894@vsta.org tags: master, trunk
00:02
Don't waste data and battery on background long polling if you don't have the ability to post notifications. (On Ubuntu Touch, we instead run a notification daemon.) check-in: 30ef720dc6 user: ajv-899-334-8894@vsta.org tags: master, trunk
00:01
Failed idea on dealing with NAT, back out. check-in: 0d418f5fb1 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to js/polling.js.

29
30
31
32
33
34
35







36
37
38
39
40
41

// This fires when we've posted a notification event and are now
//  idle until the focus returns here.
function updateVisibility() {
    if (document.hidden == false) {
	// Start listening for more messages actively
	moreMessages();







    }
}

// Visibility hook
document.addEventListener("visibilitychange", updateVisibility);








>
>
>
>
>
>
>






29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

// This fires when we've posted a notification event and are now
//  idle until the focus returns here.
function updateVisibility() {
    if (document.hidden == false) {
	// Start listening for more messages actively
	moreMessages();
    } else {
	if (!notifiable) {
	    // When not on-screen and notifications are not
	    //  available, we can just quiesce.
	    goOffline();
	    ourState = 3;
	}
    }
}

// Visibility hook
document.addEventListener("visibilitychange", updateVisibility);

Changes to js/ui.js.

75
76
77
78
79
80
81




82
83
84
85
86
87
88
...
444
445
446
447
448
449
450

451
452
453
454
455
456
457
let lastTM = '';

// Latest serial # back from server completion
let lastSerial = 0;

// Unique value for us
let clientID = null;





// Returning online (network change, cell->wifi, etc.)
function goOnline() {
    if (curReq != null) {
	curReq.abort();
	curReq = null;
    }
................................................................................
function ourStart() {

    // We'll want to send notifications (if the user
    //  lets us)
    Notification.requestPermission(function(result) {
	if (result == "granted") {
	    console.log("Notifications OK");

	}
    });

    // Send our initial update request
    ourState = 1;
    curReq = new XMLHttpRequest();
    curReq.open("GET", "/config.json");







>
>
>
>







 







>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
let lastTM = '';

// Latest serial # back from server completion
let lastSerial = 0;

// Unique value for us
let clientID = null;

// Have they OK'ed notifications?  There's things we
//  won't do if we can't post notifications anyway.
let notifiable = false;

// Returning online (network change, cell->wifi, etc.)
function goOnline() {
    if (curReq != null) {
	curReq.abort();
	curReq = null;
    }
................................................................................
function ourStart() {

    // We'll want to send notifications (if the user
    //  lets us)
    Notification.requestPermission(function(result) {
	if (result == "granted") {
	    console.log("Notifications OK");
	    notifiable = true;
	}
    });

    // Send our initial update request
    ourState = 1;
    curReq = new XMLHttpRequest();
    curReq.open("GET", "/config.json");