Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Run this to receive a png image stream from your drone.
- var arDrone = require('..');
- var http = require('http');
- console.log('Connecting png stream ...');
- var pngStream = arDrone.createClient().getPngStream();
- var lastPng;
- pngStream
- .on('error', console.log)
- .on('data', function(pngBuffer) {
- lastPng = pngBuffer;
- });
- var server = http.createServer(function(req, res) {
- if (!lastPng) {
- res.writeHead(503);
- res.end('Did not receive any png data yet.');
- return;
- }
- res.writeHead(200, {'Content-Type': 'image/png'});
- res.end(lastPng);
- });
- server.listen(8080, function() {
- console.log('Serving latest png on port 8080 ...');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement