mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Make usage of SSE be configurable
This commit is contained in:
parent
3c7f06009b
commit
4c2c7266d7
@ -18,7 +18,8 @@ var CONFIG_HOST_TIDDLER = "$:/config/multiwikiclient/host",
|
||||
BAG_STATE_TIDDLER = "$:/state/multiwikiclient/tiddlers/bag",
|
||||
REVISION_STATE_TIDDLER = "$:/state/multiwikiclient/tiddlers/revision",
|
||||
CONNECTION_STATE_TIDDLER = "$:/state/multiwikiclient/connection",
|
||||
INCOMING_UPDATES_FILTER_TIDDLER = "$:/config/multiwikiclient/incoming-updates-filter";
|
||||
INCOMING_UPDATES_FILTER_TIDDLER = "$:/config/multiwikiclient/incoming-updates-filter",
|
||||
ENABLE_SSE_TIDDLER = "$:/config/multiwikiclient/use-server-sent-events";
|
||||
|
||||
var SERVER_NOT_CONNECTED = "NOT CONNECTED",
|
||||
SERVER_CONNECTING_SSE = "CONNECTING SSE",
|
||||
@ -29,6 +30,7 @@ function MultiWikiClientAdaptor(options) {
|
||||
this.wiki = options.wiki;
|
||||
this.host = this.getHost();
|
||||
this.recipe = this.wiki.getTiddlerText("$:/config/multiwikiclient/recipe");
|
||||
this.useServerSentEvents = this.wiki.getTiddlerText(ENABLE_SSE_TIDDLER) === "yes";
|
||||
this.last_known_tiddler_id = $tw.utils.parseNumber(this.wiki.getTiddlerText("$:/state/multiwikiclient/recipe/last_tiddler_id","0"));
|
||||
this.logger = new $tw.utils.Logger("MultiWikiClientAdaptor");
|
||||
this.isLoggedIn = false;
|
||||
@ -126,14 +128,7 @@ MultiWikiClientAdaptor.prototype.getStatus = function(callback) {
|
||||
Get details of changed tiddlers from the server
|
||||
*/
|
||||
MultiWikiClientAdaptor.prototype.getUpdatedTiddlers = function(syncer,callback) {
|
||||
// Temporary override to disable SSE
|
||||
this.pollServer({
|
||||
callback: function(err,changes) {
|
||||
callback(null,changes);
|
||||
}
|
||||
});
|
||||
return;
|
||||
// Disabled SSE code
|
||||
if(this.useServerSentEvents) {
|
||||
var self = this;
|
||||
// Do nothing if there's already a connection in progress.
|
||||
if(this.serverUpdateConnectionStatus !== SERVER_NOT_CONNECTED) {
|
||||
@ -166,6 +161,13 @@ MultiWikiClientAdaptor.prototype.getUpdatedTiddlers = function(syncer,callback)
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.pollServer({
|
||||
callback: function(err,changes) {
|
||||
callback(null,changes);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user