nrkno / sofie-atem-connection

Sofie ATEM Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
129 stars 36 forks source link

fix: disconnect called before connection has completed #107 #150

Closed Julusian closed 1 year ago

Julusian commented 1 year ago

bug fix

fixes #107

The cause was the assignment of _socketProcess happening async, meaning that if disconnect or destroy was called before that promise had resolved, then it would look like connect had never been called, and the cleanup would be skipped

There are two parts here. 1) _isDisconnecting is used by disconnect to skip the call to the threads connect method if disconnect is called while the thread is being created. Once the thread is created, disconnect previously operated as expected 2) _creatingSocket is used by destroy, so that it can wait for the thread creation to complete before attempting to destroy the thread. in the future, maybe this creation can be abortable, but that will require changes in threadedclass

Only given a very light synthetic test so far.