3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/deps/application/AppPlatformListener.h"
7#include "mc/deps/core/http/PersistentWebSocket.h"
8#include "mc/deps/core/threading/Async.h"
9#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
10#include "mc/deps/core/utility/NonOwnerPointer.h"
11#include "mc/deps/nether_net/ESessionError.h"
12#include "mc/deps/nether_net/ISignalingInterface.h"
13#include "mc/network/services/signaling/ISignalingJsonRpcInterop.h"
14#include "mc/platform/ErrorInfo.h"
15#include "mc/platform/Result.h"
27namespace Bedrock::Http {
struct Url; }
29namespace Json {
class Value; }
33namespace PlayerMessaging {
struct NetworkID; }
34namespace PlayerMessaging {
struct SigninID; }
38 public ::std::enable_shared_from_this<::SignalingService> {
51 enum class ConnectionStatus : uchar {
56 enum class SignInError :
int {
58 EmptyAuthFromDiscovery = 100,
59 EmptyUrlFromDiscovery = 101,
60 ExpiredAuthFromDiscovery = 102,
66 enum class ServiceError :
int {
68 PlayerUnreachable = 1,
69 MessageDeliveryFailed = 2,
71 FallbackToBestEffortDelivery = 4,
92 Connection& operator=(Connection
const&);
93 Connection(Connection
const&);
99 virtual ~Connection() ;
101 virtual void onMessage(::std::string_view incomingMessage) ;
103 virtual bool shouldReconnect()
const ;
105 virtual ::Bedrock::Threading::Async<::Bedrock::Http::Url> getUrl() ;
107 virtual ::Bedrock::Threading::Async<::Bedrock::Http::HeaderCollection> getHeaders() ;
109 virtual ::Bedrock::Http::RetryPolicy getReconnectPolicy() ;
111 virtual void onConnect() ;
113 virtual void onDisconnect(
bool, uint closeStatus) ;
115 virtual void _requestTurnConfig()
const;
117 virtual void _sendPing()
const;
119 virtual void onAppSuspended() ;
121 virtual void onAppResumed() ;
129 ::Bedrock::NotNullNonOwnerPtr<::ISignalingServiceConfigProvider> serviceConfigProvider,
130 ::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing> eventing,
134 MCNAPI
void _parseError(::std::string
const& message, ::std::string messageId);
136 MCNAPI ::Bedrock::Result<::std::vector<::NetherNet::StunRelayServer>, ::NetherNet::ESessionError>
140 ::NetherNet::ESessionError result,
141 ::std::vector<::NetherNet::StunRelayServer>
const& config
144 MCNAPI ::Bedrock::Threading::Async<::std::error_code>
connect();
154 MCNAPI ::Bedrock::Threading::Async<::NetherNet::ESessionError>
163 ::Bedrock::NotNullNonOwnerPtr<::ISignalingServiceConfigProvider> serviceConfigProvider,
164 ::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing> eventing,
182 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Http::Url>
$getUrl();
184 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Http::HeaderCollection>
$getHeaders();
224 Channel& operator=(Channel
const&);
225 Channel(Channel
const&);
231 virtual ~Channel() =
default;
233 virtual void SendSignal(
235 ::std::string
const& message,
236 ::std::function<
void(::NetherNet::ESessionError)>&& onComplete
239 virtual ::Bedrock::PubSub::Subscription
248 ::std::string
const& message,
249 ::std::function<
void(::NetherNet::ESessionError)>&& onComplete
258 ::std::string
const& message,
259 ::std::function<
void(::NetherNet::ESessionError)>&& onComplete
288 JsonRpcConnection& operator=(JsonRpcConnection
const&);
289 JsonRpcConnection(JsonRpcConnection
const&);
295 virtual ::Bedrock::Threading::Async<::Bedrock::Http::Url> getUrl() ;
297 virtual void onMessage(::std::string_view incomingMessage) ;
299 virtual void onConnect() ;
301 virtual ~JsonRpcConnection() =
default;
303 virtual void _sendPing()
const ;
305 virtual void _requestTurnConfig()
const ;
311 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Result<void, ::NetherNet::ESessionError>>
314 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Result<void, ::NetherNet::ESessionError>>
sendJsonRpcTo(
316 ::std::optional<::std::string>
const& messageId,
317 ::std::string
const& message
324 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Http::Url>
$getUrl();
355 JsonRpcInterop& operator=(JsonRpcInterop
const&);
356 JsonRpcInterop(JsonRpcInterop
const&);
362 virtual ~JsonRpcInterop() =
default;
364 virtual ::Bedrock::Threading::Async<::Bedrock::Result<void, ::NetherNet::ESessionError>> sendJsonRpcTo(
366 ::std::optional<::std::string>
const& messageId,
367 ::std::string
const& message
370 virtual ::Bedrock::Threading::Async<::Bedrock::Result<void, ::NetherNet::ESessionError>>
371 sendJsonRpc(::std::string
const& message)
const ;
373 virtual ::std::shared_ptr<::MessageTracker> getMessageTracker() ;
380 virtual void setTurnConfig(
381 ::std::vector<::NetherNet::StunRelayServer>&& config,
382 ::std::chrono::steady_clock::time_point expiration
391 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Result<void, ::NetherNet::ESessionError>>
$sendJsonRpcTo(
393 ::std::optional<::std::string>
const& messageId,
394 ::std::string
const& message
397 MCNAPI ::Bedrock::Threading::Async<::Bedrock::Result<void, ::NetherNet::ESessionError>>
407 ::std::vector<::NetherNet::StunRelayServer>&& config,
408 ::std::chrono::steady_clock::time_point expiration
442 SignalingService& operator=(SignalingService
const&);
443 SignalingService(SignalingService
const&);
449 virtual ~SignalingService() ;
456 ::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing> eventing,
463 MCNAPI ::Bedrock::Threading::Async<::std::vector<::NetherNet::StunRelayServer>>
getRelayConfig()
const;
465 MCNAPI_C ::std::shared_ptr<::ISignalingServiceTelemetry const> getTelemetry()
const;
Definition EnableNonOwnerReferences.h:7
Definition PersistentWebSocket.h:20
Definition RetryPolicy.h:12
Definition Subscription.h:10
Definition IMinecraftEventing.h:137
Definition ISignalingJsonRpcInterop.h:20
Definition ISignalingServiceConfigProvider.h:14
Definition ISignalingServiceTelemetry.h:14
Definition MessageTracker.h:18
Definition ISignalingInterface.h:17
Definition Scheduler.h:14
Definition SignalingService.h:212
MCAPI void _SendJsonRpcSignal(::NetherNet::NetworkID networkIDTo, ::std::string const &message, ::std::function< void(::NetherNet::ESessionError)> &&onComplete)
MCAPI void $SendSignal(::NetherNet::NetworkID to, ::std::string const &message, ::std::function< void(::NetherNet::ESessionError)> &&onComplete)
MCAPI::Bedrock::PubSub::Subscription $RegisterEventHandler(::NetherNet::ISignalingEventHandler *handler)
static MCAPI void ** $vftable()
Definition SignalingService.h:63
MCAPI void * $ctor(::PlayerMessaging::SigninID id, ::Bedrock::NotNullNonOwnerPtr<::ISignalingServiceConfigProvider > serviceConfigProvider, ::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing > eventing, bool useJsonRpc)
MCAPI void _parseError(::std::string const &message, ::std::string messageId)
MCAPI ::Bedrock::Threading::Async<::Bedrock::Http::Url > $getUrl()
MCAPI ::Bedrock::Result<::std::vector<::NetherNet::StunRelayServer >, ::NetherNet::ESessionError > _parseTurnConfig(::Json::Value const &config)
MCAPI void parseTurnConfig(::std::string const &bodyText)
static MCAPI void ** $vftableForAppPlatformListener()
MCAPI void _sendTurnConfigTelemetry(::NetherNet::ESessionError result, ::std::vector<::NetherNet::StunRelayServer > const &config)
static MCAPI void ** $vftableForPersistentWebSocket()
MCAPI void onTurnConfigFailure(::Bedrock::ErrorInfo<::NetherNet::ESessionError > const &error)
MCAPI void $onAppSuspended()
MCAPI void $onDisconnect(bool, uint closeStatus)
MCAPI::Bedrock::Http::RetryPolicy $getReconnectPolicy()
MCAPI void $onAppResumed()
MCAPI bool $shouldReconnect() const
MCAPI void parseTurnConfig(::Json::Value const &config)
MCAPI void $_sendPing() const
MCAPI ::Bedrock::Threading::Async<::std::error_code > connect()
MCAPI Connection(::PlayerMessaging::SigninID id, ::Bedrock::NotNullNonOwnerPtr<::ISignalingServiceConfigProvider > serviceConfigProvider, ::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing > eventing, bool useJsonRpc)
MCAPI void $_requestTurnConfig() const
MCAPI ::Bedrock::Threading::Async<::NetherNet::ESessionError > sendTo(::NetherNet::NetworkID to, ::std::string const &message)
MCAPI void $onMessage(::std::string_view incomingMessage)
MCAPI void parseSignal(::NetherNet::NetworkID fromNetworkID, ::std::string message, ::std::string messageId)
MCAPI ::Bedrock::Threading::Async<::Bedrock::Http::HeaderCollection > $getHeaders()
Definition SignalingService.h:274
Definition SignalingService.h:278
MCAPI ::Bedrock::Threading::Async<::Bedrock::Result< void, ::NetherNet::ESessionError > > sendJsonRpc(::std::string const &message)
MCAPI ::Bedrock::Threading::Async<::Bedrock::Result< void, ::NetherNet::ESessionError > > sendJsonRpcTo(::PlayerMessaging::NetworkID networkIdTo, ::std::optional<::std::string > const &messageId, ::std::string const &message)
MCAPI void $onMessage(::std::string_view incomingMessage)
MCAPI void $_sendPing() const
MCAPI void $_requestTurnConfig() const
static MCAPI void ** $vftableForPersistentWebSocket()
MCAPI ::Bedrock::Threading::Async<::Bedrock::Http::Url > $getUrl()
static MCAPI void ** $vftableForAppPlatformListener()
Definition SignalingService.h:346
MCAPI ::std::shared_ptr<::MessageTracker > $getMessageTracker()
MCAPI ::Bedrock::Threading::Async<::Bedrock::Result< void, ::NetherNet::ESessionError > > $sendJsonRpc(::std::string const &message) const
MCAPI ::Bedrock::Threading::Async<::Bedrock::Result< void, ::NetherNet::ESessionError > > $sendJsonRpcTo(::PlayerMessaging::NetworkID networkIdTo, ::std::optional<::std::string > const &messageId, ::std::string const &message) const
MCAPI void $parseSignal(::NetherNet::NetworkID fromNetworkID, ::std::string message, ::std::string messageId)
MCAPI void $setTurnConfig(::std::vector<::NetherNet::StunRelayServer > &&config, ::std::chrono::steady_clock::time_point expiration)
static MCAPI void ** $vftable()
MCAPI void $onTurnConfigFailure(::Bedrock::ErrorInfo<::NetherNet::ESessionError > const &error)
MCAPI void $parseTurnConfig(::Json::Value const &config)
Definition SignalingService.h:276
MCAPI ::Bedrock::Threading::Async<::std::error_code > signIn(::PlayerMessaging::SigninID localId)
MCAPI ::std::shared_ptr<::SignalingService::Connection > _makeConnection(::PlayerMessaging::SigninID id)
MCAPI void * $ctor(::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing > eventing, ::WorkerPool &pool, ::Scheduler &scheduler)
MCAPI SignalingService(::Bedrock::NotNullNonOwnerPtr<::IMinecraftEventing > eventing, ::WorkerPool &pool, ::Scheduler &scheduler)
MCAPI ::Bedrock::Threading::Async<::std::vector<::NetherNet::StunRelayServer > > getRelayConfig() const
static MCAPI void ** $vftable()
Definition WorkerPool.h:19
Definition ISignalingEventHandler.h:12
Definition NetworkID.h:17
Definition StunRelayServer.h:7
Definition NetworkID.h:12