feat: Resume after disconnect

This commit is contained in:
Andrew Glaze
2026-03-22 13:14:26 -04:00
parent bc72fc9781
commit e6426225d7
4 changed files with 122 additions and 59 deletions

View File

@@ -50,6 +50,7 @@ public struct SessionStartLimit: Codable, Sendable {
public enum GatewayPayload: Decodable, Sendable {
case hello(GatewayHello)
case messageCreate(MessageCreate)
case ready(GatewayReady)
}
public struct GatewayMessage: Decodable, Sendable {
@@ -77,6 +78,9 @@ public struct GatewayMessage: Decodable, Sendable {
case 0 where t == "MESSAGE_CREATE":
let messageCreate = try container.decode(MessageCreate.self, forKey: .d)
d = .messageCreate(messageCreate)
case 0 where t == "READY":
let ready = try container.decode(GatewayReady.self, forKey: .d)
d = .ready(ready)
default:
d = nil
break
@@ -91,8 +95,13 @@ public struct GatewayMessage: Decodable, Sendable {
}
}
public struct GatewayReady: Codable, Sendable {
public let session_id: String
public let resume_gateway_url: URL
}
public struct GatewayHello: Codable, Sendable {
let heartbeat_interval: Int
public let heartbeat_interval: Int
}
public struct CreateMessageReq: Codable, Sendable {