1.0.21 • Published 3 years ago

@anzerr/net.socket v1.0.21

Weekly downloads
113
License
MIT
Repository
github
Last release
3 years ago

Intro

GitHub Actions status | linter GitHub Actions status | publish GitHub Actions status | test

Light wrapper around nodes net.socket

Install

npm install --save git+https://github.com/anzerr/net.socket.git
npm install --save @anzerr/net.socket

Example

Server

const net = require('net.socket');
let server = new net.Server('localhost:596');
server.on('message', (res) => {
	let client = res.client, payload = JSON.parse(res.payload.toString());
	console.log('Server recieve', client.id(), payload);
	client.send(JSON.stringify({pong: payload}));
});

Client

const net = require('net.socket');
let c = new net.Client('localhost:596');
c.on('connect', () => {
	console.log('client connected');
	c.send(JSON.stringify({test: 'cat10'}));
	c.on('message', (res) => {
		console.log('Client message', JSON.parse(res.toString()));
	});
});
1.0.21

3 years ago

1.0.20

4 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.12

6 years ago

1.0.10

6 years ago

1.0.11

6 years ago

1.0.4

6 years ago

1.0.5

6 years ago

1.0.6

6 years ago

1.0.7

6 years ago

1.0.8

6 years ago

1.0.9

6 years ago