sidorares / node-rfb2

rfb wire protocol client and server
MIT License
138 stars 27 forks source link

Add sections to README and document how to run server #9

Closed follower closed 9 years ago

sidorares commented 9 years ago

"rfbserver.js" right now is more an example of how would you implement server from scratch. I'd like to make it an actual useable library with api like this:

rfb.createServer(function(conn) {
   conn.on('pointerEvent', function(x, y, flags) { // ... });
   setInterval(function() {
      conn.writeUpdate({ encoding: rfb.encodings.raw, // ... });
   }, 1000);
});
sidorares commented 9 years ago

I'd probably put documentation for server api described above once it's ready

follower commented 9 years ago

Thanks for the merges of my other PRs.

Realise the server functionality is "in progress" but thought a little documentation might help for the next person like me that ends up here after finding this is the only current node.js VNC/RFB server implementation. :)

FWIW, I've updated the current example to have a quick demo of an updating display: https://github.com/follower/node-rfb2/blob/feature-update-display/rfbserver.js#L198 It only displays random coloured "static" currently but shows how it can be done.

Contemplated creating a server API but figured you would probably have plans in that direction and I don't really require much for my purposes which is essentially only producing a proof-of-concept hack. :)

Thanks for your work on this. :)

sidorares commented 9 years ago

I really don't know when I'll be able to implement server the way I want, so feel free to play with it. The direction I'd like to take: be low level (allow to drop connection at any stage, send fake/incorrect handshake etc). See implementation of mysql server for example: https://github.com/sidorares/node-mysql2#mysql-server-api - one handler for each connection, RFB specific client events and helpers on connection object to send server->client messages. I'll review current server once again but now I feel it's to limiting (only exposes "client asked for update" event and all handshake/configuration values hardcoded)