kaspergrubbe / ruby-vnc

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

Fetching Remote Screen #27

Closed evilcap closed 5 years ago

evilcap commented 5 years ago

Hello, can u explain, how can im use u'r lib 2 fetch remote screen in realtime?

lobin-z0x50 commented 5 years ago

You can take a screenshort of sreen using this, but not supported fetch screen in real time. I recommend using vncrec. https://github.com/d-theus/vncrec-ruby

evilcap commented 5 years ago

You can take a screenshort of sreen using this, but not supported fetch screen in real time. I recommend using vncrec. https://github.com/d-theus/vncrec-ruby

I just want 2 build my own HTML5 viewer for VNC session, so would you recommend me just to create a Thread, which use take_screenshot method and retranslate it to actioncable? Or what? Thx.

lobin-z0x50 commented 5 years ago

it's like the noVNC ? https://github.com/novnc/noVNC

If you use the take_screenshot method and transfer using actioncable, it will be inefficient because I think it will transfer data regardless of whether the screen has been updated or not. In order to transfer data only when the screen is updated, it may be necessary to process with type == 0 in the read_packet method.

As below.

    def read_packet type
      case type
      when 0 # ----------------------------------------------- FramebufferUpdate
        @fb.handle_response type if @fb

        #
        # notify to the thread to send screen data to client.
        #

      when 1 # --------------------------------------------- SetColourMapEntries
        @fb.handle_response type if @fb
      when 2 # ------------------------------------------------------------ Bell
        nil  # not support
      when 3 # --------------------------------------------------- ServerCutText
        socket.read 3 # discard padding bytes
        len = socket.read(4).unpack('N')[0]
        @mutex.synchronize { @clipboard = socket.read len }
      else
        warn 'unhandled server packet type - %d' % type
      end
    end
evilcap commented 5 years ago

So i decided, that Websocket it is a bad idea for sending and recieving such kind of data and i migrated to WebRTC