mirror of
https://github.com/minescope/mineping.git
synced 2025-07-13 08:14:35 +03:00
refactor!: decouple Raknet MOTD parsing and response shaping
The previous implementation of the RakNet ping was monolithic, mixing socket management, raw packet validation, and data transformation into a single, complex flow. This refactor introduces a clear, multi-stage processing pipeline that separates these concerns. The logic is now broken down into multi-stage pipeline: extracting the MOTD string from the raw pong packet -> parsing that string into a raw object -> transforming the raw data into a user-friendly response object. Additionally, the socket handling logic is improved with idempotent cleanup function to prevent resource leaks or race conditions. As part of this overhaul, external TypeScript definition (`.d.ts`) files have been removed in favor of rich JSDoc annotations. BREAKING CHANGE: The structure of the resolved `BedrockPingResponse` object has been significantly changed to improve clarity and consistency.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { pingBedrock } from "../index.js";
|
||||
|
||||
const host = "mc.nevertime.su";
|
||||
const ping = await pingBedrock(host);
|
||||
console.log(ping);
|
||||
const host = "0.0.0.0";
|
||||
const motd = await pingBedrock(host);
|
||||
console.log(motd);
|
||||
|
Reference in New Issue
Block a user