LeviLamina
Loading...
Searching...
No Matches
NetherNetConnector.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/nether_net/ESendType.h"
7#include "mc/deps/nether_net/ESessionError.h"
8#include "mc/deps/nether_net/INetherNetTransportInterfaceCallbacks.h"
9#include "mc/deps/nether_net/NetworkID.h"
10#include "mc/network/Connector.h"
11#include "mc/network/RemoteConnector.h"
12#include "mc/network/TransportLayer.h"
13#include "mc/platform/threading/Mutex.h"
14#include "mc/platform/threading/UniqueLock.h"
15
16// auto generated forward declare list
17// clang-format off
22namespace Bedrock::Http { class LibHttpClientInstance; }
23namespace Bedrock::PubSub { class Subscription; }
24namespace Json { class Value; }
25namespace NetherNet { class INetherNetTransportInterface; }
26namespace NetherNet { class ISignalingInterface; }
27namespace NetherNet { struct ILanEventHandler; }
28namespace NetherNet { struct SessionState; }
29namespace NetherNet { struct StunRelayServer; }
30namespace Social { class GameConnectionInfo; }
31// clang-format on
32
34public:
35 // NetherNetConnector inner types declare
36 // clang-format off
37 struct DisconnectEvent;
40 // clang-format on
41
42 // NetherNetConnector inner types define
43 struct DisconnectEvent {
44 public:
45 // member variables
46 // NOLINTBEGIN
51 // NOLINTEND
52
53 public:
54 // prevent constructor by default
55 DisconnectEvent& operator=(DisconnectEvent const&);
56 DisconnectEvent(DisconnectEvent const&);
57 DisconnectEvent();
58 };
59
60 struct NewIncomingConnectionEvent {
61 public:
62 // member variables
63 // NOLINTBEGIN
65 // NOLINTEND
66
67 public:
68 // prevent constructor by default
69 NewIncomingConnectionEvent& operator=(NewIncomingConnectionEvent const&);
70 NewIncomingConnectionEvent(NewIncomingConnectionEvent const&);
71 NewIncomingConnectionEvent();
72
73 public:
74 // member functions
75 // NOLINTBEGIN
77 // NOLINTEND
78
79 public:
80 // destructor thunk
81 // NOLINTBEGIN
82 MCNAPI void $dtor();
83 // NOLINTEND
84 };
85
86 struct NewOutgoingConnectionEvent {
87 public:
88 // member variables
89 // NOLINTBEGIN
91 // NOLINTEND
92
93 public:
94 // prevent constructor by default
95 NewOutgoingConnectionEvent& operator=(NewOutgoingConnectionEvent const&);
96 NewOutgoingConnectionEvent(NewOutgoingConnectionEvent const&);
97 NewOutgoingConnectionEvent();
98
99 public:
100 // member functions
101 // NOLINTBEGIN
102#ifdef LL_PLAT_C
103 MCNAPI ~NewOutgoingConnectionEvent();
104#endif
105 // NOLINTEND
106
107 public:
108 // destructor thunk
109 // NOLINTBEGIN
110#ifdef LL_PLAT_C
111 MCNAPI void $dtor();
112#endif
113 // NOLINTEND
114 };
115
116 using BroadcastRequestCallback = ::std::function<bool(void*, int*)>;
117
118 using BroadcastResponseCallback = ::std::function<void(::NetherNet::NetworkID const&, void const*, int)>;
119
120 using Event = ::std::variant<
124
126
127public:
128 // member variables
129 // NOLINTBEGIN
130 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Bedrock::Http::LibHttpClientInstance> const> mHttpLibrary;
131 ::ll::TypedStorage<8, 24, ::NetherNet::NetworkID const> mNetworkID;
132 ::ll::TypedStorage<
133 8,
134 72,
135 ::std::unique_ptr<
137 ::std::function<void(::NetherNet::INetherNetTransportInterface*)>>>
138 mTransport;
139 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mBroadcastCallbackMutex;
140 ::ll::TypedStorage<8, 64, ::std::function<bool(void*, int*)>> mBroadcastRequestCallback;
141 ::ll::TypedStorage<8, 64, ::std::function<void(::NetherNet::NetworkID const&, void const*, int)>>
142 mBroadcastResponseCallback;
143 ::ll::TypedStorage<8, 80, ::std::recursive_mutex> mEventsMutex;
144 ::ll::TypedStorage<
145 8,
146 8,
147 ::std::unique_ptr<::std::vector<::std::variant<
151 mEvents;
152 ::ll::TypedStorage<8, 24, ::std::vector<::std::weak_ptr<::WebRTCNetworkPeer>>> mPeers;
153 // NOLINTEND
154
155public:
156 // prevent constructor by default
157 NetherNetConnector();
158
159public:
160 // virtual functions
161 // NOLINTBEGIN
162 virtual ~NetherNetConnector() /*override*/;
163
164 virtual bool closeSessionWithUser(::NetherNet::NetworkID remoteId, uint64 sessionId);
165
166 virtual void setDisableLanSignaling(bool disableLanSignaling) /*override*/;
167
168 virtual bool host(::ConnectionDefinition const& definition) /*override*/;
169
170 virtual bool connect(
171 ::Social::GameConnectionInfo const& primaryConnection,
172 ::Social::GameConnectionInfo const& backupConnection
173 ) /*override*/;
174
175 virtual void tick() /*override*/;
176
177 virtual void runEvents() /*override*/;
178
179 virtual ::NetworkIdentifier getNetworkIdentifier() const /*override*/;
180
181 virtual void closeNetworkConnection(::NetworkIdentifier const&) /*override*/;
182
183 virtual bool setApplicationHandshakeCompleted(::NetworkIdentifier const&) /*override*/;
184
185 virtual ::TransportLayer getNetworkType() const /*override*/;
186
187 virtual void _onDisable() /*override*/;
188
189 virtual void _onEnable() /*override*/;
190
191 virtual void OnSpopViolation() /*override*/;
192
193 virtual void OnSessionClose(
194 ::NetherNet::NetworkID networkID,
195 uint64 sessionId,
196 ::NetherNet::ESessionError sessionError,
197 ::Json::Value summary
198 ) /*override*/;
199
200 virtual void
201 OnBroadcastResponseReceived(::NetherNet::NetworkID networkID, void const* pApplicationData, int size) /*override*/;
202
203 virtual bool OnBroadcastDiscoveryRequestReceivedGetResponse(void* pApplicationData, int* pSize) /*override*/;
204
205 virtual void OnSessionGetConnectionFlags(::NetherNet::NetworkID flags, uint*) /*override*/;
206 // NOLINTEND
207
208public:
209 // member functions
210 // NOLINTBEGIN
211 MCAPI NetherNetConnector(
212 ::NetherNetTransportFactory const& factory,
213 ::Connector::ConnectionCallbacks& callbacks,
214 ::std::optional<::NetherNet::NetworkID> networkId
215 );
216
217 MCAPI void _createEventQueue();
218
219 MCAPI ::gsl::not_null<::std::shared_ptr<::WebRTCNetworkPeer>> _getOrCreatePeer(
220 ::NetherNet::NetworkID const& remoteId,
221 uint64 sessionId,
222 bool isLan,
223 ::Bedrock::Threading::UniqueLock<::std::recursive_mutex> const&
224 );
225
226 MCAPI void _queueIncomingConnectionEvent(::NetherNet::NetworkID peerId, uint64 sessionId, bool isLan);
227
228#ifdef LL_PLAT_C
229 MCAPI void _queueOutgoingConnectionEvent(::NetherNet::NetworkID peerId, uint64 sessionId, bool isLan);
230#endif
231
232 MCFOLD ::NetherNet::NetworkID const& getNetworkID() const;
233
234 MCAPI bool getSessionState(
235 ::NetherNet::NetworkID remoteId,
236 uint64 sessionId,
237 ::NetherNet::SessionState* connectionState
238 ) const;
239
240 MCAPI bool isPacketAvailable(::NetherNet::NetworkID remoteId, uint64 sessionId, uint* pcbMessageSize) const;
241
242 MCAPI bool readPacket(
243 ::NetherNet::NetworkID remoteId,
244 uint64 sessionId,
245 void* pubDest,
246 uint cbDest,
247 uint* pcbMessageSize
248 ) const;
249
250#ifdef LL_PLAT_C
251 MCAPI ::Bedrock::PubSub::Subscription registerLanEventHandler(::NetherNet::ILanEventHandler* handler) const;
252#endif
253
254 MCAPI bool sendPacket(
255 ::NetherNet::NetworkID remoteId,
256 uint64 sessionId,
257 ::std::string const& data,
258 ::NetherNet::ESendType eSendType
259 ) const;
260
261 MCAPI void setBroadcastRequestCallback(::std::function<bool(void*, int*)>&& broadcastRequestCallback);
262
263 MCAPI void setBroadcastResponseCallback(
264 ::std::function<void(::NetherNet::NetworkID const&, void const*, int)>&& broadcastResponseCallback
265 );
266
267 MCAPI void setRelayConfig(::std::vector<::NetherNet::StunRelayServer> const& config) const;
268
269 MCAPI void setSignalingInterface(::std::shared_ptr<::NetherNet::ISignalingInterface>&& channel) const;
270 // NOLINTEND
271
272public:
273 // constructor thunks
274 // NOLINTBEGIN
275 MCAPI void* $ctor(
276 ::NetherNetTransportFactory const& factory,
278 ::std::optional<::NetherNet::NetworkID> networkId
279 );
280 // NOLINTEND
281
282public:
283 // destructor thunk
284 // NOLINTBEGIN
285 MCAPI void $dtor();
286 // NOLINTEND
287
288public:
289 // virtual function thunks
290 // NOLINTBEGIN
291 MCAPI bool $closeSessionWithUser(::NetherNet::NetworkID remoteId, uint64 sessionId);
292
293 MCAPI void $setDisableLanSignaling(bool disableLanSignaling);
294
295 MCFOLD bool $host(::ConnectionDefinition const& definition);
296
297 MCFOLD bool $connect(
298 ::Social::GameConnectionInfo const& primaryConnection,
299 ::Social::GameConnectionInfo const& backupConnection
300 );
301
302 MCFOLD void $tick();
303
304 MCAPI void $runEvents();
305
306 MCAPI ::NetworkIdentifier $getNetworkIdentifier() const;
307
308 MCFOLD void $closeNetworkConnection(::NetworkIdentifier const&);
309
310 MCFOLD bool $setApplicationHandshakeCompleted(::NetworkIdentifier const&);
311
312 MCFOLD ::TransportLayer $getNetworkType() const;
313
314 MCFOLD void $_onDisable();
315
316 MCFOLD void $_onEnable();
317
318 MCFOLD void $OnSpopViolation();
319
320 MCAPI void $OnSessionClose(
321 ::NetherNet::NetworkID networkID,
322 uint64 sessionId,
323 ::NetherNet::ESessionError sessionError,
324 ::Json::Value summary
325 );
326
327 MCAPI void $OnBroadcastResponseReceived(::NetherNet::NetworkID networkID, void const* pApplicationData, int size);
328
329 MCAPI bool $OnBroadcastDiscoveryRequestReceivedGetResponse(void* pApplicationData, int* pSize);
330
331 MCAPI void $OnSessionGetConnectionFlags(::NetherNet::NetworkID flags, uint*);
332
333
334 // NOLINTEND
335
336public:
337 // vftables
338 // NOLINTBEGIN
340
342
343 MCNAPI static void** $vftable();
344
345 MCNAPI static void** $vftableForConnector();
346 // NOLINTEND
347};
Definition LibHttpClientInstance.h:16
Definition Subscription.h:10
Definition UniqueLock.h:8
Definition Value.h:16
Definition NetherNetTransportFactory.h:18
Definition INetherNetTransportInterfaceCallbacks.h:16
Definition INetherNetTransportInterface.h:21
Definition ISignalingInterface.h:17
Definition NetworkIdentifier.h:10
Definition RemoteConnector.h:19
Definition GameConnectionInfo.h:23
Definition WebRTCNetworkPeer.h:16
STL namespace.
Definition ConnectionDefinition.h:5
Definition Connector.h:25
Definition NetherNetConnector.h:43
Definition NetherNetConnector.h:60
Definition NetherNetConnector.h:86
static MCAPI void ** $vftableForConnector()
static MCAPI void ** $vftableForEnableNonOwnerReferences()
static MCAPI void ** $vftableForNetworkEnableDisableListener()
static MCAPI void ** $vftable()
Definition ILanEventHandler.h:15
Definition NetworkID.h:17
Definition SessionState.h:7
Definition StunRelayServer.h:7
Definition Alias.h:14