Debian Codegraph @

src/MultiPlayer/MPServerResolver.hxx

raw symbols SCIP
1 /*
2 MPServerResolver.hxx - mpserver names lookup via DNS
3 Written and copyright by Torsten Dreyer - November 2016
4
5 This file is part of FlightGear.
6
7 FlightGear is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
11
12 FlightGear is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef __FG_MPSERVERRESOLVER_HXX
21 #define __FG_MPSERVERRESOLVER_HXX
22
23 #include <string>
24 #include <simgear/props/props.hxx>
25
26 class MPServerResolver {
27 public:
28 MPServerResolver();
29 virtual ~MPServerResolver();
30 void run();
31
32 /**
33 * Set the target property where the server-list gets stored
34 *
35 * \param value the property node to use as a target
36 */
37 void setTarget( SGPropertyNode_ptr value ) { _targetNode = value; }
38
39 /**
40 * Set the dns domain name to query. This could be either a full qualified name including the
41 * service and the protocol like _fgms._udp.flightgear.org or just the domain name like
42 * flightgear.org. Use setService() and setProtocol() in the latter case.
43 *
44 * \param value the dnsname to use for the query.
45 */
46 void setDnsName( const std::string & value ) { _dnsName = value; }
47
48 /** Set the service name to use for the query. Don't add the underscore, this gets added
49 * automatically. This builds the fully qualified DNS name to query, together with
50 * setProtocol() and setDnsName().
51 *
52 * \param value the service name to use for the query sans the leading underscore
53 */
54 void setService( const std::string & value ) { _service = value; }
55
56 /** Set the protocol name to use for the query. Don't add the underscore, this gets added
57 * automatically. This builds the fully qualified DNS name to query, together with
58 * setService() and setDnsName().
59 *
60 * \param value the protocol name to use for the query sans the leading underscore
61 */
62 void setProtocol( const std::string & value ) { _protocol = value; }
63
64 /** Handler to be called if the resolver process finishes with success. Does nothing by
65 * default and should be overridden be the user.
66 */
67 virtual void onSuccess() {};
68
69 /** Handler to be called if the resolver process terminates with an error. Does nothing by
70 * default and should be overridden be the user.
71 */
72 virtual void onFailure() {};
73
74 private:
75 class MPServerResolver_priv;
76 std::string _dnsName;
77 std::string _service;
78 std::string _protocol;
79 SGPropertyNode_ptr _targetNode;
80 MPServerResolver_priv * _priv;
81 };
82
83 #endif // __FG_MPSERVERRESOLVER_HXX