Class: Meshchat::Network::Message::Ping

Inherits:
Base
  • Object
show all
Defined in:
lib/meshchat/network/message/ping.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, #encrypt_for, #initialize, #message, #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

#displayObject



6
7
8
9
10
11
12
13
14
# File 'lib/meshchat/network/message/ping.rb', line 6

def display
  # we'll never display our own ping to someone else...
  # or shouldn't.... or there should be different output
  # TODO: display is a bad method name
  name = payload['sender']['alias']
  location = payload['sender']['location']

  "#{name}@#{location} pinged you."
end

#handleObject



16
17
18
19
# File 'lib/meshchat/network/message/ping.rb', line 16

def handle
  respond
  display
end

#respondObject



21
22
23
24
25
26
27
# File 'lib/meshchat/network/message/ping.rb', line 21

def respond
  reply = _message_factory.create(PING_REPLY)
  _message_dispatcher.send_message(
    uid: payload['sender']['uid'],
    message: reply
  )
end