From ee567f106a3b57aa50f7047de8b9bb639a1ba74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Thu, 29 Feb 2024 07:09:33 +0000 Subject: [PATCH] make the obs disconnect button work (#86) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/86 Co-authored-by: Lera ElvoƩ Co-committed-by: Lera ElvoƩ --- addons/no-obs-ws/NoOBSWS.gd | 8 ++++++++ graph_node_renderer/deck_holder_renderer.gd | 13 ++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/addons/no-obs-ws/NoOBSWS.gd b/addons/no-obs-ws/NoOBSWS.gd index 200f3ee..629130a 100644 --- a/addons/no-obs-ws/NoOBSWS.gd +++ b/addons/no-obs-ws/NoOBSWS.gd @@ -30,6 +30,14 @@ func connect_to_obsws(port: int, password: String = "") -> void: _auth_required.connect(_authenticate.bind(password)) +func disconnect_from_obsws() -> void: + if _ws == null: + return + + _auth_required.disconnect(_authenticate) + _ws = null + + func make_generic_request(request_type: String, request_data: Dictionary = {}) -> RequestResponse: var response := RequestResponse.new() var message := Message.new() diff --git a/graph_node_renderer/deck_holder_renderer.gd b/graph_node_renderer/deck_holder_renderer.gd index 5b8532c..1bc7793 100644 --- a/graph_node_renderer/deck_holder_renderer.gd +++ b/graph_node_renderer/deck_holder_renderer.gd @@ -107,6 +107,11 @@ func _ready() -> void: Connections.obs_websocket = no_obsws Connections.twitch = %Twitch_Connection + no_obsws.event_received.connect( + func(m: NoOBSWS.Message): + Connections._obs_event_received(m.get_data()) + ) + Connections.twitch.chat_received_rich.connect(Connections._twitch_chat_received) file_popup_menu.set_item_shortcut(FileMenuId.NEW, new_deck_shortcut) @@ -348,14 +353,12 @@ func _on_obs_websocket_setup_dialog_connect_button_pressed(state: OBSWebsocketSe OBSWebsocketSetupDialog.ConnectionState.DISCONNECTED: obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.CONNECTING) no_obsws.subscriptions = obs_setup_dialog.get_subscriptions() - print(no_obsws.subscriptions) no_obsws.connect_to_obsws(obs_setup_dialog.get_port(), obs_setup_dialog.get_password()) await no_obsws.connection_ready obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.CONNECTED) - no_obsws.event_received.connect( - func(m: NoOBSWS.Message): - Connections._obs_event_received(m.get_data()) - ) + OBSWebsocketSetupDialog.ConnectionState.CONNECTED: + no_obsws.disconnect_from_obsws() + obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.DISCONNECTED) func _process(delta: float) -> void: