Forked from janmonschke/smarttv-debugging-server.js
Last active
October 26, 2017 00:56
-
-
Save andrewshulgin/cb0bb671535a04755c07752f75e5e236 to your computer and use it in GitHub Desktop.
[Improved] A simple debugging server for the Samsung SmartTV platform. Simply start the server and then connect your machine to the TV and it'll print out (and save) everything the TV sends
This file contains 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
var net = require('net'); | |
var fs = require('fs'); | |
function formatFileName (addr) { | |
return __dirname + '/log_' + addr + '_' + Math.floor(new Date().getTime() / 1000); | |
} | |
function formatMessage (addr, message) { | |
return '[' + addr + '] ' + message.trim() + '\n'; | |
} | |
var server = net.createServer(function (socket) { | |
process.stdout.write(formatMessage(socket.remoteAddress, 'connected')); | |
socket.on('data', function (data) { | |
fs.appendFile(formatFileName(socket.remoteAddress), formatMessage(socket.remoteAddress, data.toString())); | |
process.stdout.write(formatMessage(socket.remoteAddress, data.toString())); | |
}); | |
socket.on('end', function () { | |
process.stdout.write(formatMessage(socket.remoteAddress, 'disconnected')); | |
}); | |
}); | |
server.listen({port: 45634}, function () { | |
var address = server.address(); | |
process.stdout.write('listening on ' + address.address + ':' + address.port + '\n'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could you tell me the step on how to run this server on pc ?How to connect my pc to tv ? via Ethernet cable ?Hope you help mere.Thanks in avance