Skip to content

Commit 8bf541f

Browse files
authored
Satori api expansion (#180)
* Satori api expansion * Add peek events (cherry picked from commit 7ed749e6f50fddb37d9bcf4903fbb031001a77fa) # Conflicts: # interface/include/nakama-cpp/satori/SClientInterface.h * Add advanced search * Remove unnecessary header Apply format * Add labels api * Fix join live event auth
1 parent 93e9d47 commit 8bf541f

File tree

10 files changed

+629
-89
lines changed

10 files changed

+629
-89
lines changed

interface/include/nakama-cpp/satori/HardcodedLowLevelSatoriAPI.h

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ struct SAuthenticateRequest {
4949
// Optional custom properties to update with this call.
5050
// If not set, properties are left as they are on the server.
5151
std::unordered_map<std::string, std::string> custom_properties;
52+
// Optional no_session modifies the request to only create/update
53+
// an identity without creating a new session. If set to 'true'
54+
// the response won't include a token and a refresh token.
55+
bool no_session = false;
5256
};
5357

5458
// A single event. Usually, but not necessarily, part of a batch.
@@ -64,6 +68,14 @@ struct SEvent {
6468
std::string value;
6569
// The time when the event was triggered on the producer side. Unit is unix time milliseconds
6670
Nakama::NTimestamp timestamp;
71+
// The identity id associated with the event. Ignored if the event is published as part of a session.
72+
std::string identity_id;
73+
// The session id associated with the event. Ignored if the event is published as part of a session.
74+
std::string session_id;
75+
// The session issued at associated with the event. Ignored if the event is published as part of a session.
76+
int64_t session_issued_at;
77+
// The session expires at associated with the event. Ignored if the event is published as part of a session.
78+
int64_t session_expires_at;
6779
};
6880

6981
// Publish an event to the server
@@ -78,6 +90,8 @@ struct SExperiment {
7890
std::string name;
7991
// Value associated with this Experiment.
8092
std::string value;
93+
// The labels associated with this experiment.
94+
std::vector<std::string> labels;
8195
};
8296

8397
// All experiments that this identity is involved with.
@@ -106,6 +120,8 @@ struct SFlag {
106120
bool condition_changed = false;
107121
// The origin of change on the flag value returned.
108122
SValueChangeReason change_reason;
123+
// The labels associated with this flag.
124+
std::vector<std::string> labels;
109125
};
110126

111127
// All flags available to the identity
@@ -141,6 +157,8 @@ struct SFlagOverride {
141157
std::string flag_name;
142158
// The list of configuration that affect the value of the flag.
143159
std::vector<SValue> overrides;
160+
// The labels associated with this flag.
161+
std::vector<std::string> labels;
144162
};
145163

146164
// All flags available to the identity and their value overrides
@@ -151,20 +169,43 @@ struct SFlagOverrideList {
151169

152170
// Request to get all experiments data.
153171
struct SGetExperimentsRequest {
154-
// Experiment names; if empty string all experiments are returned.
172+
// Experiment names; if empty string, all experiments are returned based on the remaining filters.
155173
std::vector<std::string> names;
174+
// Label names that must be defined for each Experiment; if empty string, all experiments are returned based on the
175+
// remaining filters.
176+
std::vector<std::string> labels;
156177
};
157178

158179
// Request to get all flags data.
159180
struct SGetFlagsRequest {
160-
// Flag names; if empty string all flags are returned.
181+
// Flag names; if empty string, all flags are returned based on the remaining filters.
161182
std::vector<std::string> names;
183+
// Label names that must be defined for each Flag; if empty string, all flags are returned based on the remaining
184+
// filters.
185+
std::vector<std::string> labels;
162186
};
163187

164188
// Request to get all live events.
165189
struct SGetLiveEventsRequest {
166-
// Live event names; if empty string all live events are returned.
190+
// Live event names; if empty string, all live events are returned based on the remaining filters.
167191
std::vector<std::string> names;
192+
// Label names that must be defined for each Live Event; if empty string, all live events are returned based on the
193+
// remaining filters.
194+
std::vector<std::string> labels;
195+
// The maximum number of past event runs to return for each live event.
196+
int32_t past_run_count;
197+
// The maximum number of future event runs to return for each live event.
198+
int32_t future_run_count;
199+
// Start time of the time window filter to apply.
200+
int64_t start_time_sec;
201+
// End time of the time window filter to apply.
202+
int64_t end_time_sec;
203+
};
204+
205+
// Request to join a 'explicit join' live event.
206+
struct SJoinLiveEventRequest {
207+
// Live event id to join.
208+
std::string id;
168209
};
169210

170211
// Enrich/replace the current session with a new ID.
@@ -181,6 +222,8 @@ struct SIdentifyRequest {
181222

182223
// A single live event.
183224
struct SLiveEvent {
225+
// The status variants of a live event.
226+
enum SStatus { UNKNOWN = 0, ACTIVE = 1, UPCOMING = 2, TERMINATED = 3 };
184227
// Name.
185228
std::string name;
186229
// Description.
@@ -201,12 +244,18 @@ struct SLiveEvent {
201244
int64_t duration_sec;
202245
// Reset CRON schedule, if configured.
203246
std::string reset_cron;
247+
// The status of this live event run.
248+
SStatus status;
249+
// The labels associated with this live event.
250+
std::vector<std::string> labels;
204251
};
205252

206253
// List of Live events.
207254
struct SLiveEventList {
208255
// Live events.
209256
std::vector<SLiveEvent> live_events;
257+
// Live events that require explicit join.
258+
std::vector<SLiveEvent> explicit_join_live_events;
210259
};
211260

212261
// Properties associated with an identity.

interface/include/nakama-cpp/satori/SClientInterface.h

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,52 +77,71 @@ class NAKAMA_API SClientInterface {
7777

7878
virtual std::future<void> postEventAsync(SSessionPtr session, const std::vector<SEvent>& events) = 0;
7979

80+
virtual void serverEvent(
81+
const std::vector<SEvent>& events,
82+
std::function<void()> successCallback = nullptr,
83+
Nakama::ErrorCallback errorCallback = nullptr) = 0;
84+
85+
virtual std::future<void> serverEventAsync(const std::vector<SEvent>& events) = 0;
86+
8087
virtual void getExperiments(
8188
SSessionPtr session,
82-
const std::vector<std::string>& names,
89+
const SGetExperimentsRequest& request = SGetExperimentsRequest(),
8390
std::function<void(SExperimentList)> successCallback = nullptr,
8491
Nakama::ErrorCallback errorCallback = nullptr) = 0;
8592

8693
virtual std::future<SExperimentList>
87-
getExperimentsAsync(SSessionPtr session, const std::vector<std::string>& names) = 0;
94+
getExperimentsAsync(SSessionPtr session, const SGetExperimentsRequest& request = SGetExperimentsRequest()) = 0;
95+
96+
virtual void getFlags(
97+
const std::string& httpKey,
98+
const SGetFlagsRequest& request = SGetFlagsRequest(),
99+
std::function<void(SFlagList)> successCallback = nullptr,
100+
Nakama::ErrorCallback errorCallback = nullptr) = 0;
101+
102+
virtual std::future<SFlagList> getFlagsAsync(const std::string& httpKey, const SGetFlagsRequest& request = SGetFlagsRequest()) = 0;
88103

89104
virtual void getFlags(
90105
SSessionPtr session,
91-
const std::vector<std::string>& names = {},
106+
const SGetFlagsRequest& request = SGetFlagsRequest(),
92107
std::function<void(SFlagList)> successCallback = nullptr,
93108
Nakama::ErrorCallback errorCallback = nullptr) = 0;
94109

95-
virtual std::future<SFlagList> getFlagsAsync(SSessionPtr session, const std::vector<std::string>& names = {}) = 0;
110+
virtual std::future<SFlagList> getFlagsAsync(SSessionPtr session, const SGetFlagsRequest& request = SGetFlagsRequest()) = 0;
111+
112+
virtual void getFlagOverrides(
113+
const std::string& httpKey,
114+
const SGetFlagsRequest& request = SGetFlagsRequest(),
115+
std::function<void(SFlagOverrideList)> successCallback = nullptr,
116+
Nakama::ErrorCallback errorCallback = nullptr) = 0;
117+
118+
virtual std::future<SFlagOverrideList>
119+
getFlagOverridesAsync(const std::string& httpKey, const SGetFlagsRequest& request = SGetFlagsRequest()) = 0;
96120

97121
virtual void getFlagOverrides(
98122
SSessionPtr session,
99-
const std::vector<std::string>& names = {},
123+
const SGetFlagsRequest& request = SGetFlagsRequest(),
100124
std::function<void(SFlagOverrideList)> successCallback = nullptr,
101125
Nakama::ErrorCallback errorCallback = nullptr) = 0;
102126

103127
virtual std::future<SFlagOverrideList>
104-
getFlagOverridesAsync(SSessionPtr session, const std::vector<std::string>& names = {}) = 0;
105-
106-
/**
107-
* Request to get all live events.
108-
*
109-
* @param session The session of the user.
110-
* @param liveEventNames Live event names; if empty string all live events are returned.
111-
*/
128+
getFlagOverridesAsync(SSessionPtr session, const SGetFlagsRequest& request = SGetFlagsRequest()) = 0;
129+
112130
virtual void getLiveEvents(
113131
SSessionPtr session,
114-
const std::vector<std::string>& liveEventNames = {},
132+
const SGetLiveEventsRequest& request = SGetLiveEventsRequest(),
115133
std::function<void(SLiveEventList)> successCallback = nullptr,
116134
Nakama::ErrorCallback errorCallback = nullptr) = 0;
117135

118-
/**
119-
* Fetch one or more users by id, usernames, and Facebook ids.
120-
*
121-
* @param session The session of the user.
122-
* @param liveEventNames Live event names; if empty string all live events are returned.
123-
*/
124-
virtual std::future<SLiveEventList>
125-
getLiveEventsAsync(SSessionPtr session, const std::vector<std::string>& liveEventNames = {}) = 0;
136+
virtual std::future<SLiveEventList> getLiveEventsAsync(SSessionPtr session, const SGetLiveEventsRequest& request = SGetLiveEventsRequest()) = 0;
137+
138+
virtual void joinLiveEvent(
139+
SSessionPtr session,
140+
const std::string& id,
141+
std::function<void()> successCallback = nullptr,
142+
Nakama::ErrorCallback errorCallback = nullptr) = 0;
143+
144+
virtual std::future<void> joinLiveEventAsync(SSessionPtr session, const std::string& id) = 0;
126145

127146
virtual void identify(
128147
SSessionPtr session,

0 commit comments

Comments
 (0)