Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::LookupSession Class Reference

#include <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 LookupSocketsocket
 
Bonjour::ReplyFn replyfn
 

Detailed Description

Constructor & Destructor Documentation

◆ LookupSession()

Slic3r::LookupSession::LookupSession ( const LookupSocket sckt,
Bonjour::ReplyFn  rfn 
)
inline
129: UdpSession(rfn), socket(sckt) {}
const LookupSocket * socket
Definition Bonjour.hpp:133
UdpSession(Bonjour::ReplyFn rfn)
Definition Bonjour.cpp:618

Member Function Documentation

◆ handle_receive()

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

Implements Slic3r::UdpSession.

725{
726 assert(socket);
727
728 if (error) {
729 BOOST_LOG_TRIVIAL(error) << error.message();
730 return;
731 }
732 if (bytes == 0 || !replyfn) {
733 return;
734 }
735
736 buffer.resize(bytes);
737 auto dns_msg = DnsMessage::decode(buffer, socket->get_txt_keys());
738 if (dns_msg) {
739 asio::ip::address ip = remote_endpoint.address();
740 if (dns_msg->rr_a) { ip = dns_msg->rr_a->ip; }
741 else if (dns_msg->rr_aaaa) { ip = dns_msg->rr_aaaa->ip; }
742
743 for (auto& sdpair : dns_msg->sdmap) {
744 if (!sdpair.second.srv) {
745 continue;
746 }
747
748 const auto& srv = *sdpair.second.srv;
749
750 auto service_name = strip_service_dn(sdpair.first, socket->get_service_dn());
751 if (service_name.empty())
752 continue;
753
754 std::string path;
755 std::string version;
756
757 BonjourReply::TxtData txt_data;
758 if (sdpair.second.txt) {
759 txt_data = std::move(sdpair.second.txt->data);
760 }
761
762 BonjourReply reply(ip, srv.port, std::move(service_name), srv.hostname, std::move(txt_data));
763 replyfn(std::move(reply));
764 }
765 }
766}
const Bonjour::TxtKeys get_txt_keys() const
Definition Bonjour.hpp:213
const std::string get_service_dn() const
Definition Bonjour.hpp:215
boost::asio::ip::udp::endpoint remote_endpoint
Definition Bonjour.hpp:120
std::vector< char > buffer
Definition Bonjour.hpp:119
Bonjour::ReplyFn replyfn
Definition Bonjour.hpp:122
char * version
Definition main.c:59
std::string strip_service_dn(const std::string &service_name, const std::string &service_dn)
Definition Bonjour.cpp:603
std::unordered_map< std::string, std::string > TxtData
Definition Bonjour.hpp:23
static optional< DnsMessage > decode(const std::vector< char > &buffer, const Bonjour::TxtKeys &txt_keys)
Definition Bonjour.cpp:406
static char error[256]
Definition tga.cpp:50

References Slic3r::UdpSession::buffer, Slic3r::DnsMessage::decode(), error, Slic3r::LookupSocket::get_service_dn(), Slic3r::LookupSocket::get_txt_keys(), Slic3r::UdpSession::remote_endpoint, Slic3r::UdpSession::replyfn, socket, and version.

+ 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 handle_receive().


The documentation for this class was generated from the following files: