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 16 17 |
# File 'lib/meshchat/net/listener/request_processor.rb', line 8 def process(raw) request = Request.new(raw) = request. # handle the message Display. # then update the sender info in the db update_sender_info(request.json) end |
.update_sender_info(json) ⇒ Object
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 19 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']) raise Errors::Forbidden.new if node.nil? 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 |