3.2.2 • Published 5 years ago

netwiz v3.2.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 years ago

netwiz

Node.js Event Based TCP Networking

About

Netwiz provides a lightweight TCP client and server for sending data.

Install

npm install netwiz

Example

Server

const netwiz = require('netwiz')
const server = new netwiz.server();

server.on('connection', function(socket) {
    console.log('new connection');

    //broadcast to all connected sockets
    server.broadcast('networkConnection', null);

    socket.send('message', 'hello');

    socket.on('message', function(socket, data) {
        console.log('client said', data);
        socket.send('message', 'ok');
    });

    socket.on('disconnect', function() {
        //socket left
    })
});

server.on('disconnection', function(socket) {
    console.log('connection lost');
});

server.listen(3030, '0.0.0.0');

Client

const netwiz = require('netwiz');
const client = new netwiz.client();

client.on('connect', function() {
    console.log('connected')
});

client.on('message', function(data) {
    console.log('server said', data)
    client.send('message', 'goodbye');
    client.close();
});

client.on('disconnect', function() {
    console.log('disconnected');
});

client.on('networkConnection', function(data) {
    //handle global broadcast
})

client.connect(3030, '0.0.0.0');

License

Netwiz is released under the Apache-2.0 license, view the LICENSE file for more information.

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.4.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago