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: