feat(gateway)!: switch handshake to req:connect (protocol v2)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Generated by scripts/protocol-gen-swift.ts — do not edit by hand
|
||||
import Foundation
|
||||
|
||||
public let GATEWAY_PROTOCOL_VERSION = 1
|
||||
public let GATEWAY_PROTOCOL_VERSION = 2
|
||||
|
||||
public enum ErrorCode: String, Codable {
|
||||
case notLinked = "NOT_LINKED"
|
||||
@@ -10,8 +10,7 @@ public enum ErrorCode: String, Codable {
|
||||
case unavailable = "UNAVAILABLE"
|
||||
}
|
||||
|
||||
public struct Hello: Codable {
|
||||
public let type: String
|
||||
public struct ConnectParams: Codable {
|
||||
public let minprotocol: Int
|
||||
public let maxprotocol: Int
|
||||
public let client: [String: AnyCodable]
|
||||
@@ -21,7 +20,6 @@ public struct Hello: Codable {
|
||||
public let useragent: String?
|
||||
|
||||
public init(
|
||||
type: String,
|
||||
minprotocol: Int,
|
||||
maxprotocol: Int,
|
||||
client: [String: AnyCodable],
|
||||
@@ -30,7 +28,6 @@ public struct Hello: Codable {
|
||||
locale: String?,
|
||||
useragent: String?
|
||||
) {
|
||||
self.type = type
|
||||
self.minprotocol = minprotocol
|
||||
self.maxprotocol = maxprotocol
|
||||
self.client = client
|
||||
@@ -40,7 +37,6 @@ public struct Hello: Codable {
|
||||
self.useragent = useragent
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
case minprotocol = "minProtocol"
|
||||
case maxprotocol = "maxProtocol"
|
||||
case client
|
||||
@@ -84,31 +80,6 @@ public struct HelloOk: Codable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct HelloError: Codable {
|
||||
public let type: String
|
||||
public let reason: String
|
||||
public let expectedprotocol: Int?
|
||||
public let minclient: String?
|
||||
|
||||
public init(
|
||||
type: String,
|
||||
reason: String,
|
||||
expectedprotocol: Int?,
|
||||
minclient: String?
|
||||
) {
|
||||
self.type = type
|
||||
self.reason = reason
|
||||
self.expectedprotocol = expectedprotocol
|
||||
self.minclient = minclient
|
||||
}
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case type
|
||||
case reason
|
||||
case expectedprotocol = "expectedProtocol"
|
||||
case minclient = "minClient"
|
||||
}
|
||||
}
|
||||
|
||||
public struct RequestFrame: Codable {
|
||||
public let type: String
|
||||
public let id: String
|
||||
@@ -537,9 +508,6 @@ public struct ShutdownEvent: Codable {
|
||||
}
|
||||
|
||||
public enum GatewayFrame: Codable {
|
||||
case hello(Hello)
|
||||
case helloOk(HelloOk)
|
||||
case helloError(HelloError)
|
||||
case req(RequestFrame)
|
||||
case res(ResponseFrame)
|
||||
case event(EventFrame)
|
||||
@@ -553,12 +521,6 @@ public enum GatewayFrame: Codable {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
let type = try typeContainer.decode(String.self, forKey: .type)
|
||||
switch type {
|
||||
case "hello":
|
||||
self = .hello(try Hello(from: decoder))
|
||||
case "hello-ok":
|
||||
self = .helloOk(try HelloOk(from: decoder))
|
||||
case "hello-error":
|
||||
self = .helloError(try HelloError(from: decoder))
|
||||
case "req":
|
||||
self = .req(try RequestFrame(from: decoder))
|
||||
case "res":
|
||||
@@ -574,9 +536,6 @@ public enum GatewayFrame: Codable {
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
switch self {
|
||||
case .hello(let v): try v.encode(to: encoder)
|
||||
case .helloOk(let v): try v.encode(to: encoder)
|
||||
case .helloError(let v): try v.encode(to: encoder)
|
||||
case .req(let v): try v.encode(to: encoder)
|
||||
case .res(let v): try v.encode(to: encoder)
|
||||
case .event(let v): try v.encode(to: encoder)
|
||||
|
||||
Reference in New Issue
Block a user