0.0.13 • Published 2 years ago

local-connect v0.0.13

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

local-connect

Create a connection between all your app on the same network

Installation

Using npm:

$ npm i local-connect

Usage

const { LocalConnection } = require("local-connect")
const id = "com.myapp.myid" //id used to recognize apps of the same id in the network
const lc = new LocalConnection(id)

lc.scan() //start scanning the ip trying to connect to it

lc.on("scan_finish", () => { //when scan is finish
    console.log(lc.connections.size); //log the number of connections
})

lc.on("connection", (socket) => { //when a connection starting; socket is a socket.io's Socket
    console.log("new connection");
    console.log(lc.connections.size); //log the number of connections
    socket.on("disconnect", () => { //when connection is finish
        console.log("disconnect");
        console.log(lc.connections.size); //log the number of connections
    })
})

lc.on("scanning", (i, total) => { //when an ip has been scanned
    console.log(`${i}/${total}`); //i is index of ip; total is total of ips to scan
})
0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago