This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('net'); | |
const client = new net.Socket(); | |
const config = { | |
host: '0.0.0.0', | |
port: 9670, | |
exclusive: true, | |
} | |
const timeout = 3000; | |
let retrying = false; | |
// Functions to handle client events |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require('net'); | |
const server = net.createServer(); | |
const config = { | |
host: '0.0.0.0', | |
port: 9670, | |
exclusive: true, | |
} | |
server.on('connection', (socket) => { | |
console.log('New client connected') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const client = require('./tcp/client'); | |
const EventEmitter = require('events'); | |
class OnDataEmitter extends EventEmitter { } | |
const OnData = new OnDataEmitter(); | |
const app = express() | |
// TCP Client data event listener that handles data event by the client. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return a new array, a subset of `list`, which matches `filter`. Assumes an | |
// array of objects and cyclers through each object, and looks at each property, | |
// and compares all string properties to the value of the `filter` string, | |
// returning only those which contain an exact match. | |
const filteredList = (filter = '', list = []) => { | |
if (filter) { | |
return list.filter((el) => { | |
return Object.keys(el).some((prop) => { | |
return el[prop] && | |
typeof el[prop] === 'string' && |
NewerOlder