Ensure Accessory is able to be republished #910
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ensure Accessory is able to be republished
♻️ Current situation
Currently the ability to republish (calling
Accessory.publish
afterunpublish
has been called) isn't really supported.Further, there are regressions introduced in the past (see #895) which now prevent this completely.
💡 Proposed solution
This PR adds a minimal set of test cases to test the behavior of a
publish
call following aunpublish
call.Problem that is solved
With this test we identified three issues:
addIdentifyingMaterial
option was turned on, this was done a second time when republishingunpublish
is called instantly on theLISTENING
event and the CIAO advertiser is used one might encounter a race condition where the Probing step isn't properly canceled (as theunpublish
was called while the Networking stack was still initializing). This issue isn't currently fixed. As a workaround we introduced theADVERTISED
event to theAccessory
class which is triggered when the advertising step completed successfully. It is noted, that this might (due to the Probing) add significant delay to the event execution when using CIAO.Implications
➕ Additional Information
Both
Accessory.unpublish
andAccessory.destroy
calls where modified to return a Promise now, such that one can wait until the mDNS advertising was fully removed. This only has any effects when using the CIAO advertiser.Testing
A new test case was added to test publish and unpublish calls of an Accessory. The test case doesn't currently have extensive assertion logic (e.g. to test stuff around IdentifierCache, Accessory structure or other storage and state components). The test only expose a simple accessory (one service, no multiple service, multi controller or bridge setup).