aboutsummaryrefslogtreecommitdiff
path: root/webclient
diff options
context:
space:
mode:
Diffstat (limited to 'webclient')
-rw-r--r--webclient/client.html19
1 files changed, 17 insertions, 2 deletions
diff --git a/webclient/client.html b/webclient/client.html
index 766b035..fce719d 100644
--- a/webclient/client.html
+++ b/webclient/client.html
@@ -4,7 +4,9 @@
<meta charset="utf-8">
<title>tomsg webclient</title>
<script>
-var sock=null,username=null;
+var PROTOCOL_VERSION=1;
+
+var sock=null,negotiated_version=false,username=null;
var roomlist=[":console"];
var currentroom=":console";
var roomlogs=new Map([[":console",[]]]);
@@ -80,7 +82,7 @@ function formatTime(date){
function net_historyCollectionCallback(id,list,count,cb, item,err){
if(err){
- cb(err);
+ cb(null,err);
} else {
list.push(item);
if(list.length==count){
@@ -95,6 +97,7 @@ function reconnect(){
if(sock)sock.close();
net_callbacks={};
+ negotiated_version=false;
var url;
if(location.hostname!="")url="wss://"+location.hostname;
@@ -145,6 +148,16 @@ function reconnect(){
});
sock.addEventListener("open",function(){
updateStatus();
+ net_send("version "+PROTOCOL_VERSION,function(ok,err){
+ if(err){
+ var msg="Server version incompatible (we need protocol version "+
+ PROTOCOL_VERSION+"): "+err;
+ addRoomEntry(":console","error",[now(),msg]);
+ } else {
+ negotiated_version=true;
+ updateStatus();
+ }
+ });
});
sock.addEventListener("close",function(ev){
updateStatus();
@@ -196,6 +209,8 @@ function updateStatus(){
str="not connected";
} else if(sock.readyState==0){
str="connecting...";
+ } else if(!negotiated_version){
+ str="versioning...";
} else if(username){
str="u: "+username;
} else {