We planned to upgrade GitLab and Mattermost to the latest version this Friday morning (early). You may experience some downtime!

Verified Commit f7471944 authored by Camil Staps's avatar Camil Staps 🚀

Keep server->client messages in a queue until a message handler is connected

parent f0ced702
...@@ -230,7 +230,7 @@ where ...@@ -230,7 +230,7 @@ where
(val :: stoc^) -> handler val w (val :: stoc^) -> handler val w
_ -> jsTrace "dynamic type mismatch" w // TODO handle gracefully _ -> jsTrace "dynamic type mismatch" w // TODO handle gracefully
# (fun,w) = jsWrapFun fun component w # (fun,w) = jsWrapFun fun component w
# w = (component .# "message_handler" .= fun) w # w = (component .# "setMessageHandler" .$! fun) w
-> w -> w
} }
......
...@@ -45,6 +45,7 @@ class Component { ...@@ -45,6 +45,7 @@ class Component {
this.abc=abc; this.abc=abc;
this.socket=socket; this.socket=socket;
this.message_handler=null; this.message_handler=null;
this.message_queue=[];
this.shared_clean_values=null; this.shared_clean_values=null;
this.do_debug=false; this.do_debug=false;
...@@ -108,7 +109,7 @@ class Component { ...@@ -108,7 +109,7 @@ class Component {
/* val is a base64-encoded serialized Dynamic */ /* val is a base64-encoded serialized Dynamic */
handleMsg (val) { handleMsg (val) {
if (this.message_handler==null){ if (this.message_handler==null){
console.log ('handleMsg called before a message handler was defined'); this.message_queue.push (val);
return; return;
} }
...@@ -116,6 +117,13 @@ class Component { ...@@ -116,6 +117,13 @@ class Component {
const args=[this, new CleanHeapValue (val)]; const args=[this, new CleanHeapValue (val)];
this.abc.interpret (this.message_handler,args); this.abc.interpret (this.message_handler,args);
} }
setMessageHandler (handler) {
this.message_handler=handler;
for (var i=0; i<this.message_queue.length; i++)
this.handleMsg (this.message_queue[i]);
delete this.message_queue;
}
} }
const DEFAULTS={ const DEFAULTS={
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment