make the obs disconnect button work (#86)

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/86
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-02-29 07:09:33 +00:00 committed by yagich
parent e2822536b1
commit ee567f106a
2 changed files with 16 additions and 5 deletions

View file

@ -30,6 +30,14 @@ func connect_to_obsws(port: int, password: String = "") -> void:
_auth_required.connect(_authenticate.bind(password)) _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: func make_generic_request(request_type: String, request_data: Dictionary = {}) -> RequestResponse:
var response := RequestResponse.new() var response := RequestResponse.new()
var message := Message.new() var message := Message.new()

View file

@ -107,6 +107,11 @@ func _ready() -> void:
Connections.obs_websocket = no_obsws Connections.obs_websocket = no_obsws
Connections.twitch = %Twitch_Connection 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) Connections.twitch.chat_received_rich.connect(Connections._twitch_chat_received)
file_popup_menu.set_item_shortcut(FileMenuId.NEW, new_deck_shortcut) 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: OBSWebsocketSetupDialog.ConnectionState.DISCONNECTED:
obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.CONNECTING) obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.CONNECTING)
no_obsws.subscriptions = obs_setup_dialog.get_subscriptions() 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()) no_obsws.connect_to_obsws(obs_setup_dialog.get_port(), obs_setup_dialog.get_password())
await no_obsws.connection_ready await no_obsws.connection_ready
obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.CONNECTED) obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.CONNECTED)
no_obsws.event_received.connect( OBSWebsocketSetupDialog.ConnectionState.CONNECTED:
func(m: NoOBSWS.Message): no_obsws.disconnect_from_obsws()
Connections._obs_event_received(m.get_data()) obs_setup_dialog.set_button_state(OBSWebsocketSetupDialog.ConnectionState.DISCONNECTED)
)
func _process(delta: float) -> void: func _process(delta: float) -> void: