mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-22 12:02:22 +00:00
fix: ws now works as expexted
This commit is contained in:
@@ -25,7 +25,7 @@ export const CurrentlyPlayingBar: React.FC = () => {
|
||||
pauseVideo,
|
||||
playVideo,
|
||||
setCurrentlyPlayingState,
|
||||
stopVideo,
|
||||
stopPlayback,
|
||||
setIsPlaying,
|
||||
isPlaying,
|
||||
videoRef,
|
||||
@@ -260,7 +260,7 @@ export const CurrentlyPlayingBar: React.FC = () => {
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
setCurrentlyPlayingState(null);
|
||||
stopPlayback();
|
||||
}}
|
||||
className="aspect-square rounded flex flex-col items-center justify-center p-2"
|
||||
>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
import { apiAtom } from "@/providers/JellyfinProvider";
|
||||
import { useAtom } from "jotai";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { View, Text } from "react-native";
|
||||
import { currentlyPlayingItemAtom, playingAtom } from "../CurrentlyPlayingBar";
|
||||
|
||||
export const WebSocketsTest = () => {
|
||||
const [ws, setWs] = useState<WebSocket | null>(null);
|
||||
|
||||
const [api] = useAtom(apiAtom);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!api || !api.accessToken || !api.basePath) return;
|
||||
|
||||
// Set up WebSocket connection
|
||||
const newWebSocket = new WebSocket(
|
||||
`wss://${api?.basePath
|
||||
.replace("https://", "")
|
||||
.replace("http://", "")}/socket?api_key=${api?.accessToken}&deviceId=${
|
||||
api?.deviceInfo.id
|
||||
}`
|
||||
);
|
||||
|
||||
newWebSocket.onopen = () => {
|
||||
console.log("WebSocket connection established");
|
||||
// You can also send data once the connection is open
|
||||
newWebSocket.send(
|
||||
JSON.stringify({ type: "greeting", payload: "Hello from client!" })
|
||||
);
|
||||
};
|
||||
|
||||
newWebSocket.onmessage = (e) => {};
|
||||
|
||||
newWebSocket.onerror = (e) => {
|
||||
console.error("WebSocket error:", e);
|
||||
};
|
||||
|
||||
newWebSocket.onclose = (e) => {
|
||||
console.log("WebSocket connection closed:", e.reason);
|
||||
};
|
||||
|
||||
setWs(newWebSocket);
|
||||
|
||||
// Clean up function
|
||||
return () => {
|
||||
newWebSocket.close();
|
||||
};
|
||||
}, [api]);
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text>WebSocket Demo</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user