class Meshchat::Network::Local::Server
This is created every request
Constants
- BAD_REQUEST
- FORBIDDEN
- NOT_AUTHORIZED
- OK
- SERVER_ERROR
Attributes
_message_dispatcher[R]
_request_processor[R]
Public Class Methods
new(message_dispatcher)
click to toggle source
# File lib/meshchat/network/local/server.rb, line 18 def initialize(message_dispatcher) @_message_dispatcher = message_dispatcher @_request_processor = Incoming::RequestProcessor.new( network: NETWORK_LOCAL, message_dispatcher: message_dispatcher ) end
Public Instance Methods
build_response(s = OK, message = '')
click to toggle source
# File lib/meshchat/network/local/server.rb, line 60 def build_response(s = OK, message = '') response = EM::DelegatedHttpResponse.new(self) response.status = s response.content_type 'text/json' response.content = message response.send_response end
process(raw)
click to toggle source
# File lib/meshchat/network/local/server.rb, line 45 def process(raw) # decode, etc _request_processor.process(raw) rescue Errors::NotAuthorized build_response NOT_AUTHORIZED rescue Errors::Forbidden build_response FORBIDDEN rescue Errors::BadRequest build_response BAD_REQUEST rescue => e Display.error e.message Display.error e.backtrace.join("\n") build_response SERVER_ERROR, e.message end
process_http_request()
click to toggle source
# File lib/meshchat/network/local/server.rb, line 26 def process_http_request # the http request details are available via the following instance variables: # @http_protocol # @http_request_method # @http_cookie # @http_if_none_match # @http_content_type # @http_path_info # @http_request_uri # @http_query_string # @http_post_content # @http_headers # view what instance variables are available thorugh the # instance_variables method process(@http_post_content) build_response end