feat/fix: implement WebSockets for NowPlaying, better data fetching with addl. Last.fm fetch, docker build fix

This commit is contained in:
Aidan 2025-09-07 00:09:06 -04:00
parent 4cec7406c3
commit 7121ec926f
11 changed files with 514 additions and 175 deletions

28
lib/socket.ts Normal file
View file

@ -0,0 +1,28 @@
"use client"
import { io, Socket } from "socket.io-client"
let socket: Socket | null = null
export const getSocket = (): Socket => {
if (!socket) {
socket = io(undefined, {
autoConnect: false,
})
}
return socket
}
export const connectSocket = (): Socket => {
const s = getSocket()
if (!s.connected) {
s.connect()
}
return s
}
export const disconnectSocket = (): void => {
if (socket?.connected) {
socket.disconnect()
}
}