Class: Meshchat::Network::Incoming::RequestProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/meshchat/network/incoming/request_processor.rb

Overview

all this does is pull the encrypted message out of the received request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(network: NETWORK_LOCAL, message_dispatcher: nil, location: nil) ⇒ RequestProcessor

Returns a new instance of RequestProcessor.



10
11
12
13
14
15
16
# File 'lib/meshchat/network/incoming/request_processor.rb', line 10

def initialize(network: NETWORK_LOCAL, message_dispatcher: nil, location: nil)
  @_message_processor = MessageProcessor.new(
    network: network,
    message_dispatcher: message_dispatcher,
    location: location
  )
end

Instance Attribute Details

#_message_processorObject (readonly)

Returns the value of attribute _message_processor.



8
9
10
# File 'lib/meshchat/network/incoming/request_processor.rb', line 8

def _message_processor
  @_message_processor
end

Instance Method Details

#parse_content(content) ⇒ Object



24
25
26
27
# File 'lib/meshchat/network/incoming/request_processor.rb', line 24

def parse_content(content)
  content = JSON.parse(content) if content.is_a?(String)
  content['message']
end

#process(request_body) ⇒ Object

Parameters:

  • request_body (String)
    • the encrypted message as a json string



19
20
21
22
# File 'lib/meshchat/network/incoming/request_processor.rb', line 19

def process(request_body)
  encoded_message = parse_content(request_body)
  _message_processor.process(encoded_message)
end