2022-01-10 23:36:01 +00:00
|
|
|
/**
|
|
|
|
* @param port The server port.
|
|
|
|
* @param timeout The read/write socket timeout.
|
|
|
|
*/
|
2023-12-08 11:26:10 +00:00
|
|
|
export type BedrockPingOptions = {
|
2023-12-09 13:38:37 +00:00
|
|
|
port?: number | undefined,
|
|
|
|
timeout?: number | undefined;
|
2022-01-10 23:36:01 +00:00
|
|
|
};
|
2022-01-10 20:21:47 +00:00
|
|
|
|
|
|
|
export type BedrockPingResponse = {
|
2024-03-30 13:41:42 +00:00
|
|
|
name: string;
|
2022-01-10 20:21:47 +00:00
|
|
|
version: {
|
2024-03-30 13:41:42 +00:00
|
|
|
gameVersion: string;
|
2022-01-10 20:21:47 +00:00
|
|
|
protocol: string;
|
|
|
|
};
|
|
|
|
players: {
|
|
|
|
max: string;
|
|
|
|
online: string;
|
|
|
|
};
|
|
|
|
description: string;
|
|
|
|
gamemode: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asynchronously ping Minecraft Bedrock server.
|
|
|
|
*
|
|
|
|
* The optional `options` argument can be an object with a `ping` (default is `19132`) or/and `timeout` (default is `5000`) property.
|
|
|
|
*
|
|
|
|
* @param host The Bedrock server address.
|
2023-12-09 13:38:37 +00:00
|
|
|
* @param options The configuration for pinging Minecraft Bedrock server.
|
2022-01-10 20:21:47 +00:00
|
|
|
*
|
|
|
|
* ```js
|
2022-01-10 23:47:14 +00:00
|
|
|
* import { pingBedrock } from '@minescope/mineping';
|
2022-01-10 20:21:47 +00:00
|
|
|
*
|
|
|
|
* const data = await pingBedrock('mco.mineplex.com');
|
|
|
|
* console.log(data);
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* The resulting output will resemble:
|
|
|
|
* ```console
|
|
|
|
* {
|
|
|
|
* version: { name: 'Mineplex', protocol: '475' },
|
|
|
|
* players: { max: '5207', online: '5206' },
|
|
|
|
* description: ' New Costumes',
|
|
|
|
* gamemode: 'Survival'
|
|
|
|
* }
|
|
|
|
* ```
|
2023-10-22 18:32:00 +00:00
|
|
|
* @see [source](https://github.com/minescope/mineping/blob/915edbec9c9ad811459458600af3531ec0836911/lib/bedrock.js#L204)
|
2022-01-10 20:21:47 +00:00
|
|
|
*/
|
2023-12-08 11:26:10 +00:00
|
|
|
export function pingBedrock(host: string, options?: BedrockPingOptions): Promise<BedrockPingResponse>;
|
2022-01-10 20:21:47 +00:00
|
|
|
|