import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif public struct GetGatewayResponse: Codable { let url: URL let shards: Int let session_start_limit: SessionStartLimit } public struct SessionStartLimit: Codable { let total: Int let remaining: Int let reset_after: Int let max_concurrency: Int } public enum GatewayPayload: Decodable { case hello(HelloPayload) } public struct GatewayMessage: Decodable { let op: Int let d: GatewayPayload? enum CodingKeys: String, CodingKey { case t case s case op case d } public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) op = try container.decode(Int.self, forKey: .op) switch op { case 10: let hello = try container.decode(HelloPayload.self, forKey: .d) d = .hello(hello) default: d = nil break } } } public struct HelloPayload: Codable { let heartbeat_interval: Int }