Class: VncClient
- Inherits:
-
Object
- Object
- VncClient
- Defined in:
- lib/network-projector/vnc/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/network-projector/vnc/client.rb', line 7 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/network-projector/vnc/client.rb', line 7 def port @port end |
Instance Method Details
#join ⇒ Object
37 38 39 40 41 |
# File 'lib/network-projector/vnc/client.rb', line 37 def join @passwdfile.unlink if @passwdfile @thread.join if @thread @thread = nil end |
#run(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/network-projector/vnc/client.rb', line 9 def run = {} @host = ([:host]) @port = ([:port]) @passwd = ([:passwd]) raise "need a host to contact" unless @host raise "need a port to contact" unless @port @passwdfile = Tempfile.new("vnc") `echo #{@passwd.shellescape} | vncpasswd -f > #{@passwdfile.path}` pin, pout, @thread = Open3.popen2e("vncviewer -passwd #{@passwdfile.path} #{@host.shellescape}:#{@port.shellescape} -fullscreen") end |
#started? ⇒ Boolean
22 23 24 25 |
# File 'lib/network-projector/vnc/client.rb', line 22 def started? join unless (@thread.nil? or @thread.alive?) @thread.nil? == false end |
#stop ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/network-projector/vnc/client.rb', line 27 def stop if @thread then begin Process.kill("TERM", @thread.pid) rescue Errno::ESRCH end end join end |