Adding wss

This commit is contained in:
Sergiotarxz 2023-04-02 21:38:58 +02:00
parent 07273a40bf
commit 797386845a
2 changed files with 7 additions and 2 deletions

View File

@ -144,7 +144,12 @@ export default function Page (): JSX.Element {
savestateFile.arrayBuffer().then((savestateBuffer) => { savestateFile.arrayBuffer().then((savestateBuffer) => {
const romArray = new Uint8Array(romBuffer) const romArray = new Uint8Array(romBuffer)
const savestateArray = new Uint8Array(savestateBuffer) const savestateArray = new Uint8Array(savestateBuffer)
const webSocket = new WebSocket(`ws://${window.location.host}/ws`) const locationProtocol = window.location.protocol
if (locationProtocol == null) {
return
}
const protocol = locationProtocol.match(/https:/) != null ? 'wss' : 'ws'
const webSocket = new WebSocket(`${protocol}://${window.location.host}/ws`)
setWebSocket(webSocket) setWebSocket(webSocket)
webSocket.binaryType = 'arraybuffer' webSocket.binaryType = 'arraybuffer'
webSocket.onclose = (message) => { webSocket.onclose = (message) => {

File diff suppressed because one or more lines are too long