LeviLamina
Loading...
Searching...
No Matches
NetworkSystem.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/common/SubClientId.h"
7#include "mc/deps/core/threading/Async.h"
8#include "mc/deps/core/utility/BinaryStream.h"
9#include "mc/deps/core/utility/NonOwnerPointer.h"
10#include "mc/deps/core/utility/pub_sub/Publisher.h"
11#include "mc/network/NetworkEnableDisableListener.h"
12#include "mc/network/NetworkSettingOptions.h"
13#include "mc/network/PacketGroupDefinition.h"
14#include "mc/network/RakNetConnector.h"
15#include "mc/network/RakPeerHelper.h"
16#include "mc/network/connection/DisconnectFailReason.h"
17
18// auto generated forward declare list
19// clang-format off
20class AppPlatform;
21class IPacketObserver;
24class LocalConnector;
28class NetworkPeer;
31class Packet;
32class RemoteConnector;
33class Scheduler;
34class ServerLocator;
35class TaskGroup;
36class WeakEntityRef;
38namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
39namespace Json { class Value; }
40namespace cereal { struct ReflectionCtx; }
41// clang-format on
42
43class NetworkSystem : public ::RakNetConnector::ConnectionCallbacks,
45 public ::NetworkEnableDisableListener {
46public:
47 // NetworkSystem inner types declare
48 // clang-format off
49 struct Dependencies;
51 // clang-format on
52
53 // NetworkSystem inner types define
54 struct Dependencies {
55 public:
56 // member variables
57 // NOLINTBEGIN
58 ::ll::TypedStorage<8, 8, ::std::reference_wrapper<::Scheduler>> receiveThread;
59 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::RemoteConnector>> remoteConnector;
60 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerLocator>> serverLocator;
61 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::AppPlatform>> appPlatform;
62 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::NetworkSessionOwner>> networkSessionOwner;
63 ::ll::TypedStorage<4, 20, ::NetworkSettingOptions> networkSettingOptions;
64 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IPacketSerializationController>> serializationController;
65 // NOLINTEND
66
67 public:
68 // member functions
69 // NOLINTBEGIN
70 MCAPI ~Dependencies();
71 // NOLINTEND
72
73 public:
74 // destructor thunk
75 // NOLINTBEGIN
76 MCAPI void $dtor();
77 // NOLINTEND
78 };
79
80 struct IncomingPacketQueue {
81 public:
82 // member variables
83 // NOLINTBEGIN
84 ::ll::TypedStorage<8, 8, ::NetEventCallback&> mCallbacksObj;
85 // NOLINTEND
86
87 public:
88 // prevent constructor by default
89 IncomingPacketQueue& operator=(IncomingPacketQueue const&);
90 IncomingPacketQueue(IncomingPacketQueue const&);
91 IncomingPacketQueue();
92 };
93
94 using IncomingPacketQueueArray = ::std::unique_ptr<::NetworkSystem::IncomingPacketQueue>[4];
95
96public:
97 // member variables
98 // NOLINTBEGIN
99 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::NetworkSessionOwner>> mNetworkSessionOwner;
100 ::ll::TypedStorage<8, 80, ::std::recursive_mutex> mConnectionsMutex;
101 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::NetworkConnection>>> mConnections;
102 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::LocalConnector>> mLocalConnector;
103 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::PacketGroupDefinition::PacketGroupBuilder>> mPacketGroupBuilder;
104 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::RemoteConnector>> mRemoteConnector;
105 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerLocator>> mServerLocator;
106 ::ll::TypedStorage<8, 8, uint64> mCurrentConnection;
107 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mReceiveTask;
108 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mReceiveTaskGroup;
109 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IPacketObserver>> mPacketObserver;
110 ::ll::TypedStorage<8, 8, ::Scheduler&> mMainThread;
111 ::ll::TypedStorage<8, 32, ::std::string> mReceiveBuffer;
112 ::ll::TypedStorage<8, 32, ::std::string> mSendBuffer;
113 ::ll::TypedStorage<8, 80, ::BinaryStream> mSendStream;
114 ::ll::TypedStorage<8, 32, ::std::unique_ptr<::NetworkSystem::IncomingPacketQueue>[4]> mIncomingPackets;
115 ::ll::TypedStorage<1, 1, bool> mUseIPv6Only;
116 ::ll::TypedStorage<2, 2, ushort> mDefaultGamePort;
117 ::ll::TypedStorage<2, 2, ushort> mDefaultGamePortv6;
118 ::ll::TypedStorage<1, 1, bool> mIsLanDiscoveryEnabled;
119 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::NetworkStatistics>> mNetworkStatistics;
120 ::ll::TypedStorage<1, 1, bool> mWebsocketsEnabled;
121 ::ll::TypedStorage<4, 20, ::NetworkSettingOptions> mNetworkSettingOptions;
122 ::ll::TypedStorage<1, 1, bool> mRawRecordingEnabled;
123 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::cereal::ReflectionCtx>>> mReflectionCtx;
124 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::IPacketSerializationController>>> mPacketOverrides;
125 ::ll::TypedStorage<
126 8,
127 8,
128 ::gsl::not_null<::std::unique_ptr<
129 ::Bedrock::PubSub::
131 mSessionSummaryPublisher;
132 // NOLINTEND
133
134public:
135 // prevent constructor by default
136 NetworkSystem& operator=(NetworkSystem const&);
137 NetworkSystem(NetworkSystem const&);
138 NetworkSystem();
139
140public:
141 LLNDAPI NetworkConnection* getConnectionFromId(NetworkIdentifier const& id);
142
143public:
144 // virtual functions
145 // NOLINTBEGIN
146 virtual bool useIPv4Only() const /*override*/;
147
148 virtual bool useIPv6Only() const /*override*/;
149
150 virtual ushort getDefaultGamePort() const /*override*/;
151
152 virtual ushort getDefaultGamePortv6() const /*override*/;
153
154 virtual ~NetworkSystem() /*override*/;
155
156 virtual void _onDisable() /*override*/;
157
158 virtual void _onEnable() /*override*/;
159
160 virtual bool
161 onNewIncomingConnection(::NetworkIdentifier const& id, ::std::shared_ptr<::NetworkPeer>&& peer) /*override*/;
162
163 virtual bool
164 onNewOutgoingConnection(::NetworkIdentifier const& id, ::std::shared_ptr<::NetworkPeer>&& peer) /*override*/;
165
166 virtual void onConnectionClosed(
167 ::NetworkIdentifier const& id,
168 ::Connection::DisconnectFailReason const discoReason,
169 ::std::string const& messageFromServer,
170 ::std::string const& messageBodyOverride,
171 bool skipDisconnectMessage,
172 ::Json::Value const& sessionSummary
173 ) /*override*/;
174
175 virtual void
176 onAllConnectionsClosed(::Connection::DisconnectFailReason discoReason, bool skipDisconnectMessage) /*override*/;
177
178 virtual void onAllRemoteConnectionsClosed(
179 ::Connection::DisconnectFailReason discoReason,
180 bool skipDisconnectMessage
181 ) /*override*/;
182
183 virtual void onOutgoingConnectionFailed(::Connection::DisconnectFailReason discoReason) /*override*/;
184
185 virtual void onWebsocketRequest(
186 ::std::string const& serverAddress,
187 ::std::string const& payload,
188 ::std::function<void()> errorCallback
189 ) /*override*/;
190 // NOLINTEND
191
192public:
193 // member functions
194 // NOLINTBEGIN
195 MCAPI explicit NetworkSystem(::NetworkSystem::Dependencies&& deps);
196
197 MCAPI ::std::shared_ptr<::IPacketSecurityController> _createPacketSecurityController(::NetworkIdentifier const& id);
198
199 MCAPI bool _isUsingNetherNetTransportLayer() const;
200
201 MCAPI void _sendInternal(::NetworkIdentifier const& id, ::Packet const& packet, ::std::string const& data);
202
203#ifdef LL_PLAT_C
204 MCAPI void closeConnection(
205 ::NetworkIdentifier const& id,
206 ::Connection::DisconnectFailReason discoReason,
207 ::std::string const& messageFromServer
208 );
209#endif
210
211 MCAPI void disconnect();
212
213 MCAPI void enableAsyncFlush(::NetworkIdentifier const& id);
214
215 MCAPI ::NetworkPeer* getPeerForUser(::NetworkIdentifier const& id);
216
217 MCAPI bool isServer() const;
218
219 MCAPI void runEvents(bool networkIsCritical);
220
221 MCAPI void send(::NetworkIdentifier const& id, ::Packet const& packet, ::SubClientId recipientSubId);
222
223 MCAPI void sendToMultiple(::std::vector<::NetworkIdentifierWithSubId> const& ids, ::Packet const& packet);
224
225 MCAPI void
226 setCloseConnection(::NetworkIdentifier const& id, ::Connection::DisconnectFailReason closeConnectionReason);
227
228 MCAPI void update(::std::vector<::WeakEntityRef> const* userList);
229 // NOLINTEND
230
231public:
232 // constructor thunks
233 // NOLINTBEGIN
234 MCAPI void* $ctor(::NetworkSystem::Dependencies&& deps);
235 // NOLINTEND
236
237public:
238 // destructor thunk
239 // NOLINTBEGIN
240 MCAPI void $dtor();
241 // NOLINTEND
242
243public:
244 // virtual function thunks
245 // NOLINTBEGIN
246 MCFOLD bool $useIPv4Only() const;
247
248 MCAPI bool $useIPv6Only() const;
249
250 MCAPI ushort $getDefaultGamePort() const;
251
252 MCAPI ushort $getDefaultGamePortv6() const;
253
254 MCAPI void $_onDisable();
255
256 MCAPI void $_onEnable();
257
258 MCAPI bool $onNewIncomingConnection(::NetworkIdentifier const& id, ::std::shared_ptr<::NetworkPeer>&& peer);
259
260 MCAPI bool $onNewOutgoingConnection(::NetworkIdentifier const& id, ::std::shared_ptr<::NetworkPeer>&& peer);
261
262 MCAPI void $onConnectionClosed(
263 ::NetworkIdentifier const& id,
264 ::Connection::DisconnectFailReason const discoReason,
265 ::std::string const& messageFromServer,
266 ::std::string const& messageBodyOverride,
267 bool skipDisconnectMessage,
268 ::Json::Value const& sessionSummary
269 );
270
271 MCAPI void $onAllConnectionsClosed(::Connection::DisconnectFailReason discoReason, bool skipDisconnectMessage);
272
273 MCAPI void
274 $onAllRemoteConnectionsClosed(::Connection::DisconnectFailReason discoReason, bool skipDisconnectMessage);
275
276 MCAPI void $onOutgoingConnectionFailed(::Connection::DisconnectFailReason discoReason);
277
278 MCAPI void $onWebsocketRequest(
279 ::std::string const& serverAddress,
280 ::std::string const& payload,
281 ::std::function<void()> errorCallback
282 );
283
284
285 // NOLINTEND
286};
Definition AppPlatform.h:91
Definition IPacketObserver.h:14
Definition IPacketSecurityController.h:22
Definition IPacketSerializationController.h:9
Definition Value.h:16
Definition LocalConnector.h:17
Definition NetEventCallback.h:263
Definition NetworkConnection.h:31
Definition NetworkIdentifier.h:10
Definition NetworkPeer.h:8
Definition NetworkSessionOwner.h:9
Definition NetworkStatistics.h:22
Definition Packet.h:29
Definition RakPeerHelper.h:35
Definition RemoteConnector.h:21
Definition Scheduler.h:14
Definition ServerLocator.h:20
Definition TaskGroup.h:61
Definition WeakEntityRef.h:14
STL namespace.
Definition NetworkIdentifierWithSubId.h:10
Definition NetworkSystem.h:54
Definition NetworkSystem.h:80
Definition RakNetConnector.h:40
Definition ReflectionCtx.h:11