From 2fe815e0926c9587a0e90c6e56812f7dc8d707dd Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Thu, 11 Nov 2021 00:14:12 -0500 Subject: [PATCH] Don't broadcast emit calls inside do_connect() This prevents the "thinking" animation from appearing on top of the submit button under certain circumstances: * When someone connects to the KoboldAI server while the model is generating (occurs after generation finishes) * Occasionally, the browser may suddenly disconnect and reconnect from Flask-SocketIO during generation, which causes the same problem --- aiserver.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/aiserver.py b/aiserver.py index c903b624..3d1bc925 100644 --- a/aiserver.py +++ b/aiserver.py @@ -576,31 +576,31 @@ def do_connect(): sendsettings() refresh_settings() vars.laststory = None - emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True) + emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}) sendwi() - emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True) - emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True) + emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}) + emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}) vars.mode = "play" else: # Game in session, send current game data and ready state to browser refresh_story() sendsettings() refresh_settings() - emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}, broadcast=True) + emit('from_server', {'cmd': 'setstoryname', 'data': vars.laststory}) sendwi() - emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}, broadcast=True) - emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}, broadcast=True) + emit('from_server', {'cmd': 'setmemory', 'data': vars.memory}) + emit('from_server', {'cmd': 'setanote', 'data': vars.authornote}) if(vars.mode == "play"): if(not vars.aibusy): - emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}, broadcast=True) + emit('from_server', {'cmd': 'setgamestate', 'data': 'ready'}) else: - emit('from_server', {'cmd': 'setgamestate', 'data': 'wait'}, broadcast=True) + emit('from_server', {'cmd': 'setgamestate', 'data': 'wait'}) elif(vars.mode == "edit"): - emit('from_server', {'cmd': 'editmode', 'data': 'true'}, broadcast=True) + emit('from_server', {'cmd': 'editmode', 'data': 'true'}) elif(vars.mode == "memory"): - emit('from_server', {'cmd': 'memmode', 'data': 'true'}, broadcast=True) + emit('from_server', {'cmd': 'memmode', 'data': 'true'}) elif(vars.mode == "wi"): - emit('from_server', {'cmd': 'wimode', 'data': 'true'}, broadcast=True) + emit('from_server', {'cmd': 'wimode', 'data': 'true'}) #==================================================================# # Event triggered when browser SocketIO sends data to the server