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.
sequence
A Number. Keeps track of request/response pair.isFromServer
A Boolean. Indicating that this packet originated on the server.isResponse
A Boolean. Indicating that this is a response to another packet.words
An Array. That have the command + arguments to be sent.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']
// }