Created
October 15, 2016 00:27
-
-
Save hiroto-takatoshi/ef4af8e3350bb0820693f829b1c6d38c to your computer and use it in GitHub Desktop.
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
var Leap = require("leapjs/lib/index") | |
var net = require('net'); | |
var JsonSocket = require('json-socket'); | |
/* | |
var WebSocketServer = require('ws').Server | |
, wss = new WebSocketServer({ port: 2333 }); | |
*/ | |
var mSocket; | |
var started = true; | |
var previousFrame; | |
var server = net.createServer(function(socket){ | |
mSocket = socket; | |
started = true; | |
console.log("client connected!"); | |
//socket.on("disconnect", function(){ | |
// started = false; | |
//}) | |
}); | |
/* | |
wss.broadcast = function broadcast(data) { | |
wss.clients.forEach(function each(client) { | |
client.send(data); | |
}); | |
}; | |
*/ | |
Leap.loop({enableGestures: true}, function(frame) { | |
if(started){ | |
if(frame.hands.length > 0){ | |
var hand = frame.hands[0]; | |
//mSocket.write(hand.rotation + ":" + hand.palmPosition.toString() + "\n"); | |
console.error(hand.rotation + ":" + hand.palmPosition.toString() + "\n"); | |
//wss.broadcast(hand.rotation + ":" + hand.palmPosition.toString() + "\n"); | |
//wss.broadcast("1"); | |
} | |
} | |
}) | |
//server.listen(2333, '192.168.43.90'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment