mirror of https://github.com/jetkvm/kvm.git
Removed diskChannel and localFile
This commit is contained in:
parent
2245dadae3
commit
34dff0a3aa
|
@ -105,9 +105,6 @@ export interface RTCState {
|
||||||
setRpcDataChannel: (channel: RTCDataChannel) => void;
|
setRpcDataChannel: (channel: RTCDataChannel) => void;
|
||||||
rpcDataChannel: RTCDataChannel | null;
|
rpcDataChannel: RTCDataChannel | null;
|
||||||
|
|
||||||
diskChannel: RTCDataChannel | null;
|
|
||||||
setDiskChannel: (channel: RTCDataChannel) => void;
|
|
||||||
|
|
||||||
peerConnectionState: RTCPeerConnectionState | null;
|
peerConnectionState: RTCPeerConnectionState | null;
|
||||||
setPeerConnectionState: (state: RTCPeerConnectionState) => void;
|
setPeerConnectionState: (state: RTCPeerConnectionState) => void;
|
||||||
|
|
||||||
|
@ -160,9 +157,6 @@ export const useRTCStore = create<RTCState>(set => ({
|
||||||
peerConnectionState: null,
|
peerConnectionState: null,
|
||||||
setPeerConnectionState: (state: RTCPeerConnectionState) => set({ peerConnectionState: state }),
|
setPeerConnectionState: (state: RTCPeerConnectionState) => set({ peerConnectionState: state }),
|
||||||
|
|
||||||
diskChannel: null,
|
|
||||||
setDiskChannel: (channel: RTCDataChannel) => set({ diskChannel: channel }),
|
|
||||||
|
|
||||||
mediaStream: null,
|
mediaStream: null,
|
||||||
setMediaStream: (stream: MediaStream) => set({ mediaStream: stream }),
|
setMediaStream: (stream: MediaStream) => set({ mediaStream: stream }),
|
||||||
|
|
||||||
|
@ -390,9 +384,6 @@ export interface RemoteVirtualMediaState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MountMediaState {
|
export interface MountMediaState {
|
||||||
localFile: File | null;
|
|
||||||
setLocalFile: (file: MountMediaState["localFile"]) => void;
|
|
||||||
|
|
||||||
remoteVirtualMediaState: RemoteVirtualMediaState | null;
|
remoteVirtualMediaState: RemoteVirtualMediaState | null;
|
||||||
setRemoteVirtualMediaState: (state: MountMediaState["remoteVirtualMediaState"]) => void;
|
setRemoteVirtualMediaState: (state: MountMediaState["remoteVirtualMediaState"]) => void;
|
||||||
|
|
||||||
|
@ -410,9 +401,6 @@ export interface MountMediaState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useMountMediaStore = create<MountMediaState>(set => ({
|
export const useMountMediaStore = create<MountMediaState>(set => ({
|
||||||
localFile: null,
|
|
||||||
setLocalFile: (file: MountMediaState["localFile"]) => set({ localFile: file }),
|
|
||||||
|
|
||||||
remoteVirtualMediaState: null,
|
remoteVirtualMediaState: null,
|
||||||
setRemoteVirtualMediaState: (state: MountMediaState["remoteVirtualMediaState"]) => set({ remoteVirtualMediaState: state }),
|
setRemoteVirtualMediaState: (state: MountMediaState["remoteVirtualMediaState"]) => set({ remoteVirtualMediaState: state }),
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ export function Dialog({ onClose }: { onClose: () => void }) {
|
||||||
const {
|
const {
|
||||||
modalView,
|
modalView,
|
||||||
setModalView,
|
setModalView,
|
||||||
setLocalFile,
|
|
||||||
setRemoteVirtualMediaState,
|
setRemoteVirtualMediaState,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
setErrorMessage,
|
setErrorMessage,
|
||||||
|
@ -58,7 +57,6 @@ export function Dialog({ onClose }: { onClose: () => void }) {
|
||||||
const [incompleteFileName, setIncompleteFileName] = useState<string | null>(null);
|
const [incompleteFileName, setIncompleteFileName] = useState<string | null>(null);
|
||||||
const [mountInProgress, setMountInProgress] = useState(false);
|
const [mountInProgress, setMountInProgress] = useState(false);
|
||||||
function clearMountMediaState() {
|
function clearMountMediaState() {
|
||||||
setLocalFile(null);
|
|
||||||
setRemoteVirtualMediaState(null);
|
setRemoteVirtualMediaState(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import {
|
||||||
USBStates,
|
USBStates,
|
||||||
useDeviceStore,
|
useDeviceStore,
|
||||||
useHidStore,
|
useHidStore,
|
||||||
useMountMediaStore,
|
|
||||||
useNetworkStateStore,
|
useNetworkStateStore,
|
||||||
User,
|
User,
|
||||||
useRTCStore,
|
useRTCStore,
|
||||||
|
@ -132,7 +131,6 @@ export default function KvmIdRoute() {
|
||||||
const {
|
const {
|
||||||
peerConnection, setPeerConnection,
|
peerConnection, setPeerConnection,
|
||||||
peerConnectionState, setPeerConnectionState,
|
peerConnectionState, setPeerConnectionState,
|
||||||
diskChannel, setDiskChannel,
|
|
||||||
setMediaStream,
|
setMediaStream,
|
||||||
setRpcDataChannel,
|
setRpcDataChannel,
|
||||||
isTurnServerInUse, setTurnServerInUse,
|
isTurnServerInUse, setTurnServerInUse,
|
||||||
|
@ -484,18 +482,12 @@ export default function KvmIdRoute() {
|
||||||
setRpcDataChannel(rpcDataChannel);
|
setRpcDataChannel(rpcDataChannel);
|
||||||
};
|
};
|
||||||
|
|
||||||
const diskDataChannel = pc.createDataChannel("disk");
|
|
||||||
diskDataChannel.onopen = () => {
|
|
||||||
setDiskChannel(diskDataChannel);
|
|
||||||
};
|
|
||||||
|
|
||||||
setPeerConnection(pc);
|
setPeerConnection(pc);
|
||||||
}, [
|
}, [
|
||||||
cleanupAndStopReconnecting,
|
cleanupAndStopReconnecting,
|
||||||
iceConfig?.iceServers,
|
iceConfig?.iceServers,
|
||||||
legacyHTTPSignaling,
|
legacyHTTPSignaling,
|
||||||
sendWebRTCSignal,
|
sendWebRTCSignal,
|
||||||
setDiskChannel,
|
|
||||||
setMediaStream,
|
setMediaStream,
|
||||||
setPeerConnection,
|
setPeerConnection,
|
||||||
setPeerConnectionState,
|
setPeerConnectionState,
|
||||||
|
@ -719,25 +711,6 @@ export default function KvmIdRoute() {
|
||||||
}
|
}
|
||||||
}, [navigate, navigateTo, queryParams, setModalView, setQueryParams]);
|
}, [navigate, navigateTo, queryParams, setModalView, setQueryParams]);
|
||||||
|
|
||||||
const { localFile } = useMountMediaStore();
|
|
||||||
useEffect(() => {
|
|
||||||
if (!diskChannel || !localFile) return;
|
|
||||||
diskChannel.onmessage = async e => {
|
|
||||||
console.debug("Received", e.data);
|
|
||||||
const data = JSON.parse(e.data);
|
|
||||||
const blob = localFile.slice(data.start, data.end);
|
|
||||||
const buf = await blob.arrayBuffer();
|
|
||||||
const header = new ArrayBuffer(16);
|
|
||||||
const headerView = new DataView(header);
|
|
||||||
headerView.setBigUint64(0, BigInt(data.start), false); // start offset, big-endian
|
|
||||||
headerView.setBigUint64(8, BigInt(buf.byteLength), false); // length, big-endian
|
|
||||||
const fullData = new Uint8Array(header.byteLength + buf.byteLength);
|
|
||||||
fullData.set(new Uint8Array(header), 0);
|
|
||||||
fullData.set(new Uint8Array(buf), header.byteLength);
|
|
||||||
diskChannel.send(fullData);
|
|
||||||
};
|
|
||||||
}, [diskChannel, localFile]);
|
|
||||||
|
|
||||||
// System update
|
// System update
|
||||||
const [kvmTerminal, setKvmTerminal] = useState<RTCDataChannel | null>(null);
|
const [kvmTerminal, setKvmTerminal] = useState<RTCDataChannel | null>(null);
|
||||||
const [serialConsole, setSerialConsole] = useState<RTCDataChannel | null>(null);
|
const [serialConsole, setSerialConsole] = useState<RTCDataChannel | null>(null);
|
||||||
|
|
|
@ -21,7 +21,6 @@ type Session struct {
|
||||||
ControlChannel *webrtc.DataChannel
|
ControlChannel *webrtc.DataChannel
|
||||||
RPCChannel *webrtc.DataChannel
|
RPCChannel *webrtc.DataChannel
|
||||||
HidChannel *webrtc.DataChannel
|
HidChannel *webrtc.DataChannel
|
||||||
DiskChannel *webrtc.DataChannel
|
|
||||||
shouldUmountVirtualMedia bool
|
shouldUmountVirtualMedia bool
|
||||||
rpcQueue chan webrtc.DataChannelMessage
|
rpcQueue chan webrtc.DataChannelMessage
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue