Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Jan 14, 2025
1 parent ce2a1ba commit 0eb8ef3
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/components/MGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,21 @@ const MGraph = () => {
type: 'subscribe_event'
}
// console.log('Send')
if (ws === 'mixedContent') {
alert(
'Mixed content error in Mgraph.ts: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.send(JSON.stringify(req.id && req))
}
const interval = setInterval(() => {
if (ws === 'mixedContent') {
alert(
'Mixed content error in Mgrapph interval: Cannot connect to ws:// from an https:// page.'
)
return
}
if (ws?.ws && ws.ws.readyState === WebSocket.OPEN) {
handleWebsockets()
clearInterval(interval)
Expand All @@ -221,6 +233,12 @@ const MGraph = () => {
type: 'unsubscribe_event',
event_type: 'graph_update'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Mgraph cleanup: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.send(JSON.stringify(request.id && request))
}
// console.log('Clean Up')
Expand Down
30 changes: 30 additions & 0 deletions src/pages/Settings/Webaudio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ const Webaudio = ({ style }: { style: CSSProperties }) => {
id: 8000 + i,
type: 'audio_stream_config'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Webaudio.ts getmedia: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.ws.send(JSON.stringify(++request.id && request))
}
sendWs()
Expand Down Expand Up @@ -153,6 +159,12 @@ const Webaudio = ({ style }: { style: CSSProperties }) => {
id: 8500 + i,
type: 'audio_stream_data_v2'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Webaudio.ts onaudioprocess v2: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.ws.send(JSON.stringify(++request.id && request))
}
const sendWsV1 = async () => {
Expand All @@ -163,6 +175,12 @@ const Webaudio = ({ style }: { style: CSSProperties }) => {
id: 8000 + i,
type: 'audio_stream_data'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Webaudio.ts onaudioprocess v1: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.ws.send(JSON.stringify(++request.id && request))
}
if (webAudType === 'audio_stream_data_v2') {
Expand Down Expand Up @@ -203,6 +221,12 @@ const Webaudio = ({ style }: { style: CSSProperties }) => {
id: 8200 + i,
type: 'audio_stream_stop'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Webaudio.ts fab: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.ws.send(JSON.stringify(++request.id && request))
}
sendWs().then(() => getSchemas())
Expand Down Expand Up @@ -359,6 +383,12 @@ const Webaudio = ({ style }: { style: CSSProperties }) => {
id: 8499,
type: 'audio_stream_start'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Webaudio.ts button: Cannot connect to ws:// from an https:// page.'
)
return
}
ws?.ws.send(JSON.stringify(request.id && request))
}
sendWs()
Expand Down
28 changes: 26 additions & 2 deletions src/utils/Websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function createSocket() {
'/api/websocket'

if (window.location.protocol === 'https:' && wsUrl.startsWith('ws://')) {
console.error(
console.warn(
'Mixed content error: Cannot connect to ws:// from an https:// page.'
)
return null
return 'mixedContent'
}

try {
Expand All @@ -47,6 +47,12 @@ function createSocket() {
}
})
)
if (ws === 'mixedContent') {
alert(
'Mixed content error in Websocket.ts onopen: Cannot connect to ws:// from an https:// page.'
)
return
}
if (ws) {
ws.ws = e.target as WebSocket

Expand Down Expand Up @@ -194,6 +200,12 @@ export const HandleWs = () => {
type: 'subscribe_event'
}
// console.log("Send");
if (ws === 'mixedContent') {
alert(
'Mixed content error in websocket.ts: Cannot connect to ws:// from an https:// page.'
)
return
}
if (ws) {
ws.send(JSON.stringify(++request.id && request))
}
Expand All @@ -209,6 +221,12 @@ export const HandleWs = () => {
type: 'unsubscribe_event',
event_type: 'visualisation_update'
}
if (ws === 'mixedContent') {
alert(
'Mixed content error in Websocket.ts cleanup: Cannot connect to ws:// from an https:// page.'
)
return
}
if (ws) {
ws.send(JSON.stringify(++request.id && request))
}
Expand All @@ -223,6 +241,12 @@ export const HandleWs = () => {

useEffect(() => {
const interval = setInterval(() => {
if (ws === 'mixedContent') {
alert(
'Mixed content error in Websocket.ts interval: Cannot connect to ws:// from an https:// page.'
)
return
}
if (ws && ws.ws && ws.ws.readyState === WebSocket.OPEN) {
setWsReady(true)
clearInterval(interval)
Expand Down

0 comments on commit 0eb8ef3

Please sign in to comment.