#pragma once #include "V8Tree/Instance.h" #include "V8Tree/Service.h" #include "Util/HeapValue.h" #ifdef _WIN32 #if defined(_NOOPT) || defined(_DEBUG) || defined(RBX_TEST_BUILD) //#define DEBUG_TELEPORT #endif #endif namespace RBX { class DataModel; class TeleportCallback; extern const char *const sTeleportService; class TeleportService : public DescribedNonCreatable, public Service { private: static TeleportCallback *_callback; static std::string _spawnName; static std::string _baseUrl; static std::string _browserTrackerId; static bool _waitingForUserInput; bool requestingTeleport; std::string url; RBX::Timer retryTimer; boost::scoped_ptr teleportThread; static HeapValue previousPlaceId; static HeapValue previousCreatorType; static HeapValue previousCreatorId; static bool teleported; static boost::shared_ptr customTeleportLoadingGui; static Reflection::Variant dataTable; boost::shared_ptr tempCustomTeleportLoadingGui; typedef boost::unordered_map SettingsMap; static SettingsMap settingsTable; public: enum TeleportState { TeleportState_RequestedFromServer = 0, TeleportState_Started, TeleportState_WaitingForServer, TeleportState_Failed, TeleportState_InProgress, TeleportState_NumStates }; enum TeleportType { TeleportType_ToPlace = 0, TeleportType_ToInstance, TeleportType_ToReservedServer }; boost::function confirmationCallback; boost::function showErrorCallback; bool customizedTeleportUI; TeleportService(); static void SetCallback(TeleportCallback *callback); static void SetBaseUrl(const char *baseUrl); static void SetBrowserTrackerId(const std::string& browserTrackerId); void TeleportImpl(shared_ptr teleportInfo, shared_ptr customLoadingGUI = shared_ptr()); void TeleportCancel(); void TeleportThreadImpl(shared_ptr teleportInfo); void ServerTeleport(shared_ptr characterOrPlayerInstance, shared_ptr teleportInfo, shared_ptr customLoadingGUI); void Teleport(int placeId, shared_ptr characterOrPlayerInstance, Reflection::Variant teleportData, shared_ptr customLoadingGUI); void TeleportToSpawnByName(int placeId, std::string spawnName, shared_ptr characterOrPlayerInstance, Reflection::Variant teleportData, shared_ptr customLoadingGUI); void TeleportToPrivateServer(int placeId, std::string reservedServerAccessCode, shared_ptr players, std::string spawnName, Reflection::Variant teleportData, shared_ptr customLoadingGUI); void ProcessGrantAccessSuccess(shared_ptr players, shared_ptr teleportInfo, shared_ptr customLoadingGUI, std::string response); void ProcessGrantAccessError(shared_ptr players, shared_ptr teleportInfo, std::string error); void ReserveServer(int placeId, boost::function resumeFunction, boost::function errorFunction); void ProcessReserveServerResultsSuccess(std::string response, boost::function resumeFunction, boost::function errorFunction); void ProcessReserveServerResultsError(std::string error, boost::function errorFunction); void ProcessGetPlayerPlaceInstanceResultsSuccess(std::string response, boost::function)> resumeFunction, boost::function errorFunction); void ProcessGetPlayerPlaceInstanceResultsError(std::string error, boost::function errorFunction); void GetPlayerPlaceInstanceAsync(int playerId, boost::function)> resumeFunction, boost::function errorFunction); void TeleportToPlaceInstance(int placeId, std::string instanceId, shared_ptr characterOrPlayerInstance, std::string spawnName, Reflection::Variant teleportData, shared_ptr customLoadingGUI); static std::string & GetSpawnName(); static void ResetSpawnName(); void SetTeleportSetting(std::string key, Reflection::Variant value); Reflection::Variant GetTeleportSetting(std::string key); bool attemptingTeleport() { return requestingTeleport; } static Reflection::EventDesc, Reflection::Variant)> event_playerArrivedFromTeleport; void sendPlayerArrivedFromTeleportSignal(shared_ptr loadingGui, Reflection::Variant teleportDataTable) { playerArrivedFromTeleportSignal(loadingGui, teleportDataTable); } rbx::signal, Reflection::Variant)> playerArrivedFromTeleportSignal; static int getPreviousPlaceId() {return previousPlaceId;} static int getPreviousCreatorType() {return previousCreatorType;} static int getPreviousCreatorId() {return previousCreatorId;} static boost::shared_ptr getCustomTeleportLoadingGui() {return customTeleportLoadingGui;} static void setCustomTeleportLoadingGui(shared_ptr value) {customTeleportLoadingGui = value;} boost::shared_ptr getTempCustomTeleportLoadingGui() {return tempCustomTeleportLoadingGui;} void setTempCustomTeleportLoadingGui(shared_ptr value) {tempCustomTeleportLoadingGui = value;} static bool didTeleport() {return teleported;} static Reflection::Variant getDataTable() {return dataTable;} Reflection::Variant getLocalPlayerTeleportData(); }; }