frostbite-rcon-utils

createPacket(sequence, isFromServer, isResponse, data)

Creates a Packet object that you can supply to the encodePacket(packet) function.
You will use it when you have data you want to transform to a structure that encodePacket and calculatePacketSize can read.

Arguments

  1. sequence A Number. Keeps track of request/response pair.
  2. isFromServer A Boolean. Indicating that this packet originated on the server.
  3. isResponse A Boolean. Indicating that this is a response to another packet.
  4. words An Array. That have the command + arguments to be sent.

Returns

Packet: A Packet object.

Example

import net from 'net';
import { createPacket } from 'frostbite-rcon-utils';

let packet = createPacket(0, false, false, ['serverInfo']);

console.log(packet);
// =>
// {
//   sequence: 0,
//   isFromServer: false,
//   isResponse: false,
//   size: 
//   totalWords: 1,
//   words: ['serverInfo']
// }