kaspergrubbe / ruby-vnc

A library for interaction automation of servers via VNC
MIT License
31 stars 17 forks source link

support reading desktop name of connected server #25

Closed lobin-z0x50 closed 5 years ago

lobin-z0x50 commented 5 years ago

sample code:

require 'net/vnc'

Net::VNC.open '192.168.1.159:0', :shared => true, :password => '12345' do |vnc|
  puts "connected to '#{vnc.desktop_name}' !!"
end

result (Ultra VNC Server):

Nagisa:ruby-vnc lobin$ ruby example.rb
connected to 'desktop-ccsh66e ( 192.168.56.1, 192.168.1.159 ) - application mode' !!
Nagisa:ruby-vnc lobin$
kaspergrubbe commented 5 years ago

I thought desktop_name is a strange name as it is oddly specific (it might not be a desktop machine we are connecting to), so to search for a better name I took a look at the VNC specification:

      +--------------+--------------+------------------------------+
      | No. of bytes | Type [Value] | Description                  |
      +--------------+--------------+------------------------------+
      | 2            | U16          | framebuffer-width in pixels  |
      | 2            | U16          | framebuffer-height in pixels |
      | 16           | PIXEL_FORMAT | server-pixel-format          |
      | 4            | U32          | name-length                  |
      | name-length  | U8 array     | name-string                  |
      +--------------+--------------+------------------------------+

So they just call it name, do you think that is a better option?

lobin-z0x50 commented 5 years ago

According to the specification of the RFB protocol, it is written as the name associated with the desktop, so I use that property name.

2019-02-03 22 12 32

I think that if it is a simple name property, it is too abstract to be confusing.

aquasync commented 5 years ago

While it is certainly ideal to be able to offload the problem of naming things to the spec, I agree name would be a bit broad for this purpose. Could use server_name, remote_name or whatever (yay bikeshedding!) but happy to go with desktop_name given the spec text.