1.0.2 • Published 6 years ago

@lug/netproxy-node-ipc v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

NetProxy - node-ipc

Implementation of node-ipc in this module

Getting started

  • install npm i @lug/netproxy-node-ipc
  • use it
const {
  NetClientProxyNodeIpc,
  NetServerProxyNodeIpc
} = require('../netProxy')

const client = new NetClientProxyNodeIpc()
const server = new NetServerProxyNodeIpc()


server.ev.on('socket.data', (socket, data) => {
  server.send(socket, `I received your message : """${data}"""`)
})
server.ev.on('start', ()=>{
  setTimeout(client.disconnect.bind(client),1000)
  setTimeout(server.stop.bind(server),2500)
})

client.ev.on('connected', ()=>{
  client.send('Hey srv its me')
})

client.connect('localhost', 9999)
server.listen(9999)

Methods

At the end you will have this

  • Server
    • listen(port)
    • stop()
    • send(socket,data)
  • Client
    • connect(ip,port)
    • disconnect()
    • send(data)

and some events that are triggered when it needs to

Events

An event is fired with this.ev.emit('event'[,arg])

Server

eventargtypedescription
errorerroranywhen an error happen
start--when the server start listening
stop--when the server stop
socket.connectsocketsocketwhen a client connect
socket.disconnectsocketsocketwhen a client disconnect
socket.datasocket, datasocket, anywhen a client send data

Client

eventargtypedescription
errorerroranywhen an error happen
connect--when the client is connecting
connectedsocketsocketwhen the client is connected stop
disconnect--when a client disconnect
destroy--when a client is destroyed
datadataanywhen a client recieve data
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago