-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (33 loc) · 851 Bytes
/
server.js
File metadata and controls
40 lines (33 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use-strict'
net = require('net');
const express = require('express');
const http = require('http');
const socketIo = require('socket.io');
gt06 = require('./tools/gt06');
//VARIBALES
cont = 0;
//TCP SERVER
net.createServer(function (connection) {
connection.on('data', function (data) {
vico = gt06.parse_data(data);
if (vico.protocal_id == '01') {
cont = cont+1;
console.log(cont);
}
});
}).on('error', (err) => {
console.log("Aqui el error del TCP---" + err);
}).listen(5000);
//HTTP SERVER
const app = express();
app.get('/', (req, res) => {
res.send("INICIADO")
});
const server = http.Server(app);
server.listen(3000);
const io = socketIo(server);
io.on('connection', (socket) => {
socket.emit('hello', {
nobre: 'Victor Anaya'
});
});