Implement client protocol version negotiation in server initialization (#107)
* Implement client version negotiation in server initialization * Add test coverage for version negotiation * Make Version.supported and Version.negotiate() APIs internal to not create new surface area
This commit is contained in:
parent
3690509fa0
commit
720a8102e9
1 changed files with 80 additions and 5 deletions
|
|
@ -486,15 +486,20 @@ public actor Server {
|
|||
try await hook(params.clientInfo, params.capabilities)
|
||||
}
|
||||
|
||||
// Set initial state
|
||||
// Perform version negotiation
|
||||
let clientRequestedVersion = params.protocolVersion
|
||||
let negotiatedProtocolVersion = Version.negotiate(
|
||||
clientRequestedVersion: clientRequestedVersion)
|
||||
|
||||
// Set initial state with the negotiated protocol version
|
||||
await self.setInitialState(
|
||||
clientInfo: params.clientInfo,
|
||||
clientCapabilities: params.capabilities,
|
||||
protocolVersion: params.protocolVersion
|
||||
protocolVersion: negotiatedProtocolVersion
|
||||
)
|
||||
|
||||
return Initialize.Result(
|
||||
protocolVersion: Version.latest,
|
||||
protocolVersion: negotiatedProtocolVersion,
|
||||
capabilities: await self.capabilities,
|
||||
serverInfo: self.serverInfo,
|
||||
instructions: nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue