summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/obswebsocket.cr15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr
index aea6eed..9af1856 100644
--- a/src/obswebsocket.cr
+++ b/src/obswebsocket.cr
@@ -127,8 +127,7 @@ module OBS
def transition!
self.send_sync( OBS.req( "TriggerStudioModeTransition" ) )
end
- # Asynchronous send
- def send( json : String )
+ def block_until_negotiated
unless @negotiated
@negotiationdelayqueue += 1
negotiationresult = @negotiationdelay.receive
@@ -137,18 +136,16 @@ module OBS
end
@negotiated || return false # not sure why this condition would occur without an exception
end
+ end
+ # Asynchronous send
+ def send( json : String )
+ self.block_until_negotiated()
STDERR.puts( "SENT: #{JSON.parse(json).pretty_inspect}" )
@websocket && @websocket.not_nil!.send( json )
end
# Block until response
def send_sync( json : String )
- unless @negotiated
- @negotiationdelayqueue += 1
- negotiationresult = @negotiationdelay.receive
- if negotiationresult.is_a?( Exception )
- raise negotiationresult
- end
- end
+ self.block_until_negotiated()
reschan = Channel( JSON::Any ).new
STDERR.puts( "SENT: #{JSON.parse(json).pretty_inspect}" )
@openrequests[ JSON.parse( json )["d"]["requestId"].as_s ] = reschan