steam-server-query
Version:
Module which implements the Master Server Query Protocol and Game Server Queries.
32 lines (31 loc) • 2.39 kB
TypeScript
import { InfoResponse, PlayerResponse, RulesResponse } from './gameServerTypes';
/**
* Send a A2S_INFO request to a game server. Retrieves information like its name, the current map, the number of players and so on.
*
* Read more [here](https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO).
* @param gameServer Host and port of the game server to call.
* @param attempts Optional. Number of call attempts to make. Default is 1 attempt.
* @param timeout Optional. Time in milliseconds after the socket request should fail. Default is 1000. Specify an array of timeouts if they should be different for every attempt.
* @returns A promise including an object of the type `InfoResponse`
*/
export declare function queryGameServerInfo(gameServer: string, attempts?: number, timeout?: number | number[]): Promise<InfoResponse>;
/**
* Send a A2S_PLAYER request to a game server. Retrieves the current playercount and for every player their name, score and duration.
*
* Read more [here](https://developer.valvesoftware.com/wiki/Server_queries#A2S_PLAYER).
* @param gameServer Host and port of the game server to call.
* @param attempts Optional. Number of call attempts to make. Default is 1 attempt.
* @param timeout Optional. Time in milliseconds after the socket request should fail. Default is 1000. Specify an array of timeouts if they should be different for every attempt.
* @returns A promise including an object of the type `PlayerResponse`
*/
export declare function queryGameServerPlayer(gameServer: string, attempts?: number, timeout?: number | number[]): Promise<PlayerResponse>;
/**
* Send a A2S_RULES request to a game server. Retrieves the rule count and for every rule its name and value.
*
* Read more [here](https://developer.valvesoftware.com/wiki/Server_queries#A2S_RULES).
* @param gameServer Host and port of the game server to call.
* @param attempts Optional. Number of call attempts to make. Default is 1 attempt.
* @param timeout Optional. Time in milliseconds after the socket request should fail. Default is 1000. Specify an array of timeouts if they should be different for every attempt.
* @returns A promise including an object of the type `RulesResponse`
*/
export declare function queryGameServerRules(gameServer: string, attempts?: number, timeout?: number | number[]): Promise<RulesResponse>;