diff --git a/lib/STP/packets.js b/lib/STP/packets.js index 8347897..73d49fd 100644 --- a/lib/STP/packets.js +++ b/lib/STP/packets.js @@ -1,3 +1,6 @@ + +// #region === [ private lib functions ] === + class STPPacket { cmd = 'NOOP'; data = {}; @@ -12,15 +15,6 @@ class STPPacket { } } -class KeyExchangePacket extends STPPacket { - constructor(key, type = 'pkcs8-pem') { - super(); - this.cmd = 'KEY'; - this.data.key = key; - this.meta.type = type; - } -} - function basicPacket(commandName) { return class extends STPPacket { constructor() { @@ -30,6 +24,19 @@ function basicPacket(commandName) { } } +// #endregion + +// #region === [ exotic packet classes ] === + +class KeyExchangePacket extends STPPacket { + constructor(key, type = 'pkcs8-pem') { + super(); + this.cmd = 'KEY'; + this.data.key = key; + this.meta.type = type; + } +} + class ClientsPacket extends STPPacket { constructor(clients) { super(); @@ -38,9 +45,17 @@ class ClientsPacket extends STPPacket { } } +// #endregion + +// #region === [ ordinary packet classes ] === + const AckPacket = basicPacket('ACK'); const GetClientsPacket = basicPacket('QNODES'); +// #endregion + +// #region === [ public lib functions ] === + function reconstructPacket(packet) { if(packet.startsWith('\02')) @@ -62,11 +77,16 @@ function reconstructPacket(packet) { } -// module.exports.STPPacket = STPPacket; +// #endregion + +// #region === [ exports ] === + module.exports.KeyExchangePacket = KeyExchangePacket; module.exports.ClientsPacket = ClientsPacket; module.exports.AckPacket = AckPacket; module.exports.GetClientsPacket = GetClientsPacket; -module.exports.reconstructPacket = reconstructPacket; \ No newline at end of file +module.exports.reconstructPacket = reconstructPacket; + +// #endregion \ No newline at end of file