Add WebMC & WS changes (#431)
Co-authored-by: Colbster937 <96893162+colbychittenden@users.noreply.github.com>
This commit is contained in:
parent
a88c8b5470
commit
634df8d03d
5 changed files with 13 additions and 4 deletions
|
|
@ -10,6 +10,10 @@
|
|||
{
|
||||
"ip": "wss://play.mcraft.fun"
|
||||
},
|
||||
{
|
||||
"ip": "wss://play.webmc.fun",
|
||||
"name": "WebMC"
|
||||
},
|
||||
{
|
||||
"ip": "wss://ws.fuchsmc.net"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export type AppConfig = {
|
|||
// defaultVersion?: string
|
||||
peerJsServer?: string
|
||||
peerJsServerFallback?: string
|
||||
promoteServers?: Array<{ ip, description, version? }>
|
||||
promoteServers?: Array<{ ip, description, name?, version?, }>
|
||||
mapsProvider?: string
|
||||
|
||||
appParams?: Record<string, any> // query string params
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ class CustomDuplex extends Duplex {
|
|||
}
|
||||
|
||||
export const getWebsocketStream = async (host: string) => {
|
||||
const baseProtocol = location.protocol === 'https:' ? 'wss' : host.startsWith('ws://') ? 'ws' : 'wss'
|
||||
const baseProtocol = host.startsWith('ws://') ? 'ws' : 'wss'
|
||||
const hostClean = host.replace('ws://', '').replace('wss://', '')
|
||||
const ws = new WebSocket(`${baseProtocol}://${hostClean}`)
|
||||
const hostURL = new URL(`${baseProtocol}://${hostClean}`)
|
||||
const hostParams = hostURL.searchParams
|
||||
hostParams.append('client_mcraft', '')
|
||||
const ws = new WebSocket(`${baseProtocol}://${hostURL.host}${hostURL.pathname}?${hostParams.toString()}`)
|
||||
const clientDuplex = new CustomDuplex(undefined, data => {
|
||||
ws.send(data)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQ
|
|||
}
|
||||
|
||||
const displayConnectButton = qsParamIp
|
||||
const serverExamples = ['example.com:25565', 'play.hypixel.net', 'ws://play.pcm.gg']
|
||||
const serverExamples = ['example.com:25565', 'play.hypixel.net', 'ws://play.pcm.gg', 'wss://play.webmc.fun']
|
||||
// pick random example
|
||||
const example = serverExamples[Math.floor(Math.random() * serverExamples.length)]
|
||||
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ const Inner = ({ hidden, customServersList }: { hidden?: boolean, customServersL
|
|||
...serversListProvided,
|
||||
...(customServersList ? [] : (miscUiState.appConfig?.promoteServers ?? [])).map((server): StoreServerItem => ({
|
||||
ip: server.ip,
|
||||
name: server.name,
|
||||
versionOverride: server.version,
|
||||
description: server.description,
|
||||
isRecommended: true
|
||||
|
|
@ -167,6 +168,7 @@ const Inner = ({ hidden, customServersList }: { hidden?: boolean, customServersL
|
|||
console.log('pingResult.fullInfo.description', pingResult.fullInfo.description)
|
||||
data = {
|
||||
formattedText: pingResult.fullInfo.description,
|
||||
icon: pingResult.fullInfo.favicon,
|
||||
textNameRight: `ws ${pingResult.latency}ms`,
|
||||
textNameRightGrayed: `${pingResult.fullInfo.players?.online ?? '??'}/${pingResult.fullInfo.players?.max ?? '??'}`,
|
||||
offline: false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue