Class: Protobuf::Rpc::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/protobuf/rpc/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/protobuf/rpc/client.rb', line 6

def initialize(host, port)
  @host, @port = host, port
end

Instance Method Details

#call(name, request, response) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/protobuf/rpc/client.rb', line 10

def call(name, request, response)
  socket = TCPSocket.open @host, @port
  socket.write "#{name}\n"
  request.serialize_to socket
  socket.close_write
  response.parse_from socket
end