Module: Roby::Interface::V2

Extended by:
Logger::Hierarchy
Defined in:
lib/roby/interface/v2.rb,
lib/roby/interface/v2/tcp.rb,
lib/roby/interface/v2/async.rb,
lib/roby/interface/v2/client.rb,
lib/roby/interface/v2/server.rb,
lib/roby/interface/v2/channel.rb,
lib/roby/interface/v2/protocol.rb,
lib/roby/interface/v2/async/log.rb,
lib/roby/interface/v2/shell_client.rb,
lib/roby/interface/v2/async/interface.rb,
lib/roby/interface/v2/shell_subcommand.rb,
lib/roby/interface/v2/async/job_monitor.rb,
lib/roby/interface/v2/subcommand_client.rb,
lib/roby/interface/v2/async/ui_connector.rb,
lib/roby/interface/v2/async/action_monitor.rb,
lib/roby/interface/v2/async/new_job_listener.rb

Overview

V2 of the remote Roby control protocol

Defined Under Namespace

Modules: Async, Protocol Classes: Channel, Client, Server, ShellClient, ShellSubcommand, SubcommandClient, TCPServer

Class Method Summary collapse

Class Method Details

.connect_with_tcp_to(host, port = DEFAULT_PORT_V2, handshake: %i[actions commands])) ⇒ Client

Connect to a Roby controller interface at this host and port

Parameters:

Returns:



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/roby/interface/v2/tcp.rb', line 177

def self.connect_with_tcp_to(host, port = DEFAULT_PORT_V2,
        handshake: %i[actions commands])
    require "socket"
    socket = TCPSocket.new(host, port)
    addr = socket.addr(true)
    channel = Channel.new(socket, true)
    Protocol.setup_channel(channel)
    Client.new(channel, "#{addr[2]}:#{addr[1]}", handshake: handshake)
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Errno::ETIMEDOUT,
       Errno::EHOSTUNREACH, Errno::ENETUNREACH, Client::TimeoutError => e
    raise ConnectionError,
          "failed to connect to #{host}:#{port}: #{e.message}",
          e.backtrace
rescue SocketError => e
    raise e, "cannot connect to host '#{host}' port '#{port}': #{e.message}",
          e.backtrace
rescue ::Exception # rubocop:disable Lint/RescueException
    socket.close if socket && !socket.closed?
    raise
end