Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Make the /chat-poll timeout configurable using the chat-poll-timeout setting. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
8363e7b8e6ddf9ec48682b68e54ab288 |
| User & Date: | drh 2020-12-26 12:33:33.307 |
Context
|
2020-12-26
| ||
| 13:46 | Chat docs: minor typos and additions. check-in: 10085418fe user: stephan tags: trunk | |
| 12:33 | Make the /chat-poll timeout configurable using the chat-poll-timeout setting. check-in: 8363e7b8e6 user: drh tags: trunk | |
|
2020-12-25
| ||
| 23:38 | CSS docs and line-wrapped the new settings icon data URL. No functional changes. check-in: ca42098af0 user: stephan tags: trunk | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* ** SETTING: chat-inline-images boolean default=on ** ** Specifies whether posted images in /chat should default to being ** displayed inline or as downloadable links. Each chat user can ** change this value for their current chat session in the UI. */ /* ** WEBPAGE: chat ** ** Start up a browser-based chat session. ** ** This is the main page that humans use to access the chatroom. Simply ** point a web-browser at /chat and the screen fills with the latest | > > > > > > > > > > > > > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /* ** SETTING: chat-inline-images boolean default=on ** ** Specifies whether posted images in /chat should default to being ** displayed inline or as downloadable links. Each chat user can ** change this value for their current chat session in the UI. */ /* ** SETTING: chat-poll-timeout width=10 default=420 ** ** On an HTTP request to /chat-poll, if there is no new content available, ** the reply is delayed waiting for new content to arrive. (This is the ** "long poll" strategy of event delivery to the client.) This setting ** determines approximately how long /chat-poll will delay before giving ** up and returning an empty reply. The default value is about 7 minutes, ** which works well for Fossil behind the althttpd web server. Other ** server environments may choose a longer or shorter delay. ** ** For maximum efficiency, it is best to choose the longest delay that ** does not cause timeouts in intermediate proxies or web server. */ /* ** WEBPAGE: chat ** ** Start up a browser-based chat session. ** ** This is the main page that humans use to access the chatroom. Simply ** point a web-browser at /chat and the screen fills with the latest |
| ︙ | ︙ | |||
333 334 335 336 337 338 339 |
fossil_free(zOut);
}
}
/*
** WEBPAGE: chat-poll
**
| | > > > > > | | | | | | < | > | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
fossil_free(zOut);
}
}
/*
** WEBPAGE: chat-poll
**
** The chat page generated by /chat using an XHR to this page to
** request new chat content. A typical invocation is:
**
** /chat-poll/N
** /chat-poll?name=N
**
** The "name" argument should begin with an integer which is the largest
** "msgid" that the chat page currently holds. If newer content is
** available, this routine returns that content straight away. If no new
** content is available, this webpage blocks until the new content becomes
** available. In this way, the system implements "hanging-GET" or "long-poll"
** style event notification. If no new content arrives after a delay of
** approximately chat-poll-timeout seconds (default: 420), then reply is
** sent with an empty "msg": field.
**
** If N is negative, then the return value is the N most recent messages.
** Hence a request like /chat-poll/-100 can be used to initialize a new
** chat session to just the most recent messages.
**
** Some webservers (althttpd) do not allow a term of the URL path to
** begin with "-". Then /chat-poll/-100 cannot be used. Instead you
|
| ︙ | ︙ | |||
393 394 395 396 397 398 399 |
**
** The messages are ordered oldest first unless "before" is provided, in which
** case they are sorted newest first (to facilitate the client-side UI update).
*/
void chat_poll_webpage(void){
Blob json; /* The json to be constructed and returned */
sqlite3_int64 dataVersion; /* Data version. Used for polling. */
| | | > | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
**
** The messages are ordered oldest first unless "before" is provided, in which
** case they are sorted newest first (to facilitate the client-side UI update).
*/
void chat_poll_webpage(void){
Blob json; /* The json to be constructed and returned */
sqlite3_int64 dataVersion; /* Data version. Used for polling. */
const int iDelay = 1000; /* Delay until next poll (milliseconds) */
int nDelay; /* Maximum delay.*/
int msgid = atoi(PD("name","0"));
const int msgBefore = atoi(PD("before","0"));
int nLimit = msgBefore>0 ? atoi(PD("n","0")) : 0;
Blob sql = empty_blob;
Stmt q1;
nDelay = db_get_int("chat-poll-timeout",420); /* Default about 7 minutes */
login_check_credentials();
if( !g.perm.Chat ) return;
chat_create_tables();
cgi_set_content_type("text/json");
dataVersion = db_int64(0, "PRAGMA data_version");
blob_append_sql(&sql,
"SELECT msgid, datetime(mtime), xfrom, xmsg, length(file),"
|
| ︙ | ︙ |
Changes to src/setup.c.
| ︙ | ︙ | |||
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
"chat-keep-days", "chatkd", "7", 0);
@ <p>Chat message are removed after N days, where N is the value of
@ this setting. N may be fractional. So, for example, to only keep
@ an historical record of chat messages for 12 hours, set this value
@ to 0.5.
@ (Property: "chat-keep-days")</p>
@ <hr />
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_finish_page();
}
/*
| > > > > > > > > > > > > > | 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 |
"chat-keep-days", "chatkd", "7", 0);
@ <p>Chat message are removed after N days, where N is the value of
@ this setting. N may be fractional. So, for example, to only keep
@ an historical record of chat messages for 12 hours, set this value
@ to 0.5.
@ (Property: "chat-keep-days")</p>
@ <hr />
entry_attribute("Chat Polling Timeout", 10,
"chat-poll-timeout", "chatpt", "420", 0);
@ <p>New chat content is downloaded using the "long poll" technique.
@ HTTP requests are made to /chat-poll which blocks waiting on new
@ content to arrive. But the /chat-poll cannot block forever. It
@ eventual must give up and return an empty message set. This setting
@ determines how long /chat-poll will wait before giving up. The
@ default setting of approximately 7 minutes works well on many systems.
@ Shorter delays might be required on installations that use proxies
@ or web-servers with short timeouts. For best efficiency, this value
@ should be larger rather than smaller.
@ (Property: "chat-chat-timeout")</p>
@ </hr>
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
@ </div></form>
db_end_transaction(0);
style_finish_page();
}
/*
|
| ︙ | ︙ |