1.3.0 • Published 10 days ago

node-snet v1.3.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
10 days ago

Node Simple Network

NodeJS port of LuaJIT SNet

SNET - cross-platform, open source, network library

Install

npm install node-snet
yarn add node-snet
pnpm add node-snet

Example

import { Server, BitStream } from 'node-snet';

const server = new Server({
  port: 11321,
  clientTimeout: 10000,
  ipVersion: 'v6'
});

server.on('ready', () => {
  console.log(`@server: started at port ${server.port}`);
});

server.on('onReceivePacket', async (id, bs, address, port) => {
  console.log(`onReceivePacket: ${address}:${port}`, id, bs.toString());
  if (id === 1) {
    const data = new BitStream();
    data.writeString('snetwork');
    server.sendAll(2, data, 4);
  }
});

server.on('onClientUpdate', async (address, port, type) => {
  console.log(`onClientUpdate ${address}:${port}:`, type);
});

server.listen();

// or change port
// server.listen(7788).then(() => console.log('listen'))
1.3.0

10 days ago

1.2.0

22 days ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.4

12 months ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago