Skip to content
Snippets Groups Projects
Commit 7a96e2b3 authored by rswindell's avatar rswindell
Browse files

Resolve FAQ:

Don't report a JavaScript warning ("Disconnected") until the OperationCallback
has been executed 10 times with the user offline. This gives the executing
script ample time to recognize the disconnected state and exit gracefully.
Script that do not check/notice that the user has disconnected will still be
auto-terminated (by default) and this warning will still be logged in those
cases. The value 10 was picked at random and appears to work fine.
parent 7b559cc7
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -548,7 +548,8 @@ js_OperationCallback(JSContext *cx)
return(JS_FALSE);
}
if(sbbs->js_callback.auto_terminate && !sbbs->online) {
if(sbbs->js_callback.auto_terminate && !sbbs->online
&& ++sbbs->js_callback.offline_counter >= 10) {
JS_ReportWarning(cx,"Disconnected");
sbbs->js_callback.counter=0;
JS_SetOperationCallback(cx, js_OperationCallback);
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -85,6 +85,7 @@ typedef struct js_callback {
uint32_t yield_interval;
uint32_t gc_interval;
uint32_t gc_attempts;
uint32_t offline_counter;
BOOL auto_terminate;
volatile BOOL* terminated;
BOOL bg;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment