Class: Client

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

Overview

module Vesta

Class Method Summary collapse

Class Method Details

.communicate(host, port, peers) ⇒ Object

Communicating



11
12
13
14
15
16
17
# File 'lib/vesta/client.rb', line 11

def self.communicate(host, port, peers)
    begin
        Faraday.post("#{host}:#{port}/communicate", peers: peers).body
    rescue Faraday::ConnectionFailed => e
        raise
    end
end

.get_public_key(host, port) ⇒ Object

Getting public key from connected peer



20
21
22
# File 'lib/vesta/client.rb', line 20

def self.get_public_key(host,port)
    Faraday.post("#{host}:#{port}/get_pubkey").body
end

.send_message(host, port, from, message) ⇒ Object

Sending messages to peers



25
26
27
28
29
30
31
# File 'lib/vesta/client.rb', line 25

def self.send_message(host,port,from,message)
    begin
        Faraday.post("#{host}:#{port}/get_message", from: from, message: message).body
    rescue Faraday::ConnectionFailed => e
        raise
    end
end