-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
AutoDiscovery.cpp
71 lines (53 loc) · 1.26 KB
/
AutoDiscovery.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* AutoDiscovery.cpp
* cefix_alterable
*
* Created by Stephan Huber on 10.09.11.
* Copyright 2011 Digital Mind. All rights reserved.
*
*/
#include "AutoDiscovery.h"
#ifdef __APPLE__
#include "AutoDiscoveryBonjourImpl.h"
#else
#include "AutoDiscoveryWinImpl.h"
#endif
DiscoveredServicesCallback::DiscoveredServicesCallback()
: osg::Referenced()
{
}
AutoDiscovery::~AutoDiscovery()
{
if (_clientImpl) {
delete _clientImpl;
_clientImpl = NULL;
}
deregisterServices();
}
void AutoDiscovery::registerService(const std::string& type, unsigned int port)
{
deregisterServices();
_serverImpl = new AutoDiscoveryServerImpl(type, port);
}
void AutoDiscovery::deregisterServices()
{
if (_serverImpl) {
delete _serverImpl;
_serverImpl = NULL;
}
}
void AutoDiscovery::update()
{
if (_serverImpl)
_serverImpl->update();
if (_clientImpl)
_clientImpl->update();
}
void AutoDiscovery::discoverServices(const std::string& type, DiscoveredServicesCallback* cb)
{
_clientImpl = new AutoDiscoveryClientImpl(type, cb);
}
bool AutoDiscovery::needsContinuousUpdate() const
{
return (((_clientImpl) && _clientImpl->needsTimer()) || ((_serverImpl) && _serverImpl->needsTimer()));
}