v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
11
source/platform/CMakeLists.txt
Normal file
11
source/platform/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
INCLUDE_DIRECTORIES (
|
||||
${STAR_EXTERN_INCLUDES}
|
||||
${STAR_CORE_INCLUDES}
|
||||
${STAR_PLATFORM_INCLUDES}
|
||||
)
|
||||
|
||||
SET (star_platform_HEADERS
|
||||
StarP2PNetworkingService.hpp
|
||||
StarStatisticsService.hpp
|
||||
StarUserGeneratedContentService.hpp
|
||||
)
|
17
source/platform/StarDesktopService.hpp
Normal file
17
source/platform/StarDesktopService.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef STAR_DESKTOP_SERVICE_HPP
|
||||
#define STAR_DESKTOP_SERVICE_HPP
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_CLASS(DesktopService);
|
||||
|
||||
class DesktopService {
|
||||
public:
|
||||
~DesktopService() = default;
|
||||
|
||||
virtual void openUrl(String const& url) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
65
source/platform/StarP2PNetworkingService.hpp
Normal file
65
source/platform/StarP2PNetworkingService.hpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
#ifndef STAR_P2P_NETWORKING_SERVICE_HPP
|
||||
#define STAR_P2P_NETWORKING_SERVICE_HPP
|
||||
|
||||
#include "StarEither.hpp"
|
||||
#include "StarHostAddress.hpp"
|
||||
#include "StarStrongTypedef.hpp"
|
||||
#include "StarRpcPromise.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_CLASS(P2PSocket);
|
||||
STAR_CLASS(P2PNetworkingService);
|
||||
|
||||
enum class P2PJoinRequestReply {
|
||||
No,
|
||||
Yes,
|
||||
Ignore,
|
||||
};
|
||||
|
||||
// P2P networking is assumed to be guaranteed in order delivery of arbitrarily
|
||||
// sized messages. Neither the P2PSocket or the P2PNetworkingService are
|
||||
// assumed to be thread safe interfaces, but access to independent P2PSockets
|
||||
// from different threads or access to a P2PSocket and the P2PNetworkingService
|
||||
// from different threads is assumed to be safe.
|
||||
class P2PSocket {
|
||||
public:
|
||||
virtual ~P2PSocket() = default;
|
||||
|
||||
virtual bool isOpen() = 0;
|
||||
virtual bool sendMessage(ByteArray const& message) = 0;
|
||||
virtual Maybe<ByteArray> receiveMessage() = 0;
|
||||
};
|
||||
|
||||
strong_typedef(String, P2PNetworkingPeerId);
|
||||
|
||||
// API for platform specific peer to peer multiplayer services.
|
||||
class P2PNetworkingService {
|
||||
public:
|
||||
virtual ~P2PNetworkingService() = default;
|
||||
|
||||
// P2P friends cannot join this player
|
||||
virtual void setJoinUnavailable() = 0;
|
||||
// P2P friends can join this player's local game
|
||||
virtual void setJoinLocal(uint32_t capacity) = 0;
|
||||
// P2P friends can join this player at the given remote server
|
||||
virtual void setJoinRemote(HostAddressWithPort location) = 0;
|
||||
// Updates rich presence activity info
|
||||
virtual void setActivityData(String const& title, Maybe<pair<uint16_t, uint16_t>>) = 0;
|
||||
|
||||
// If this player joins another peer's game using the P2P UI, this will return
|
||||
// a pending join location
|
||||
virtual MVariant<P2PNetworkingPeerId, HostAddressWithPort> pullPendingJoin() = 0;
|
||||
// This will return a username and a promise keeper to respond to the join request
|
||||
virtual Maybe<pair<String, RpcPromiseKeeper<P2PJoinRequestReply>>> pullJoinRequest() = 0;
|
||||
|
||||
virtual void setAcceptingP2PConnections(bool acceptingP2PConnections) = 0;
|
||||
virtual List<P2PSocketUPtr> acceptP2PConnections() = 0;
|
||||
virtual void update() = 0;
|
||||
|
||||
virtual Either<String, P2PSocketUPtr> connectToPeer(P2PNetworkingPeerId peerId) = 0;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
40
source/platform/StarStatisticsService.hpp
Normal file
40
source/platform/StarStatisticsService.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef STAR_STATS_BACKEND_HPP
|
||||
#define STAR_STATS_BACKEND_HPP
|
||||
|
||||
#include "StarJson.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_CLASS(StatisticsService);
|
||||
|
||||
class StatisticsService {
|
||||
public:
|
||||
virtual ~StatisticsService() = default;
|
||||
|
||||
virtual bool initialized() const = 0;
|
||||
virtual Maybe<String> error() const = 0;
|
||||
|
||||
// The functions below aren't valid unless initialized() returns true and
|
||||
// error() is empty.
|
||||
|
||||
// setStat should return false for stats or types that aren't known by the
|
||||
// service, without reporting an error.
|
||||
// By sending all stats to the StatisticsService, we can configure collection
|
||||
// of new stats entirely on the service, without any modifications to the game.
|
||||
virtual bool setStat(String const& name, String const& type, Json const& value) = 0;
|
||||
virtual Json getStat(String const& name, String const& type, Json def = {}) const = 0;
|
||||
|
||||
// reportEvent should return false if the service doesn't handle this event.
|
||||
virtual bool reportEvent(String const& name, Json const& fields) = 0;
|
||||
|
||||
virtual bool unlockAchievement(String const& name) = 0;
|
||||
virtual StringSet achievementsUnlocked() const = 0;
|
||||
|
||||
virtual void refresh() = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual bool reset() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
26
source/platform/StarUserGeneratedContentService.hpp
Normal file
26
source/platform/StarUserGeneratedContentService.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef STAR_USER_GENERATED_CONTENT_SERVICE_HPP
|
||||
#define STAR_USER_GENERATED_CONTENT_SERVICE_HPP
|
||||
|
||||
namespace Star {
|
||||
|
||||
STAR_CLASS(UserGeneratedContentService);
|
||||
|
||||
class UserGeneratedContentService {
|
||||
public:
|
||||
~UserGeneratedContentService() = default;
|
||||
|
||||
// Returns a list of the content the user is currently subscribed to.
|
||||
virtual StringList subscribedContentIds() const = 0;
|
||||
|
||||
// If the content has been downloaded successfully, returns the path to the
|
||||
// downloaded content directory on the filesystem, otherwise nothing.
|
||||
virtual Maybe<String> contentDownloadDirectory(String const& contentId) const = 0;
|
||||
|
||||
// Start downloading subscribed content in the background, returns true when
|
||||
// all content is synchronized.
|
||||
virtual bool triggerContentDownload() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue