web-next: estado del reino como Online/Offline (puerto 8085) en vez del conteo
En el recuadro de estado de la home, la fila del reino mostraba el conteo de personajes online (0). Ahora muestra Online/Offline según un TCP check al worldserver (puerto 8085), con color verde/rojo como la fila Login. lib/home.ts añade world_status (checkServerStatus address:8085). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,8 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
|
|||||||
setRequestLocale(locale)
|
setRequestLocale(locale)
|
||||||
const { noticias, status } = await getData()
|
const { noticias, status } = await getData()
|
||||||
|
|
||||||
const online = status ? status.online_characters : 0
|
const worldStatus = status ? status.world_status : 'Offline'
|
||||||
|
const worldClass = worldStatus === 'Online' ? 'green-info' : 'red-info'
|
||||||
const loginStatus = status ? status.status : 'Offline'
|
const loginStatus = status ? status.status : 'Offline'
|
||||||
const loginClass = loginStatus === 'Online' ? 'green-info' : 'red-info'
|
const loginClass = loginStatus === 'Online' ? 'green-info' : 'red-info'
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ export default async function HomePage({ params }: { params: Promise<{ locale: s
|
|||||||
{status?.server_name ?? '—'}{' '}
|
{status?.server_name ?? '—'}{' '}
|
||||||
<span className="blue-info small-font">{status?.expansion ?? ''}</span>
|
<span className="blue-info small-font">{status?.expansion ?? ''}</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="real-info-box green-info">{online}</td>
|
<td className={`real-info-box ${worldClass}`}>{worldStatus}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Login</td>
|
<td>Login</td>
|
||||||
|
|||||||
+10
-1
@@ -16,8 +16,12 @@ export interface ServerStatus {
|
|||||||
expansion: string
|
expansion: string
|
||||||
online_characters: number
|
online_characters: number
|
||||||
status: 'Online' | 'Offline'
|
status: 'Online' | 'Offline'
|
||||||
|
world_status: 'Online' | 'Offline'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Puerto del worldserver (AzerothCore) para el estado del reino.
|
||||||
|
const WORLD_PORT = 8085
|
||||||
|
|
||||||
/** Etiqueta de expansión por build del cliente (incluye WoW Classic; Nova WoW = 3.4.3 = 54261). */
|
/** Etiqueta de expansión por build del cliente (incluye WoW Classic; Nova WoW = 3.4.3 = 54261). */
|
||||||
export function expansionFromGamebuild(gamebuild: number): string {
|
export function expansionFromGamebuild(gamebuild: number): string {
|
||||||
if (gamebuild === 12340) return 'WotLK'
|
if (gamebuild === 12340) return 'WotLK'
|
||||||
@@ -75,12 +79,17 @@ export async function getServerStatus(): Promise<ServerStatus | null> {
|
|||||||
)
|
)
|
||||||
const s = rows[0]
|
const s = rows[0]
|
||||||
if (!s) return null
|
if (!s) return null
|
||||||
const [online, up] = await Promise.all([getOnlineCount(), checkServerStatus(s.address, s.port)])
|
const [online, up, worldUp] = await Promise.all([
|
||||||
|
getOnlineCount(),
|
||||||
|
checkServerStatus(s.address, s.port),
|
||||||
|
checkServerStatus(s.address, WORLD_PORT),
|
||||||
|
])
|
||||||
return {
|
return {
|
||||||
server_name: s.name,
|
server_name: s.name,
|
||||||
address: s.address,
|
address: s.address,
|
||||||
expansion: expansionFromGamebuild(s.gamebuild),
|
expansion: expansionFromGamebuild(s.gamebuild),
|
||||||
online_characters: online,
|
online_characters: online,
|
||||||
status: up ? 'Online' : 'Offline',
|
status: up ? 'Online' : 'Offline',
|
||||||
|
world_status: worldUp ? 'Online' : 'Offline',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user