Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

Commit 83cd99e

Browse files
committed
Update mlestalk.js
1 parent ece457a commit 83cd99e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

static/js/mlestalk.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,14 @@ function sendEmptyJoin() {
334334
send_message(myname, mychannel, "", false);
335335
}
336336

337+
function sendInitJoin() {
338+
send_message(myname, mychannel, "", true);
339+
}
340+
337341
function send(isFull) {
338342
var message = $('#input_message').val();
343+
//var file = document.getElementById("input_file").files[0];
344+
339345
//if(file) {
340346
// send_image(myname, mychannel, file);
341347
// document.getElementById("input_file").value = "";
@@ -415,7 +421,7 @@ webWorker.onmessage = function(e) {
415421

416422
if(uid.length > 0 && channel.length > 0) {
417423
initOk = true;
418-
sendEmptyJoin();
424+
sendInitJoin();
419425

420426
var li;
421427
if(isReconnect && lastMessageSeenTs > 0) {
@@ -514,7 +520,10 @@ webWorker.onmessage = function(e) {
514520
multipart_dict[uid + channel] = null;
515521
}
516522

517-
if(message.length > 0 && idtimestamp[uid] <= msgTimestamp) {
523+
if(idtimestamp[uid] <= msgTimestamp) {
524+
if(isFull && 0 == message.length) /* Ignore init messages in timestamp processing */
525+
break;
526+
518527
if(!idreconnsync[uid]) {
519528
idlastmsghash[uid] = hash_message(uid, isFull ? msgTimestamp + message + '\n' : msgTimestamp + message);
520529
}
@@ -530,6 +539,9 @@ webWorker.onmessage = function(e) {
530539
if(lastMessageSeenTs < msgTimestamp)
531540
lastMessageSeenTs = msgTimestamp;
532541

542+
if(0 == message.length)
543+
break;
544+
533545
var li;
534546

535547
dateString = update_datestring(dateString);
@@ -680,7 +692,7 @@ function sync_reconnect() {
680692

681693
if('' != myname && '' != mychannel) {
682694
webWorker.postMessage(["reconnect", null, myname, mychannel, isTokenChannel]);
683-
sendEmptyJoin();
695+
sendInitJoin();
684696
}
685697
}
686698

@@ -693,7 +705,7 @@ function send_data(cmd, uid, channel, data, isFull, isImage, isMultipart, isFirs
693705
if(initOk) {
694706
var rarray = new Uint32Array(8);
695707
window.crypto.getRandomValues(rarray);
696-
var arr = [cmd, data, uid, channel, isTokenChannel, rarray, isFull, isImage, isMultipart, isFirst, isLast];
708+
var arr = [cmd, data, uid, channel, isTokenChannel, rarray, isFull, isImage, isMultipart, isFirst, isLast, Date.now()];
697709
if(!isResync || data.length == 0) {
698710
if(data.length > 0) {
699711
idlastmsghash[uid] = hash_message(uid, data);

0 commit comments

Comments
 (0)