mirror of
https://github.com/MatrixSeven/file-transfer-go.git
synced 2026-05-18 10:37:29 +08:00
实现 WebRTC 数据通道管理器的 P2P 和 WS 中继模式支持,添加中继服务以处理 P2P 失败时的降级方案,更新相关接口和状态管理,增强错误处理和消息转发功能。
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
// 传输模式
|
||||
export type TransportMode = 'p2p' | 'relay';
|
||||
|
||||
export interface WebRTCState {
|
||||
isConnected: boolean;
|
||||
isConnecting: boolean;
|
||||
@@ -8,6 +11,8 @@ export interface WebRTCState {
|
||||
error: string | null;
|
||||
canRetry: boolean;
|
||||
currentRoom: { code: string; role: 'sender' | 'receiver' } | null;
|
||||
// 传输模式:p2p 直连 | relay 服务器中继
|
||||
transportMode: TransportMode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,6 +42,7 @@ const initialState: WebRTCState = {
|
||||
error: null,
|
||||
canRetry: false,
|
||||
currentRoom: null,
|
||||
transportMode: 'p2p',
|
||||
};
|
||||
|
||||
export const useWebRTCStore = create<WebRTCStore>((set) => ({
|
||||
|
||||
Reference in New Issue
Block a user