Class: Conreality::Client
- Inherits:
-
Object
- Object
- Conreality::Client
- Defined in:
- lib/conreality/client.rb
Overview
Client for accessing a Conreality master server.
Instance Attribute Summary collapse
-
#rpc_public ⇒ Object
readonly
Returns the value of attribute rpc_public.
-
#rpc_session ⇒ Object
readonly
Returns the value of attribute rpc_session.
Connection management collapse
-
#connect ⇒ Client
Connects to the server.
-
#disconnect! ⇒ void
Disconnects from the server.
Public interface collapse
-
#authenticate(agent_uuid, secret = nil) ⇒ Session
Invokes the public ‘Authenticate` method on the server.
-
#bye ⇒ void
Invokes the public ‘Bye` method on the server.
-
#hello ⇒ Hash
Invokes the public ‘Hello` method on the server.
-
#ping ⇒ void
Invokes the public ‘Ping` method on the server.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(master_host) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Returns a developer-friendly representation of this client.
Constructor Details
#initialize(master_host) ⇒ Client
Returns a new instance of Client.
24 25 26 27 28 29 |
# 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 |
Instance Attribute Details
#rpc_public ⇒ Object (readonly)
Returns the value of attribute rpc_public.
13 14 15 |
# File 'lib/conreality/client.rb', line 13 def rpc_public @rpc_public end |
#rpc_session ⇒ Object (readonly)
Returns the value of attribute rpc_session.
14 15 16 |
# File 'lib/conreality/client.rb', line 14 def rpc_session @rpc_session end |
Class Method Details
.connect(master_host, *args) ⇒ Object
18 19 20 |
# File 'lib/conreality/client.rb', line 18 def self.connect(master_host, *args) self.new(master_host, *args).connect end |
Instance Method Details
#authenticate(agent_uuid, secret = nil) ⇒ Session
Invokes the public ‘Authenticate` method on the server.
67 68 69 |
# File 'lib/conreality/client.rb', line 67 def authenticate(agent_uuid, secret = nil) Session.new(self, 1) # TODO end |
#bye ⇒ void
This method returns an undefined value.
Invokes the public ‘Bye` method on the server.
75 76 77 |
# File 'lib/conreality/client.rb', line 75 def bye @rpc_public.bye(RPC::EmptyRequest.new) end |
#connect ⇒ Client
Connects to the server.
45 46 47 |
# File 'lib/conreality/client.rb', line 45 def connect self end |
#disconnect! ⇒ void
This method returns an undefined value.
Disconnects from the server.
53 54 55 |
# File 'lib/conreality/client.rb', line 53 def disconnect! @channel = @rpc_public = @rpc_session = nil end |
#hello ⇒ Hash
Invokes the public ‘Hello` method on the server.
83 84 85 |
# 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 ⇒ String
Returns a developer-friendly representation of this client.
35 36 37 |
# File 'lib/conreality/client.rb', line 35 def inspect sprintf("#<%s:%#0x>", self.class.name, self.__id__) end |
#ping ⇒ void
This method returns an undefined value.
Invokes the public ‘Ping` method on the server.
91 92 93 |
# File 'lib/conreality/client.rb', line 91 def ping @rpc_public.ping(RPC::PingRequest.new) end |