Class: VpsAdmin::CLI::Commands::VpsRemoteControl::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vpsadmin/cli/commands/vps_remote_console.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vps, token, rate) ⇒ HttpClient

Returns a new instance of HttpClient.



89
90
91
92
93
94
95
96
97
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 89

def initialize(vps, token, rate)
  @vps = vps
  @token = token
  @rate = rate
  @mutex = Mutex.new
  @write_buffer = ''
  @stop = false
  @error = false
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



115
116
117
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 115

def error
  @error
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 111

def error?
  @error != false
end

#joinObject



117
118
119
120
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 117

def join
  stop
  thread.join
end

#resize(width, height) ⇒ Object



128
129
130
131
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 128

def resize(width, height)
  @width = width
  @height = height
end

#startObject



99
100
101
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 99

def start
  @thread = Thread.new { run }
end

#stopObject



103
104
105
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 103

def stop
  @stop = true
end

#stop?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 107

def stop?
  @stop
end

#write(data) ⇒ Object



122
123
124
125
126
# File 'lib/vpsadmin/cli/commands/vps_remote_console.rb', line 122

def write(data)
  mutex.synchronize do
    write_buffer << data
  end
end