fix super message

This commit is contained in:
anlicheng 2026-05-27 22:48:47 +08:00
parent 32014d9634
commit 78ec74a0cb
7 changed files with 33 additions and 25 deletions

View File

@ -469,7 +469,7 @@ extension SDLContextActor {
// MARK: Super
extension SDLContextActor {
private func handleSuperMessage(message: SDLQUICInboundMessage) async {
private func handleSuperMessage(message: SDLSuperMessage) async {
switch message {
case .welcome(let welcome):
SDLLogger.log("[SDLContext] quic welcome: \(welcome)")

View File

@ -127,23 +127,6 @@ extension SDLStunProbeReply {
}
enum SDLQUICInboundMessage {
//
case welcome(SDLWelcome)
case pong
//
case registerSuperAck(SDLRegisterSuperAck)
case registerSuperNak(SDLRegisterSuperNak)
case peerInfo(SDLPeerInfo)
case event(SDLEvent)
case policyReponse(SDLPolicyResponse)
case exposedServiceResponse(SDLExposedServiceResponse)
case arpResponse(SDLArpResponse)
}
//
enum SDLEventType: UInt8 {

View File

@ -11,8 +11,8 @@ import Network
final class SDLSuperClient: @unchecked Sendable {
private let queue = DispatchQueue(label: "com.sdl.SuperClient.queue") // 线
//
public let messageStream: AsyncThrowingStream<SDLQUICInboundMessage, Error>
private let messageCont: AsyncThrowingStream<SDLQUICInboundMessage, Error>.Continuation
public let messageStream: AsyncThrowingStream<SDLSuperMessage, Error>
private let messageCont: AsyncThrowingStream<SDLSuperMessage, Error>.Continuation
private let stateLock = NSLock()
private var isStarted = false
@ -25,7 +25,7 @@ final class SDLSuperClient: @unchecked Sendable {
init(serverEndpoint: SDLConfiguration.ResolvedServerEndpoint, port: UInt16, maxBufferSize: Int = 2 * 1024 * 1024) {
self.maxBufferSize = maxBufferSize
let pairs = AsyncThrowingStream.makeStream(of: SDLQUICInboundMessage.self)
let pairs = AsyncThrowingStream.makeStream(of: SDLSuperMessage.self)
self.messageStream = pairs.stream
self.messageCont = pairs.continuation

View File

@ -8,7 +8,7 @@ import Foundation
import NIOCore
enum SDLSuperCodec {
public static func decode(frame: ByteBuffer) -> SDLQUICInboundMessage? {
public static func decode(frame: ByteBuffer) -> SDLSuperMessage? {
var buffer = frame
guard let type = buffer.readInteger(as: UInt8.self),
let packetType = SDLPacketType(rawValue: type) else {

View File

@ -0,0 +1,25 @@
//
// SDLQUICInboundMessage.swift
// punchnet
//
// Created by on 2026/5/27.
//
import Foundation
enum SDLSuperMessage {
//
case welcome(SDLWelcome)
case pong
//
case registerSuperAck(SDLRegisterSuperAck)
case registerSuperNak(SDLRegisterSuperNak)
case peerInfo(SDLPeerInfo)
case event(SDLEvent)
case policyReponse(SDLPolicyResponse)
case exposedServiceResponse(SDLExposedServiceResponse)
case arpResponse(SDLArpResponse)
}

View File

@ -1,7 +1,7 @@
import Foundation
actor SDLSuperService {
typealias MessageHandler = @Sendable (SDLQUICInboundMessage) async -> Void
typealias MessageHandler = @Sendable (SDLSuperMessage) async -> Void
private let serverEndpoint: SDLConfiguration.ResolvedServerEndpoint
private let port: UInt16
@ -74,7 +74,7 @@ actor SDLSuperService {
}
}
private func handleMessage(_ message: SDLQUICInboundMessage, generation: UInt64) async {
private func handleMessage(_ message: SDLSuperMessage, generation: UInt64) async {
guard self.generation == generation else {
return
}

View File

@ -7,7 +7,7 @@
import Foundation
final class SDLSuperSession: @unchecked Sendable {
typealias MessageHandler = @Sendable (SDLQUICInboundMessage) async -> Void
typealias MessageHandler = @Sendable (SDLSuperMessage) async -> Void
private let serverEndpoint: SDLConfiguration.ResolvedServerEndpoint
private let port: UInt16