2022-01-10 23:36:01 +00:00
|
|
|
/**
|
|
|
|
* @param port The server port.
|
|
|
|
* @param timeout The read/write socket timeout.
|
|
|
|
*/
|
2023-12-08 11:41:24 +00:00
|
|
|
export type BedrockPingOptions = {
|
2022-01-10 23:36:01 +00:00
|
|
|
port: number,
|
|
|
|
timeout: number;
|
|
|
|
};
|
2022-01-10 20:21:47 +00:00
|
|
|
|
|
|
|
export type BedrockPingResponse = {
|
|
|
|
version: {
|
|
|
|
name: string;
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* ```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
|
|
|
*/
|
|
|
|
export function pingBedrock(host: string, options?: PingOptions): Promise<BedrockPingResponse>;
|
|
|
|
|