bool tcp_adapter_proxy::async_wait_for_stream_start()

in src/TcpAdapterProxy.cpp [870:930]


        bool tcp_adapter_proxy::async_wait_for_stream_start(tcp_adapter_context &tac, message const &message)
        {
            using namespace com::amazonaws::iot::securedtunneling;
            BOOST_LOG_SEV(log, trace) << "Wait for control message stream start, receive message type:" << message.type();
            std::int32_t stream_id = static_cast<std::int32_t>(message.streamid());
            string service_id = message.serviceid();
            switch (message.type())
            {
            case Message_Type_SESSION_RESET:
    #ifdef DEBUG
                BOOST_LOG_SEV(log, trace) << "Session reset recieved";
    #endif
                return true;
            case Message_Type_STREAM_RESET:
                //while waiting for stream start (destination mode implied), no TCP socket is present so these
                //messages are no-op
    #ifdef DEBUG
                BOOST_LOG_SEV(log, trace) << "Stream reset recieved";
    #endif
                return true;
            case Message_Type_STREAM_START:
    #ifdef DEBUG
                BOOST_LOG_SEV(log, debug) << "Stream start recieved";
    #endif
                stream_id = static_cast<std::int32_t>(message.streamid());
                if (!stream_id)
                {
                    throw proxy_exception("No stream ID set for stream start message!");
                }
                BOOST_LOG_SEV(log, debug) << "Received service id :" << service_id << " ,stream id: " << message.streamid();
                // v1 message format does not need to validate service id. Set to the one service id stored in memory.
                if (tac.adapter_config.is_v1_message_format)
                {
                    service_id = tac.adapter_config.serviceId_to_endpoint_map.cbegin()->first;
                }
                else if (tac.adapter_config.serviceId_to_endpoint_map.find(service_id) == tac.adapter_config.serviceId_to_endpoint_map.end())
                {
                    throw proxy_exception((boost::format("Invalid service id received for stream start: %1%") % service_id).str());
                }

                tac.serviceId_to_streamId_map[service_id] = stream_id;
                tac.serviceId_to_tcp_client_map[service_id]->on_receive_stream_start();
                return false;
            case Message_Type_DATA:    //handling the following cases alleviates clang compiler warnings
                throw std::logic_error("Data message recieved in control message handler");
            case Message_Type_SERVICE_IDS:
                // service ids should already be received at this point, no actions to process again.
                return true;
            case Message_Type_UNKNOWN:
            case Message_Type_Message_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
            case Message_Type_Message_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
                //Can only use the following when linked to full ProtocolBuffers library rather than LITE
                //throw proxy_exception((boost::format("Unexpected message type recieved during control message handling during data transfer: %1%") % External_MessageType_Name(message.messagetype())).str());
                throw proxy_exception((boost::format("Unexpected message type recieved while waiting for stream start: %1%") % message.type()).str());
            default:
                if (message.ignorable()) {
                    return true;
                }
                throw std::logic_error((boost::format("Unrecognized message type received while waiting for stream start: %1%") % message.type()).str());
            }
        }