summaryrefslogtreecommitdiff
path: root/src/obswebsocket.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/obswebsocket.cr')
-rw-r--r--src/obswebsocket.cr22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr
index 3dfa5cc..f758632 100644
--- a/src/obswebsocket.cr
+++ b/src/obswebsocket.cr
@@ -45,6 +45,10 @@ module OBSWebSocket
@video = OBSWebSocket::VideoSettings.new( @@reqchan )
@stats = OBSWebSocket::Stats.new( @@reqchan )
@negotiated = false
+ @connecterror = 0
+ def negotiated?
+ return @negotiated
+ end
def reqchan
return @@reqchan
end
@@ -177,6 +181,7 @@ module OBSWebSocket
self.send( json_text )
when 2 # identified
@negotiated = true
+ @connecterror = 0
self.reqchan.send( { nil, "clear queue" } )
when 5 # event
eventsubs.each do | eventchan |
@@ -244,6 +249,23 @@ module OBSWebSocket
obs_pubsub.run
sleep 10
next
+ rescue ex : Socket::ConnectError | IO::Error
+ if @connecterror < 3
+ print ex.message
+ @connecterror += 1
+ ( @connecterror == 3 ) && ( @connecterror += 1 ) && print ". Suppressing further repeat errors."
+ print "\n"
+ end
+ obs_pubsub && obs_pubsub.close
+ @negotiated = false
+ sleep 10
+ next
+ rescue ex
+ pp ex
+ pp ex.backtrace?
+ obs_pubsub && obs_pubsub.close
+ @negotiated = false
+ next
end
end
end