Merge pull request #1313 from urbit/rver-rc-modulo

Add support for POST delete channel requests in rver using navigator.sendBeacon
This commit is contained in:
Logan 2019-07-05 12:30:49 -07:00 committed by GitHub
commit 154722a878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -623,10 +623,10 @@
//
delete() {
var id = this.nextId();
this.sendJSONToChannel({
navigator.sendBeacon(this.channelURL(), JSON.stringify([{
"id": id,
"action": "delete"
}, false);
}]));
}
// unsubscribe to a specific subscription
@ -642,7 +642,7 @@
// sends a JSON command command to the server.
//
sendJSONToChannel(j, connectAgain = true) {
sendJSONToChannel(j) {
var req = new XMLHttpRequest();
req.open("PUT", this.channelURL());
req.setRequestHeader("Content-Type", "application/json");
@ -663,9 +663,7 @@
this.lastEventId = this.lastAcknowledgedEventId;
}
if (connectAgain) {
this.connectIfDisconnected();
}
this.connectIfDisconnected();
}
// connects to the EventSource if we are not currently connected
@ -1109,6 +1107,9 @@
::
?: =('GET' method.request)
(on-get-request channel-id request)
?: =('POST' method.request)
:: POST methods are used solely for deleting channels
(on-put-request channel-id request)
::
~& %session-not-a-put
[~ state]