Skip to content

Commit

Permalink
Fixed error with missing get_link_status function
Browse files Browse the repository at this point in the history
  • Loading branch information
jiveabillion committed Jan 9, 2024
1 parent d6d5b36 commit b9d948e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions civitai/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,20 @@ def command_response(payload, history=False):
def socketio_connect():
if (sio.connected): return
sio.connect(socketio_url, socketio_path='/api/socketio')
def is_connected() -> bool:
return sio.connected

current_key = None
def join_room(key):
if (current_key == key): return
def on_join(payload):
log(f"Joined room {key}")
sio.emit('join', key, callback=on_join)

def rejoin_room(key):
current_key = None
join_room(key)

old_short_key = None
def on_civitai_link_key_changed():
global old_short_key
Expand Down
11 changes: 5 additions & 6 deletions scripts/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ def connect_to_civitai(demo: gr.Blocks, app):
link.log('Connecting to Civitai Link Server')
link.socketio_connect()
link.join_room(key)

def get_link_status()-> bool:
return link.is_connected()

def reconnect_to_civitai() -> str:
key = shared.opts.data.get("civitai_link_key", None)
# If key is empty or not set, don't connect to Civitai Link
if not key:
msg = 'Civitai Link Key is empty'
link.log(msg)
return msg
if False and link.is_connected():
msg = 'Civitai Link already active'
link.log('Civitai Link already active')
return msg


link.log('Reconnecting to Civitai Link Server')
link.socketio_connect()
link.rejoin_room(key)
Expand All @@ -34,5 +32,6 @@ def reconnect_to_civitai() -> str:
return msg
else:
return 'Civitai Link not connected'

script_callbacks.on_app_started(connect_to_civitai)

1 comment on commit b9d948e

@okolokoorkay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job

Please sign in to comment.