fix super message
This commit is contained in:
parent
32014d9634
commit
78ec74a0cb
@ -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)")
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
25
Tun/Super/SDLSuperMessage.swift
Normal file
25
Tun/Super/SDLSuperMessage.swift
Normal 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)
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user