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

#include <src/slic3r/Utils/Bonjour.hpp>

+ Inheritance diagram for Slic3r::LookupSocket:
+ Collaboration diagram for Slic3r::LookupSocket:

Public Member Functions

 LookupSocket (Bonjour::TxtKeys txt_keys, std::string service, std::string service_dn, std::string protocol, Bonjour::ReplyFn replyfn, const boost::asio::ip::address &multicast_address, const boost::asio::ip::address &interface_address, std::shared_ptr< boost::asio::io_service > io_service)
 
 LookupSocket (Bonjour::TxtKeys txt_keys, std::string service, std::string service_dn, std::string protocol, Bonjour::ReplyFn replyfn, const boost::asio::ip::address &multicast_address, std::shared_ptr< boost::asio::io_service > io_service)
 
const Bonjour::TxtKeys get_txt_keys () const
 
const std::string get_service () const
 
const std::string get_service_dn () const
 
void send ()
 
void async_receive ()
 
void cancel ()
 

Protected Member Functions

SharedSession create_session () const override
 
void create_request ()
 
void receive_handler (SharedSession session, const boost::system::error_code &error, size_t bytes)
 

Protected Attributes

boost::optional< BonjourRequestrequest
 
Bonjour::TxtKeys txt_keys
 
std::string service
 
std::string service_dn
 
std::string protocol
 
Bonjour::ReplyFn replyfn
 
boost::asio::ip::address multicast_address
 
boost::asio::ip::udp::socket socket
 
boost::asio::ip::udp::endpoint mcast_endpoint
 
std::shared_ptr< boost::asio::io_service > io_service
 
std::vector< BonjourRequestrequests
 

Detailed Description

Constructor & Destructor Documentation

◆ LookupSocket() [1/2]

Slic3r::LookupSocket::LookupSocket ( Bonjour::TxtKeys  txt_keys,
std::string  service,
std::string  service_dn,
std::string  protocol,
Bonjour::ReplyFn  replyfn,
const boost::asio::ip::address &  multicast_address,
const boost::asio::ip::address &  interface_address,
std::shared_ptr< boost::asio::io_service >  io_service 
)
inline
186 : UdpSocket(replyfn, multicast_address, interface_address, io_service)
191 {
192 assert(!service.empty() && replyfn);
194 }
std::string service_dn
Definition Bonjour.hpp:229
void create_request()
Definition Bonjour.hpp:219
Bonjour::TxtKeys txt_keys
Definition Bonjour.hpp:227
std::string service
Definition Bonjour.hpp:228
std::string protocol
Definition Bonjour.hpp:230
UdpSocket(Bonjour::ReplyFn replyfn, const boost::asio::ip::address &multicast_address, const boost::asio::ip::address &interface_address, std::shared_ptr< boost::asio::io_service > io_service)
Bonjour::ReplyFn replyfn
Definition Bonjour.hpp:167
boost::asio::ip::address multicast_address
Definition Bonjour.hpp:168
std::shared_ptr< boost::asio::io_service > io_service
Definition Bonjour.hpp:171

References create_request(), Slic3r::UdpSocket::replyfn, and service.

+ Here is the call graph for this function:

◆ LookupSocket() [2/2]

Slic3r::LookupSocket::LookupSocket ( Bonjour::TxtKeys  txt_keys,
std::string  service,
std::string  service_dn,
std::string  protocol,
Bonjour::ReplyFn  replyfn,
const boost::asio::ip::address &  multicast_address,
std::shared_ptr< boost::asio::io_service >  io_service 
)
inline
208 {
209 assert(!service.empty() && replyfn);
211 }

References create_request(), Slic3r::UdpSocket::replyfn, and service.

+ Here is the call graph for this function:

Member Function Documentation

◆ async_receive()

void Slic3r::UdpSocket::async_receive ( )
inherited
695{
696 try {
697 // our session to hold the buffer + endpoint
698 auto session = create_session();
699 socket.async_receive_from(asio::buffer(session->buffer, session->buffer.size())
700 , session->remote_endpoint
701 , boost::bind(&UdpSocket::receive_handler, this, session, asio::placeholders::error, asio::placeholders::bytes_transferred));
702 }
703 catch (std::exception& e) {
704 BOOST_LOG_TRIVIAL(error) << e.what();
705 }
706}
void receive_handler(SharedSession session, const boost::system::error_code &error, size_t bytes)
Definition Bonjour.cpp:708
boost::asio::ip::udp::socket socket
Definition Bonjour.hpp:169
virtual SharedSession create_session() const =0
static char error[256]
Definition tga.cpp:50

References Slic3r::UdpSocket::create_session(), error, Slic3r::UdpSocket::receive_handler(), and Slic3r::UdpSocket::socket.

Referenced by Slic3r::UdpSocket::receive_handler(), and Slic3r::UdpSocket::send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

void Slic3r::UdpSocket::cancel ( )
inlineinherited
162{ socket.cancel(); }

References Slic3r::UdpSocket::socket.

◆ create_request()

void Slic3r::LookupSocket::create_request ( )
inlineprotected
220 {
221 requests.clear();
222 // create PTR request
223 if (auto rqst = BonjourRequest::make_PTR(service, protocol); rqst)
224 requests.push_back(std::move(rqst.get()));
225 }
std::vector< BonjourRequest > requests
Definition Bonjour.hpp:172
static boost::optional< BonjourRequest > make_PTR(const std::string &service, const std::string &protocol)
Definition Bonjour.cpp:494

References Slic3r::BonjourRequest::make_PTR(), protocol, Slic3r::UdpSocket::requests, and service.

Referenced by LookupSocket(), and LookupSocket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_session()

SharedSession Slic3r::LookupSocket::create_session ( ) const
overrideprotectedvirtual

Implements Slic3r::UdpSocket.

719{
720 return std::shared_ptr< LookupSession >(new LookupSession(this, replyfn));
721}

References Slic3r::UdpSocket::replyfn.

◆ get_service()

const std::string Slic3r::LookupSocket::get_service ( ) const
inline
214{ return service; }

References service.

◆ get_service_dn()

const std::string Slic3r::LookupSocket::get_service_dn ( ) const
inline
215{ return service_dn; }

References service_dn.

Referenced by Slic3r::LookupSession::handle_receive().

+ Here is the caller graph for this function:

◆ get_txt_keys()

const Bonjour::TxtKeys Slic3r::LookupSocket::get_txt_keys ( ) const
inline
213{ return txt_keys; }

References txt_keys.

Referenced by Slic3r::LookupSession::handle_receive().

+ Here is the caller graph for this function:

◆ receive_handler()

void Slic3r::UdpSocket::receive_handler ( SharedSession  session,
const boost::system::error_code &  error,
size_t  bytes 
)
protectedinherited
709{
710 // let io_service to handle the datagram on session
711 // from boost documentation io_service::post:
712 // The io_service guarantees that the handler will only be called in a thread in which the run(), run_one(), poll() or poll_one() member functions is currently being invoked.
713 io_service->post(boost::bind(&UdpSession::handle_receive, session, error, bytes));
714 // immediately accept new datagrams
716}
virtual void handle_receive(const boost::system::error_code &error, size_t bytes)=0
void async_receive()
Definition Bonjour.cpp:694

References Slic3r::UdpSocket::async_receive(), error, Slic3r::UdpSession::handle_receive(), and Slic3r::UdpSocket::io_service.

Referenced by Slic3r::UdpSocket::async_receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ send()

void Slic3r::UdpSocket::send ( )
inherited
681{
682 try {
683 for (const auto& request : requests)
684 socket.send_to(asio::buffer(request.m_data), mcast_endpoint);
685
686 // Should we care if this is called while already receiving? (async_receive call from receive_handler)
688 }
689 catch (std::exception& e) {
690 BOOST_LOG_TRIVIAL(error) << e.what();
691 }
692}
boost::asio::ip::udp::endpoint mcast_endpoint
Definition Bonjour.hpp:170

References Slic3r::UdpSocket::async_receive(), error, Slic3r::UdpSocket::mcast_endpoint, Slic3r::UdpSocket::requests, and Slic3r::UdpSocket::socket.

+ Here is the call graph for this function:

Member Data Documentation

◆ io_service

std::shared_ptr< boost::asio::io_service > Slic3r::UdpSocket::io_service
protectedinherited

◆ mcast_endpoint

boost::asio::ip::udp::endpoint Slic3r::UdpSocket::mcast_endpoint
protectedinherited

Referenced by Slic3r::UdpSocket::send().

◆ multicast_address

boost::asio::ip::address Slic3r::UdpSocket::multicast_address
protectedinherited

◆ protocol

std::string Slic3r::LookupSocket::protocol
protected

Referenced by create_request().

◆ replyfn

◆ request

boost::optional<BonjourRequest> Slic3r::LookupSocket::request
protected

◆ requests

std::vector<BonjourRequest> Slic3r::UdpSocket::requests
protectedinherited

◆ service

std::string Slic3r::LookupSocket::service
protected

◆ service_dn

std::string Slic3r::LookupSocket::service_dn
protected

Referenced by get_service_dn().

◆ socket

boost::asio::ip::udp::socket Slic3r::UdpSocket::socket
protectedinherited

◆ txt_keys

Bonjour::TxtKeys Slic3r::LookupSocket::txt_keys
protected

Referenced by get_txt_keys().


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