feat: Resume after disconnect
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user