trilemma-dev / SecureXPC

A simple and secure XPC framework for Swift
MIT License
75 stars 15 forks source link

Adds `requestID` to all requests and responses #82

Closed jakaplan closed 2 years ago

jakaplan commented 2 years ago

All requests now have a unique identifier and all replies reference this identifier. This is currently useless as the XPC framework itself makes sure that replies are associated back with their requests.

The reason for adding a requestID is to enable server handlers to respond with multiple values per request. From the client perspective this will be exposed as an AsyncSequence (and some sort of backwards compatibility closure-based version as well). These responses will in fact be sends from the server to the client, containing the requestID which then allows for them to be properly associated.

While there will probably be a fair amount of complexity under-the-hood to enable these multi-response scenarios, I believe it should be quite simple from an API user perspective - far simpler than arbitrary sends from the server to the client - so I'm excited to add this.

Since this is a fully separable (although by itself useless) part, I thought it best for it to have its own PR first.

jakaplan commented 2 years ago

@amomchilov for your review

amomchilov commented 2 years ago

From the client perspective this will be exposed as an AsyncSequence (and some sort of backwards compatibility closure-based version as well). These responses will in fact be sends from the server to the client, containing the requestID which then allows for them to be properly associated.

Wow, that's a very neat idea.