OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::LookupSession Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.hpp>

Inheritance diagram for Slic3r::LookupSession:
Collaboration diagram for Slic3r::LookupSession:

Public Member Functions

 LookupSession (const LookupSocket *sckt, Bonjour::ReplyFn rfn)
void handle_receive (const boost::system::error_code &error, size_t bytes) override

Public Attributes

std::vector< char > buffer
boost::asio::ip::udp::endpoint remote_endpoint

Protected Attributes

const LookupSocket * socket
Bonjour::ReplyFn replyfn

Detailed Description

Constructor & Destructor Documentation

◆ LookupSession()

Slic3r::LookupSession::LookupSession ( const LookupSocket * sckt,
Bonjour::ReplyFn rfn )
inline
143: UdpSession(rfn), socket(sckt) {}
const LookupSocket * socket
Definition Bonjour.hpp:147
UdpSession(Bonjour::ReplyFn rfn)
Definition Bonjour.cpp:640

References Slic3r::UdpSession::UdpSession(), and socket.

Here is the call graph for this function:

Member Function Documentation

◆ handle_receive()

void Slic3r::LookupSession::handle_receive ( const boost::system::error_code & error,
size_t bytes )
overridevirtual

Implements Slic3r::UdpSession.

747{
748 assert(socket);
749
750 if (error) {
751 BOOST_LOG_TRIVIAL(error) << error.message();
752 return;
753 }
754 if (bytes == 0 || !replyfn) {
755 return;
756 }
757
758 buffer.resize(bytes);
759 auto dns_msg = DnsMessage::decode(buffer, socket->get_txt_keys());
760 if (dns_msg) {
761 asio::ip::address ip = remote_endpoint.address();
762 if (dns_msg->rr_a) { ip = dns_msg->rr_a->ip; }
763 else if (dns_msg->rr_aaaa) { ip = dns_msg->rr_aaaa->ip; }
764
765 for (auto& sdpair : dns_msg->sdmap) {
766 if (!sdpair.second.srv) {
767 continue;
768 }
769
770 const auto& srv = *sdpair.second.srv;
771
772 auto service_name = strip_service_dn(sdpair.first, socket->get_service_dn());
773 if (service_name.empty())
774 continue;
775
776 std::string path;
777 std::string version;
778
779 BonjourReply::TxtData txt_data;
780 if (sdpair.second.txt) {
781 txt_data = std::move(sdpair.second.txt->data);
782 }
783
784 BonjourReply reply(ip, srv.port, std::move(service_name), srv.hostname, std::move(txt_data));
785 replyfn(std::move(reply));
786 }
787 }
788}
boost::asio::ip::udp::endpoint remote_endpoint
Definition Bonjour.hpp:134
std::vector< char > buffer
Definition Bonjour.hpp:133
Bonjour::ReplyFn replyfn
Definition Bonjour.hpp:136
std::string strip_service_dn(const std::string &service_name, const std::string &service_dn)
Definition Bonjour.cpp:625
std::unordered_map< std::string, std::string > TxtData
Definition Bonjour.hpp:36
static optional< DnsMessage > decode(const std::vector< char > &buffer, const Bonjour::TxtKeys &txt_keys)
Definition Bonjour.cpp:428

References Slic3r::UdpSession::buffer, Slic3r::DnsMessage::decode(), Slic3r::UdpSession::remote_endpoint, Slic3r::UdpSession::replyfn, and socket.

Here is the call graph for this function:

Member Data Documentation

◆ buffer

std::vector<char> Slic3r::UdpSession::buffer
inherited

◆ remote_endpoint

boost::asio::ip::udp::endpoint Slic3r::UdpSession::remote_endpoint
inherited

◆ replyfn

Bonjour::ReplyFn Slic3r::UdpSession::replyfn
protectedinherited

◆ socket

const LookupSocket* Slic3r::LookupSession::socket
protected

Referenced by LookupSession(), and handle_receive().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Bonjour.cpp