Last active
August 29, 2015 14:11
-
-
Save 0x1mason/15f030f410a83f10bd00 to your computer and use it in GitHub Desktop.
hackathon socket magic
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 exec = require('child_process').exec; | |
var ADB = require('appium-adb'); | |
//var adb = new ADB(); | |
var template = '{"action":"Prepare", "cmd":"foo"}'; | |
// var args = process.argv.slice(2).join(' '); | |
// adb.getConnectedDevices(function(err, devices) { | |
// if (err) { | |
// console.log(err); | |
// process.exit(1); | |
// } | |
// devices.forEach(function(device) { | |
// var arg = "adb -s " + device.udid + " " + args; | |
// exec(arg, function(err, stdout, stderr){ | |
// if (err) { console.log ('error for device:', device.udid, err); } | |
// console.log(device.udid, ':', stdout, stderr || ''); | |
// }); | |
// }); | |
// }); | |
var startSock = function(port) { | |
var socket = net.connect(port, function () { | |
socket.setEncoding('utf8'); | |
console.log("Connected on " + port); | |
}); | |
socket.on('error', function (err) { | |
console.dir(err); | |
}); | |
socket.on('close', function () { | |
console.dir("Closing " + port); | |
}); | |
socket.on('data', function(data) { | |
console.dir(data); | |
}); | |
socket.write(template); | |
} | |
//exports.start = function (cb, onDie) { | |
var start = function (cb, onDie) { | |
startSock(4724); | |
}; | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment