void Cucs_processor::On_incoming_connection(std::string, int, Socket_address::Ptr addr, Io_stream::Ref stream) { if (stream->Get_type() != Io_stream::Type::TCP) { // support only TCP connections. stream->Close(); return; } auto new_id = Get_next_id(); Server_context sc; sc.stream = stream; sc.stream_id = new_id; sc.address = addr; sc.last_message_time = std::chrono::steady_clock::now(); Schedule_next_read(sc); ucs_connections.emplace(sc.stream_id, std::move(sc)); ugcs::vsm::proto::Vsm_message msg; auto p = msg.mutable_register_peer(); p->set_peer_id(Get_application_instance_id()); p->set_peer_type(proto::PEER_TYPE_VSM); // Get the VSM name which must be defined using DEFINE_DEFAULT_VSM_NAME in VSM sources. p->set_name(Get_vsm_name()); p->set_version_major(SDK_VERSION_MAJOR); p->set_version_minor(SDK_VERSION_MINOR); p->set_version_build(SDK_VERSION_BUILD); msg.set_device_id(0); Send_ucs_message(new_id, msg); }
void Ucs_vehicle_ctx::Write_to_ucs_timed_out( const Operation_waiter::Ptr& waiter, Ugcs_mavlink_stream::Weak_ptr mav_stream) { auto locked = mav_stream.lock(); Io_stream::Ref stream = locked ? locked->Get_stream() : nullptr; std::string server_info = stream ? stream->Get_name() : "already disconnected"; LOG_DEBUG("Write timeout towards UCS server at [%s] detected from vehicle context.", server_info.c_str()); waiter->Abort(); if (stream) { stream->Close(); } }