{"_id":"@0x0c/rcon","name":"@0x0c/rcon","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@0x0c/rcon","version":"1.0.0","description":"Simple queued RCON client with support for multi-packeted responses.","author":{"name":"Ilya G.","email":"igorbachevsky@gmail.com"},"homepage":"https://github.com/keyCat/node-rcon","license":"ISC","main":"./dist/index.js","scripts":{"build":"tsc"},"devDependencies":{"@types/node":"20.9.0","prettier":"^3.0.3","typescript":"^5.4.5"},"_id":"@0x0c/rcon@1.0.0","gitHead":"62a3ab98ed1acaa3b89988aa68ccce9f3e413ec8","types":"./dist/index.d.ts","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-xDRcWqQV0N/iuBDUD31iffSxxdPOs2pZ9NRN7gZh5v7+O0U/ZrtVyCjnr0HvvqhQIZ32SUgXoF9CWDH7lb5Lrw==","shasum":"ac31bd86da9806e3fd8cbb58de5693d1c20e19d7","tarball":"https://registry.npmjs.org/@0x0c/rcon/-/rcon-1.0.0.tgz","fileCount":21,"unpackedSize":52041,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFogH7jO0ikl0Exl9gys2NgHhmkgzoTp7fwKnv7+OqcIAiBWlt4bh+81kpuX7/jMu49c8ijUteC0ElW6HqR8qJxtRw=="}]},"_npmUser":{"name":"keycat","email":"igorbachevsky@gmail.com"},"directories":{},"maintainers":[{"name":"keycat","email":"igorbachevsky@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rcon_1.0.0_1722319741614_0.14008398974242064"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-30T06:09:01.495Z","1.0.0":"2024-07-30T06:09:01.761Z","modified":"2024-07-30T06:09:02.247Z"},"maintainers":[{"name":"keycat","email":"igorbachevsky@gmail.com"}],"description":"Simple queued RCON client with support for multi-packeted responses.","homepage":"https://github.com/keyCat/node-rcon","author":{"name":"Ilya G.","email":"igorbachevsky@gmail.com"},"license":"ISC","readme":"# NodeJS RCON Client\n\n```bash\n$ npm install @0x0c/rcon\n```\n\nA zero-dependency, fully-typed Node.js library providing an client for interacting with servers that\nsupport [RCON protocol](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol).\n\nSupports multi-packeted responses, timeouts and queuing out of the box.\n\n## Quick Start\n\n```ts\nimport {RconClient} from '@0x0c/rcon';\n\nconst rcon = new RconClient({\n    host: '127.0.0.1',\n    port: 27015,\n    password: '<my-rcon-password>',\n});\n\nasync function queryStatus() {\n    const [status, stats] = await Promise.all([rcon.send('status'), rcon.send('stats')]);\n    myCustomParserForStatusCommandResponse(status);\n    parseAndStoreServerStats(stats);\n    // close connection when it is not required anymore\n    rcon.disconnect();\n}\n\nqueryStatus();\n```\n\n## API\n\n### `new RconClient(options): RconClient`\n\n| Argument                 | Type   | Description                                                             |\n|--------------------------|--------|-------------------------------------------------------------------------|\n| `options`                | object | Options                                                                 |\n| `options.host`           | string | IP address or hostname of the server                                    |\n| `options.port`           | number | RCON port                                                               |\n| `options.password`       | string | RCON Password                                                           |\n| [`options.timeout=5000`] | number | Optional. The timeout for the response in milliseconds. Default: `5000` |\n\n### `RconClient.connect(): Promise<void>`\n\nConnect to the server. This method is called automatically when you send the first command, but you can call it manually\nif you want to check the connection status after that.\n\n### `RconClient.connected: boolean`\n\nProperty that indicates whether the client is connected to the server.\n\n### `RconClient.send(command, options?): Promise<string>`\n\nSend command to the server an return the response as a string.\n\n| Argument                     | Type    | Description                                                                                                                 |\n|------------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------|\n| `command`                    | string  | Command to send                                                                                                             |\n| [`options`]                  | object  | Optional. Options                                                                                                           |\n| [`options.timeout`]          | number  | Optional. Set timeout for this command separately from connection timeout. Default: equals to connection timeout            |\n| [`options.multipacket=true`] | boolean | Optional. Send at least two commands using a \"boundary packet\" that helps to read multi-packeted responses. Default: `true` |\n\n### `RconClient.disconnect(): void`\n\nClose the connection to the server. Connection is kept alive between commands, so you should call this method when you\nare done to free up resources.\n\n## Notes\n\nBy default, all commands are sent with the expectation of _multi-packet response_.\n\nHowever, this means that even smallest replies may take twice as long (roughly) to resolve due to two packets being\nqueued: a packet for the command itself, and a \"boundary\" packet (a junk packet that helps the connection client to\nunderstand when a server has finished replying to the previously sequenced packet).\n\nYou can disable this feature when sending:\n\n```ts\nconst stats = await rcon.send('stats', {multipacket: false});\n```\n","readmeFilename":"README.md"}