Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Pairing - Change Messenger sync behaviour based on state #3241

Open
Tracked by #3248
Samyoul opened this issue Feb 28, 2023 · 0 comments
Open
Tracked by #3248

Local Pairing - Change Messenger sync behaviour based on state #3241

Samyoul opened this issue Feb 28, 2023 · 0 comments

Comments

@Samyoul
Copy link
Member

Samyoul commented Feb 28, 2023

I notice is that a lot of the syncing methods now have a nilable parameter, that seems to be nil in the majority of cases. Perhaps we could simplify the method logic and update Messenger's state with a "RawMessageHandler" register.

The consuming code would look like something below:

m.SetRawMessageHandler(rawMessageHandler)
m.SyncDevices()
m.SendPairInstallation(context.TODO)
m.ResetRawMessageHandler() // Defaults back to `dispatchPairInstallationMessage()`

Implementing this change would simplify the calling of all the functions that have an optional RawMessageHandler , future developers don't need to know what a RawMessageHandler is unless they want to change "broadcasting" behaviour.


Additionally we have precedent for altering Messenger behaviour via an update to state with the use of the localPairing field, this is used as below:

func (m *Messenger) hasPairedDevices() bool {
	logger := m.logger.Named("hasPairedDevices")

	if m.localPairing {
		return true
	}

	...
}

Consider the relationship between these two factors, localPairing and RawMessageHandler. Is there a link between them that would affect the implementation?

Perhaps if localPairing is true, a non-default RawMessageHandler should be present?

Details

#3202 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant