summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/obswebsocket.cr13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/obswebsocket.cr b/src/obswebsocket.cr
index 968957f..66a19f3 100644
--- a/src/obswebsocket.cr
+++ b/src/obswebsocket.cr
@@ -140,6 +140,8 @@ module OBSWebSocket
end
obs_pubsub.send( msg[1] )
end
+ elsif msgtuple[1] == "break"
+ break
elsif msgtuple[1] == "subscribe events"
reschan = msgtuple[0]
if reschan
@@ -270,8 +272,6 @@ module OBSWebSocket
end
end
obs_pubsub.run
- sleep 10
- next
rescue ex : Socket::ConnectError | IO::Error
if @connecterror < 3
print ex.message
@@ -279,16 +279,15 @@ module OBSWebSocket
( @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?
+ ensure
obs_pubsub && obs_pubsub.close
@negotiated = false
- next
+ @@reqchan.send( { nil, "break" } ) # ask reader fiber to terminate
+ # Should we invalidate all the cached ORM data here?
+ sleep 10
end
end
end