Module: Pokan::ServerMessages
- Included in:
- Server
- Defined in:
- lib/pokan/server_messages.rb
Instance Method Summary collapse
-
#digest_message ⇒ Object
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.
-
#goodbye_message ⇒ Object
Gets the message that the peer needs to send when is going to stop participating of the group.
-
#hello_message ⇒ Object
Gets a message for the introduction of the new peer to the seed.
Instance Method Details
#digest_message ⇒ Object
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
19 20 21 22 23 24 25 |
# File 'lib/pokan/server_messages.rb', line 19 def 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 ⇒ Object
Gets the message that the peer needs to send when is going to stop participating of the group
12 13 14 |
# File 'lib/pokan/server_messages.rb', line 12 def { action: 'goodbye', origin:"#{address}:#{port}" }.to_json end |
#hello_message ⇒ Object
Gets a message for the introduction of the new peer to the seed
6 7 8 |
# File 'lib/pokan/server_messages.rb', line 6 def { action: 'hello', origin:"#{address}:#{port}" }.to_json end |