diff --git a/addons/no-obs-ws/NoOBSWS.gd b/addons/no-obs-ws/NoOBSWS.gd index 360ee244..e951c748 100644 --- a/addons/no-obs-ws/NoOBSWS.gd +++ b/addons/no-obs-ws/NoOBSWS.gd @@ -24,10 +24,14 @@ signal event_received(event: Message) signal _auth_required() +func is_open() -> bool: + return _ws != null and _ws.get_ready_state() == WebSocketPeer.STATE_OPEN + func connect_to_obsws(port: int, host: String = "127.0.0.1", password: String = "") -> void: _ws = WebSocketPeer.new() _ws.connect_to_url(WS_URL % [host,port]) - _auth_required.connect(_authenticate.bind(password)) + if not _auth_required.is_connected(_authenticate): + _auth_required.connect(_authenticate.bind(password)) func disconnect_from_obsws() -> void: