I'm trying to do a TCP listener in order to grab the information sent by a GPS Tracker.
I've done the following with node.js net package
let net = require('net');
let netServer = net.createServer(function (socket) {
//Once we receive data...
socket.on('data', function (data) {
console.log('data');
console.log(data.toString().length);
console.log(data.toString());
});
socket.on('end', function () {
console.log('end');
});
socket.on('error', function (err) {
console.log('error');
console.log(err.message);
console.log(err.name);
console.log(err.stack);
});
});
netServer.listen(7018);
I'd love to do the same but with SocketCluster. Can someone give a quick tip on this?
This is one of the approach I've tried so far, but without success:
var net = require('net');
var socketClusterServer = require('socketcluster-server');
var net = net.createServer();
var scServer = socketClusterServer.attach(net);
net.listen(7018);
scServer.on('connection', function (socket) {
connection.on('data', function (data) {
console.log('data');
console.log(data.toString());
});
});
Since WebSockets is based on TCP, it's possible but a lot of work. You'd have to implement the WebSocket client protocol from scratch. https://datatracker.ietf.org/doc/html/rfc6455
I'm trying to do a TCP listener in order to grab the information sent by a GPS Tracker.
I've done the following with node.js net package
I'd love to do the same but with SocketCluster. Can someone give a quick tip on this?
This is one of the approach I've tried so far, but without success: