forked from coronalabs/corona
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRtt_PlatformReachability.h
99 lines (69 loc) · 2.51 KB
/
Rtt_PlatformReachability.h
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//////////////////////////////////////////////////////////////////////////////
//
// This file is part of the Corona game engine.
// For overview and more information on licensing please refer to README.md
// Home page: https://github.com/coronalabs/corona
// Contact: [email protected]
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _Rtt_PlatformReachability_H__
#define _Rtt_PlatformReachability_H__
#include "Core/Rtt_Build.h"
#include "Core/Rtt_ResourceHandle.h"
#include "Rtt_PlatformNotifier.h"
#include "Rtt_Event.h"
// ----------------------------------------------------------------------------
struct lua_State;
namespace Rtt
{
class Runtime;
// ----------------------------------------------------------------------------
class PlatformReachability
{
public:
enum PlatformReachabilityType
{
kReachabilityTypeUndefined = 0,
kHostName,
kAddress,
kInternet,
kLocalWiFi,
kNumReachabilityTypes
};
static const char kReachabilityListenerEvent[];
explicit PlatformReachability( const ResourceHandle<lua_State> & handle, PlatformReachabilityType type, const char* address );
virtual ~PlatformReachability();
// Intended for internal use to decide if the constructor failed since we don't do exception handling.
virtual bool IsValid() const;
virtual bool IsReachable() const;
virtual bool IsConnectionRequired() const;
virtual bool IsConnectionOnDemand() const;
virtual bool IsInteractionRequired() const;
virtual bool IsReachableViaCellular() const;
virtual bool IsReachableViaWiFi() const;
protected:
ResourceHandle<lua_State> fLuaState;
};
// ----------------------------------------------------------------------------
class ReachabilityChangeEvent : public VirtualEvent
{
public:
typedef VirtualEvent Super;
typedef ReachabilityChangeEvent Self;
public:
static const char kName[];
public:
ReachabilityChangeEvent( const PlatformReachability& reachability, const char *address );
// virtual ~ReachabilityChangeEvent();
public:
virtual const char* Name() const;
virtual int Push( lua_State *L ) const;
virtual void Dispatch( lua_State *L, Runtime& runtime ) const;
protected:
const PlatformReachability& fNetworkReachability;
const char *fAddress; // Does not own this.
};
// ----------------------------------------------------------------------------
} // namespace Rtt
// ----------------------------------------------------------------------------
#endif // _Rtt_PlatformReachability_H__