summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/obswebsocket.cr47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr
index df84cba..da188bc 100644
--- a/src/obswebsocket.cr
+++ b/src/obswebsocket.cr
@@ -159,9 +159,9 @@ module OBSWebSocket
if msgtuple[1] == "clear queue"
queue.each do | msg |
reschan = msg[0]
- print( "SENT: " )
+ STDERR.print( "SENT: " )
json = JSON.parse(msg[1])
- pp json
+ STDERR.print( json.pretty_inspect )
if reschan
openrequests[ json["d"]["requestId"].as_s ] = reschan
end
@@ -176,37 +176,36 @@ module OBSWebSocket
end
elsif @negotiated
reschan = msgtuple[0]
- print "SENT: "
+ STDERR.print( "SENT: " )
json = JSON.parse( msgtuple[1] )
- pp json
+ STDERR.print( json.pretty_inspect )
if reschan
openrequests[ json["d"]["requestId"].as_s ] = reschan
end
@obs_pubsub.send( msgtuple[1] )
elsif JSON.parse( msgtuple[1] )["op"].as_i64 == 1
- print "SENT: "
+ STDERR.print( "SENT: " )
json = JSON.parse( msgtuple[1] )
- pp json
+ STDERR.print( json.pretty_inspect )
@obs_pubsub.send( msgtuple[1] )
else
- print "QUEUED: "
- pp msgtuple[1]
+ STDERR.print( "QUEUED: " )
+ STDERR.print( msgtuple[1].pretty_inspect )
queue.push( { msgtuple[0], msgtuple[1] } )
end
end
end
@obs_pubsub.on_message do | message |
json = JSON.parse( message )
- print( "RECEIVED: ")
- print( json.to_pretty_json )
- print( "\n")
+ STDERR.print( "RECEIVED: ")
+ STDERR.print( json.to_pretty_json )
+ STDERR.print( "\n")
if json["error"]?
- puts json["error"]
+ STDERR.puts( json["error"] )
next
end
case json["op"].as_i64
when 0 # hello
-
hello = JSON.build do |j|
j.object do
j.field "op", 1
@@ -324,7 +323,7 @@ module OBSWebSocket
when "SourceFilterEnableStateChanged"
edata = json["d"]["eventData"]
if ( source = @sources[edata["sourceName"].as_s]? )
- puts "SourceFilterEnableStateChanged: #{source.class}"
+ STDERR.puts( "SourceFilterEnableStateChanged: #{source.class}" )
source.filters[edata["filterName"].as_s].enabledcache( edata["filterEnabled"].as_bool )
else
raise SourceMissingException.new( "SourceFilterEnableStateChanged: missing source #{ edata["sourceName"].as_s}" )
@@ -350,7 +349,7 @@ module OBSWebSocket
spawn do
d = json["d"]
if d["requestStatus"]["result"].as_bool == false
- puts "ERROR: #{d["requestType"].as_s} #{d["requestStatus"]["code"].as_i64}: #{d["requestStatus"]["comment"].as_s}"
+ STDERR.puts( "ERROR: #{d["requestType"].as_s} #{d["requestStatus"]["code"].as_i64}: #{d["requestStatus"]["comment"].as_s}" )
end
if openrequests[ d["requestId"].as_s ]?
channel = openrequests[ d["requestId"].as_s ]
@@ -358,7 +357,7 @@ module OBSWebSocket
channel.close
openrequests.delete( d["requestId"].as_s )
else
- puts "PUBSUBREAD THREAD: no response channel known for requestId: #{ d["requestId"].as_s }"
+ STDERR.puts( "PUBSUBREAD THREAD: no response channel known for requestId: #{ d["requestId"].as_s }" )
end
end
Fiber.yield
@@ -367,14 +366,14 @@ module OBSWebSocket
@obs_pubsub.run
rescue ex : Socket::ConnectError | IO::Error
if @connecterror < 3
- print ex.message
+ STDERR.print( ex.message )
@connecterror += 1
- ( @connecterror == 3 ) && ( @connecterror += 1 ) && print ". Suppressing further repeat errors."
- print "\n"
+ ( @connecterror == 3 ) && ( @connecterror += 1 ) && STDERR.print( ". Suppressing further repeat errors." )
+ STDERR.print( "\n" )
end
rescue ex
- pp ex
- pp ex.backtrace?
+ STDERR.print( ex.pretty_inspect )
+ STDERR.print( ex.backtrace?.pretty_inspect )
ensure
@closed || @obs_pubsub.close
@negotiated = false
@@ -414,8 +413,8 @@ module OBSWebSocket
@reqchan.send( { reschan, OBSWebSocket.req( "GetOutputList", UUID.random.to_s ) } )
d = reschan.receive
if ( rdata = d["responseData"]? )
- print "OUTPUTS THREAD: "
- pp rdata
+ STDERR.print( "OUTPUTS THREAD: " )
+ STDERR.print( rdata.pretty_inspect )
rdata["outputs"].as_a.each do | output |
@outputs[output["outputName"].as_s] = OBSWebSocket::Output.new( @reqchan, output )
end
@@ -592,7 +591,7 @@ module OBSWebSocket
return true
end
def invalidate
- puts "SCENELIST THREAD: scenes invalidated"
+ STDERR.puts( "SCENELIST THREAD: scenes invalidated" )
@scenes_by_index = Array(String).new
@scenes = Hash(String, OBSWebSocket::Scene).new
@program = String.new