1.0.1 • Published 2 years ago
@fillipe143/node-socket v1.0.1
const { ServerSocket } = require('@fillipe143/node-socket');
const { ClientSocket } = require('@fillipe143/node-socket');
const { ServerSocket } = require('@fillipe143/node-socket');
//http://localhost:3000
const options = {
host: 'localhost',
port: 3000
}
const server = new ServerSocket(options);
const { ClientSocket } = require('@fillipe143/node-socket');
//http://localhost:3000
const options = {
host: 'localhost',
port: 3000
}
const client = new ClientSocket(options);
on('connect', () => void): this //When the connection is created
on('error', (err) => void): this //When the connection fails
on('data', (data) => void): this //Receive data from other WebSocket libraries
on('close', () => void): this //When the connection is terminated
const { ServerSocket } = require('@fillipe143/node-socket');
const options = {
host: 'localhost',
port: 3000
}
const server = new ServerSocket(options);
server.on('connect', () => {
server.emit('event name', 'event data');
});
const { ClientSocket } = require('@fillipe143/node-socket');
const options = {
host: 'localhost',
port: 3000
}
const client = new ClientSocket(options);
server.on('event name', data => {
console.log('Received: ' + data);
});