module Pokan::ServerMessages

Public Instance Methods

digest_message() click to toggle source

Gets a digest containing all peers’ key/timestamp of all peers It returns a json with all the pairs for each peer in a Digest Structure

# File lib/pokan/server_messages.rb, line 19
def digest_message
  data= Hash.new
  peers = Query.new(Peer).where(role:['peer','seed'], status:'alive')
  peers.each { |peer| data[peer.id] = peer.digest }

  { action: 'digest', data: data, origin:"#{address}:#{port}" }.to_json
end
goodbye_message() click to toggle source

Gets the message that the peer needs to send when is going to stop participating of the group

# File lib/pokan/server_messages.rb, line 12
def goodbye_message
  { action: 'goodbye', origin:"#{address}:#{port}" }.to_json
end
hello_message() click to toggle source

Gets a message for the introduction of the new peer to the seed

# File lib/pokan/server_messages.rb, line 6
def hello_message
  { action: 'hello', origin:"#{address}:#{port}" }.to_json
end