Class: Meshchat::Network::Message::NodeListHash

Inherits:
Base
  • Object
show all
Defined in:
lib/meshchat/network/message/node_list_hash.rb

Instance Attribute Summary

Attributes inherited from Base

#_message, #_message_dispatcher, #_message_factory, #_sender_location, #_sender_name, #_sender_uid, #_time_received, #payload

Instance Method Summary collapse

Methods inherited from Base

#client, #client_version, #display, #encrypt_for, #initialize, #render, #sender, #sender_location, #sender_name, #sender_uid, #time_received, #time_received_as_date, #type

Constructor Details

This class inherits a constructor from Meshchat::Network::Message::Base

Instance Method Details

#handleNilClass

node list hash is received

Returns:

  • (NilClass)

    no output for this message type



12
13
14
15
# File 'lib/meshchat/network/message/node_list_hash.rb', line 12

def handle
  respond
  nil
end

#messageObject



6
7
8
# File 'lib/meshchat/network/message/node_list_hash.rb', line 6

def message
  @_message ||= Node.as_sha512
end

#respondObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/meshchat/network/message/node_list_hash.rb', line 17

def respond
  if message != Node.as_sha512
    Display.debug 'node list hashes do not match'

    node_list = _message_factory.create(
      NODE_LIST,
      data: { message: Node.as_json }
    )

    _message_dispatcher.send_message(
      uid: payload['sender']['uid'],
      message: node_list
    )
  else
    Display.debug 'node list hash matches'
  end
end