diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/obswebsocket.cr | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr index 29bcaa6..3dfa5cc 100644 --- a/src/obswebsocket.cr +++ b/src/obswebsocket.cr @@ -118,7 +118,7 @@ module OBSWebSocket def initialize( uri : String ) spawn do loop do - obs5_pubsub = HTTP::WebSocket.new( URI.parse( uri ), HTTP::Headers{"Cookie" => "SESSIONID=1235", "Sec-WebSocket-Protocol" => "obswebsocket.json"} ) + obs_pubsub = HTTP::WebSocket.new( URI.parse( uri ), HTTP::Headers{"Cookie" => "SESSIONID=1235", "Sec-WebSocket-Protocol" => "obswebsocket.json"} ) openrequests = Hash( String, Channel( JSON::Any ) ).new eventsubs = Array( Channel(JSON::Any) ).new #metachan = Channel( Tuple( String, Channel( JSON::Any ) ) ).new @@ -134,7 +134,7 @@ module OBSWebSocket if reschan openrequests[ json["d"]["requestId"].as_s ] = reschan end - obs5_pubsub.send( msg[1] ) + obs_pubsub.send( msg[1] ) end elsif msgtuple[1] == "subscribe events" reschan = msgtuple[0] @@ -149,12 +149,12 @@ module OBSWebSocket if reschan openrequests[ json["d"]["requestId"].as_s ] = reschan end - obs5_pubsub.send( msgtuple[1] ) + obs_pubsub.send( msgtuple[1] ) elsif JSON.parse( msgtuple[1] )["op"].as_i64 == 1 print "SENT: " json = JSON.parse( msgtuple[1] ) pp json - obs5_pubsub.send( msgtuple[1] ) + obs_pubsub.send( msgtuple[1] ) else print "QUEUED: " pp msgtuple[1] @@ -162,14 +162,13 @@ module OBSWebSocket end end end - obs5_pubsub.on_message do | message | + obs_pubsub.on_message do | message | json = JSON.parse( message ) print( "RECEIVED: ") print( json.to_pretty_json ) print( "\n") if json["error"]? puts json["error"] - #ircipc.send( { "#" + settings["reqchan"], "| obs5: #{json["error"]}" } ) next end case json["op"].as_i64 @@ -242,7 +241,7 @@ module OBSWebSocket end end end - obs5_pubsub.run + obs_pubsub.run sleep 10 next end |