Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Upon initial connect to the chatroom, only load the most recent 50 messages. This magic number "50" ought to be configurable, but is hard-coded for the moment. We also need a way for the user to request more history. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | chatroom-dev |
| Files: | files | file ages | folders |
| SHA3-256: |
c017a7b4d072fb6e6ab5310ae427790e |
| User & Date: | drh 2020-12-23 16:08:38.591 |
Context
|
2020-12-23
| ||
| 16:11 | The althttpd webserver blocks the "/-50" part of the URL. So it has to be a query parameter. ... (check-in: 3d6267edad user: drh tags: chatroom-dev) | |
| 16:08 | Upon initial connect to the chatroom, only load the most recent 50 messages. This magic number "50" ought to be configurable, but is hard-coded for the moment. We also need a way for the user to request more history. ... (check-in: c017a7b4d0 user: drh tags: chatroom-dev) | |
| 15:35 | Add the /chat-delete page that can be used to by an XHR to delete a particular chat message. ... (check-in: 2480ce9465 user: drh tags: chatroom-dev) | |
Changes
Changes to src/chat.c.
| ︙ | ︙ | |||
222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
** to ask for new chat content. 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.
**
** The reply from this webpage is JSON that describes the new content.
** Format of the json:
**
** | {
** | "msg":[
** | {
** | "msgid": integer // message id
| > > > > > > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
** to ask for new chat content. 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.
**
** /chat-poll/N
**
** 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.
**
** The reply from this webpage is JSON that describes the new content.
** Format of the json:
**
** | {
** | "msg":[
** | {
** | "msgid": integer // message id
|
| ︙ | ︙ | |||
261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
int msgid = atoi(PD("name","0"));
Stmt q1;
login_check_credentials();
if( !g.perm.Chat ) return;
chat_create_tables();
cgi_set_content_type("text/json");
dataVersion = db_int64(0, "PRAGMA data_version");
db_prepare(&q1,
"SELECT msgid, datetime(mtime), xfrom, xmsg, length(file),"
" fname, fmime, mdel"
" FROM chat"
" WHERE msgid>%d"
" ORDER BY msgid",
msgid
| > > > > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
int msgid = atoi(PD("name","0"));
Stmt q1;
login_check_credentials();
if( !g.perm.Chat ) return;
chat_create_tables();
cgi_set_content_type("text/json");
dataVersion = db_int64(0, "PRAGMA data_version");
if( msgid<0 ){
msgid = db_int(0,
"SELECT msgid FROM chat WHERE mdel IS NOT true"
" ORDER BY msgid DESC LIMIT 1 OFFSET %d", -msgid);
}
db_prepare(&q1,
"SELECT msgid, datetime(mtime), xfrom, xmsg, length(file),"
" fname, fmime, mdel"
" FROM chat"
" WHERE msgid>%d"
" ORDER BY msgid",
msgid
|
| ︙ | ︙ |
Changes to src/chat.js.
1 2 |
(function(){
const form = document.querySelector('#chat-form');
| | | 1 2 3 4 5 6 7 8 9 10 |
(function(){
const form = document.querySelector('#chat-form');
let mxMsg = -50;
const F = window.fossil, D = F.dom;
const _me = F.user.name;
/* State for paste and drag/drop */
const BlobXferState = {
dropDetails: document.querySelector('#chat-drop-details'),
blob: undefined
};
|
| ︙ | ︙ |