npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

battle-node-v2

v2.2.0

Published

Modern Promise-based BattlEye RCON Client for Node.js

Readme

Battle Node v2.2

Battle Node v2.2 is a modern, TypeScript-based Node.js client for the BattlEye RCON protocol. It supports standard BattlEye commands for games like ARMA 2, ARMA 3, DayZ, and others.

Target: Node.js 22+ (Native ESM, Built-in Test Runner, Native Arg Parsing)

Features

  • TypeScript: Written in strict TypeScript (ES2023) with full type definitions.
  • Zero Dependencies: Uses only native Node.js APIs (net, dgram, events, util).
  • Native Scheduler: Built-in task runner for automated commands (Anti-overlap, Human-readable intervals).
  • Reliable UDP: Automatic retries with exponential backoff, command queuing, and multipart packet reassembly.
  • Multi-Transport: Supports UDP (standard) and TCP (proxy) with correct stream framing.
  • Observability: Built-in statistics (getStats()) and structured logging.

Documentation

Installation

npm install battle-node-v2

Note: This package is purely ESM. You must use import syntax and have "type": "module" in your project's package.json.

Usage

Basic Example

import { BattleNode, BattleNodeConfig } from 'battle-node-v2';

const config: BattleNodeConfig = {
  ip: '127.0.0.1',
  port: 2302,
  rconPassword: 'your_password'
};

const client = new BattleNode(config);

try {
  await client.login();
  console.log('Logged in!');
  
  // Use typed helper methods
  const players = await client.getPlayers();
  console.log('Players:', players);
  
  // Scheduler Example: Auto-save every 10 minutes
  client.scheduler.addTask('auto_save', '10m', async () => {
      console.log('Saving server...');
      await client.sendCommand('#save');
  });

} catch (error) {
  console.error('RCON Error:', error);
  client.disconnect();
}

Production Ready Example

This example demonstrates retry logic, custom logging, and graceful shutdown.

import { BattleNode, BattleNodeConfig } from 'battle-node-v2';

const config: BattleNodeConfig = {
  ip: '192.168.1.144',
  port: 2302,
  rconPassword: 'your_password',
  
  // Reliability Settings
  timeout: 5000,          // Connection timeout
  maxRetries: 3,         // Retry commands up to 3 times
  retryDelay: 1000,      // Exponential backoff base delay
  
  // Custom Logging
  logLevel: 'info',
  logger: (level, msg, meta) => {
     const timestamp = new Date().toISOString();
     console.log(`[${timestamp}] [${level.toUpperCase()}] ${msg}`, meta || '');
  }
};

const client = new BattleNode(config);

client.on('message', (msg) => console.log('[SERVER]:', msg));
client.on('disconnected', () => console.log('Disconnected from server'));

async function main() {
  try {
    await client.login();
    console.log('RCON Connected');

    // Auto-Announce every 2 hours
    client.scheduler.addTask('announcer', '2h', async () => {
        await client.say('Join our Discord!');
    });

  } catch (err) {
    console.error('Failed to connect:', err);
    process.exit(1);
  }
}

// Graceful Shutdown
process.on('SIGINT', () => {
    client.disconnect(); // Stops scheduler and closes socket
    process.exit(0);
});

main();

CLI Tool

The package includes a built-in CLI for quick server management using native argument parsing.

# Run directly with npx
npx battle-node-v2 -i 127.0.0.1 -p 2302 -P mypassword

# Or install globally
npm install -g battle-node-v2
battle-rcon --ip 192.168.1.144 --port 2302 --password mypassword

License

MIT