Module: MeshChat::Net::Listener::RequestProcessor
- Defined in:
- lib/meshchat/net/listener/request_processor.rb
Class Method Summary collapse
Class Method Details
.process(raw) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/meshchat/net/listener/request_processor.rb', line 8 def process(raw) request = Request.new(raw) = request. update_sender_info(request.json) Display. end |
.update_sender_info(json) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/meshchat/net/listener/request_processor.rb', line 17 def update_sender_info(json) sender = json['sender'] # if the sender isn't currently marked as active, # perform the server list exchange node = Node.find_by_uid(sender['uid']) if node.nil? return Display.alert "#{sender['alias']} is not authorized!" end unless node.online? node.update(online: true) payload = Message::NodeListHash.new Client.send( location: sender['location'], message: payload) end # update the node's location/alias # as they can change this info willy nilly node.update( location: sender['location'], alias_name: sender['alias'] ) end |