class Conreality::Client

Client for accessing a Conreality master server.

Attributes

rpc_public[R]
rpc_session[R]

Public Class Methods

connect(master_host, *args) click to toggle source

@param master_host [String]

# File lib/conreality/client.rb, line 18
def self.connect(master_host, *args)
  self.new(master_host, *args).connect
end
new(master_host) click to toggle source

@param master_host [String]

# File lib/conreality/client.rb, line 24
def initialize(master_host)
  channel_creds = :this_channel_is_insecure
  @channel      = RPC::Session::Stub.setup_channel(nil, master_host, channel_creds)
  @rpc_public   = RPC::Public::Stub.new(master_host, channel_creds, channel_override: @channel)
  @rpc_session  = RPC::Session::Stub.new(master_host, channel_creds, channel_override: @channel)
end

Public Instance Methods

authenticate(agent_uuid, secret = nil) click to toggle source

Invokes the public `Authenticate` method on the server.

@param agent_uuid [String] @param secret [String] @return [Session]

# File lib/conreality/client.rb, line 67
def authenticate(agent_uuid, secret = nil)
  Session.new(self, 1) # TODO
end
bye() click to toggle source

Invokes the public `Bye` method on the server.

@return [void]

# File lib/conreality/client.rb, line 75
def bye
  @rpc_public.bye(RPC::EmptyRequest.new)
end
connect() click to toggle source

Connects to the server.

@return [Client] `self`

# File lib/conreality/client.rb, line 45
def connect
  self
end
disconnect!() click to toggle source

Disconnects from the server.

@return [void]

# File lib/conreality/client.rb, line 53
def disconnect!
  @channel = @rpc_public = @rpc_session = nil
end
hello() click to toggle source

Invokes the public `Hello` method on the server.

@return [Hash]

# File lib/conreality/client.rb, line 83
def hello
  {version: @rpc_public.hello(RPC::HelloRequest.new(version: Conreality::VERSION.to_s)).version}.freeze
end
inspect() click to toggle source

Returns a developer-friendly representation of this client.

@return [String]

# File lib/conreality/client.rb, line 35
def inspect
  sprintf("#<%s:%#0x>", self.class.name, self.__id__)
end
ping() click to toggle source

Invokes the public `Ping` method on the server.

@return [void]

# File lib/conreality/client.rb, line 91
def ping
  @rpc_public.ping(RPC::PingRequest.new)
end