Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. var rfb = require('..');
  2. var r = rfb.createConnection({
  3. host: '127.0.0.1',
  4. port: 5921,
  5. password: '',
  6. //encodings: [rfb.encodings.raw],
  7. encodings: [rfb.encodings.tightPng, rfb.encodings.raw],
  8. });
  9.  
  10. r.on('connect', function() {
  11. console.log('successfully connected and authorised');
  12. console.log('remote screen name: ' + r.title + ' width:' + r.width + ' height: ' + r.height);
  13. //r.updateClipboard('send text to remote clipboard');
  14. //r.requestUpdate(false, 0, 0, r.width, r.height); // incremental?, x, y, w, h
  15. });
  16.  
  17. // screen updates
  18. r.on('rect', function(rect) {
  19. switch(rect.encoding) {
  20. case rfb.encodings.raw:
  21. console.log('raw frame recieved');
  22. // rect.x, rect.y, rect.width, rect.height, rect.data
  23. // pixmap format is in r.bpp, r.depth, r.redMask, greenMask, blueMask, redShift, greenShift, blueShift
  24. console.log('rect.x ' + rect.x + ' rect.y ' + rect.y + ' rect.width ' + rect.width + ' rect.height ' + rect.height);
  25. r.end()
  26. break;
  27. case rfb.encodings.tight:
  28. case rfb.encodings.tightPng:
  29. console.log('tight frame recieved');
  30. console.log('rect.x ' + rect.x + ' rect.y ' + rect.y + ' rect.width ' + rect.width + ' rect.height ' + rect.height + ' rect.cmode ' + rect.cmode);
  31. // if (rect.cmode == 'png') {
  32. // var fs = require('fs');
  33. // fs.writeFile('/home/vtolstov/devel/test' + Date.now() + '.png', rect.data, function(err) {
  34. // if(err) {
  35. // return console.log(err);
  36. // }
  37. // });
  38. // }
  39. // r.end()
  40. break;
  41. case rfb.encodings.copyRect:
  42. // pseudo-rectangle
  43. // copy rectangle from rect.src.x, rect.src.y, rect.width, rect.height, to rect.x, rect.y
  44. break;
  45. case rfb.encodings.hextile:
  46. // not fully implemented
  47. //rect.on('tile', handleHextileTile); // emitted for each subtile
  48. break;
  49. }
  50. });
  51.  
  52. //r.on('clipboard', function(newPasteBufData) {
  53. // console.log('remote clipboard updated!', newPasteBufData);
  54. //});
  55. //r.on('bell', console.log.bind(null, 'Bell!!'));
  56. // force update
  57. // // updates are requested automatically after each new received update
  58. // // you may want to have more frequent updates for high latency / high bandwith connection
  59. //r.requestUpdate(false, 0, 0, r.width, r.height); // incremental?, x, y, w, h
  60. //
  61. //r.end(); // close connection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement