def handle_message(msg, connection = {})
    intermediate = Messages::Intermediate.parse(msg)

    if Messages::Request.is_request_message?(intermediate)
      tp << ThreadPoolJob.new(intermediate) { |i|
              handle_request(i, false, connection)
            }

    elsif Messages::Notification.is_notification_message?(intermediate)
      tp << ThreadPoolJob.new(intermediate) { |i|
              handle_request(i, true, connection)
            }

    elsif Messages::Response.is_response_message?(intermediate)
      handle_response(intermediate)

    end

    intermediate
  end
def handle_message(msg, connection = {})
    intermediate = Messages::Intermediate.parse(msg)

    if Messages::Request.is_request_message?(intermediate)
      tp << ThreadPoolJob.new(intermediate) { |i|
              handle_request(i, false, connection)
            }

    elsif Messages::Notification.is_notification_message?(intermediate)
      tp << ThreadPoolJob.new(intermediate) { |i|
              handle_request(i, true, connection)
            }

    elsif Messages::Response.is_response_message?(intermediate)
      handle_response(intermediate)

    end

    intermediate
  end
Internal helper, handle message received