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.



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

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.



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

def error
  @error
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  @error != false
end

#joinObject



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

def join
  stop
  thread.join
end

#resize(width, height) ⇒ Object



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

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

#startObject



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

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

#stopObject



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

def stop
  @stop = true
end

#stop?Boolean

Returns:

  • (Boolean)


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

def stop?
  @stop
end

#write(data) ⇒ Object



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

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