mirror of
https://github.com/heroiclabs/nakama-java.git
synced 2026-11-24 08:55:49 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
747c31aee3 | ||
|
|
54faa2d1f8 | ||
|
|
55b69d693d | ||
|
|
113d21a1e1 | ||
|
|
95a8571b4c | ||
|
|
b8de50d4e0 | ||
|
|
11d758e48c | ||
|
|
6e8e08519b | ||
|
|
0e3e237656 | ||
|
|
8cd7bd7e71 | ||
|
|
d9c2ffe343 | ||
|
|
5f044e2cf7 | ||
|
|
55119792d9 | ||
|
|
38362c56ef | ||
|
|
4f43a4acb9 | ||
|
|
6fc77a2b23 | ||
|
|
5922d7e655 | ||
|
|
5f54b0a385 |
No files matched your search
@@ -4,6 +4,42 @@ All notable changes to this project are documented below.
|
||||
|
||||
The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/).
|
||||
|
||||
## [0.5.1] - 2017-12-07
|
||||
### Fixed
|
||||
- Build storage update messages with valid operations.
|
||||
|
||||
## [0.5.0] - 2017-11-21
|
||||
### Added
|
||||
- Support for In-App Notifications feature.
|
||||
- Support for Friends feature.
|
||||
- Support for Groups feature.
|
||||
|
||||
### Changed
|
||||
- Leaderboard sort order is now exposed as an enum rather than a number.
|
||||
|
||||
### Fixed
|
||||
- Use correct name for inconsistently defined topic leave message builder method.
|
||||
|
||||
## [0.4.0] - 2017-11-07
|
||||
### Changed
|
||||
- Expose a simpler interface for identifier fields.
|
||||
|
||||
## [0.3.0] - 2017-10-17
|
||||
### Added
|
||||
- Advanced Matchmaking with custom filters and user properties.
|
||||
|
||||
### Fixed
|
||||
- Improved errors to contain the underlying error reason.
|
||||
|
||||
## [0.2.0] - 2017-09-24
|
||||
### Added
|
||||
- Leaderboard messages.
|
||||
- Matchmaking messages.
|
||||
- Match messsages.
|
||||
- Match presence updates.
|
||||
- Topic messages.
|
||||
- Topic presence updates.
|
||||
|
||||
## [0.1.2] - 2017-09-02
|
||||
### Fixed
|
||||
- Pin transitive SLF4J dependency on 1.7.* stable release.
|
||||
|
||||
@@ -24,6 +24,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compile(group: 'com.heroiclabs.nakama', name: 'client', version: '+')
|
||||
compile('org.slf4j:slf4j-api:1.7.25') {
|
||||
force = true // don't upgrade to "1.8.0-alpha2"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+9
-3
@@ -25,7 +25,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com.heroiclabs.nakama'
|
||||
version = '0.1.2'
|
||||
version = '0.5.1'
|
||||
def description = 'Android optimized Java client for Nakama server.'
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
@@ -83,14 +83,15 @@ bintray {
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.16.18'
|
||||
compile 'com.google.code.gson:gson:2.8.1'
|
||||
compile 'com.google.code.gson:gson:2.8.2'
|
||||
compile 'com.google.protobuf:protobuf-lite:3.0.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.8.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.9.0'
|
||||
compile 'com.stumbleupon:async:1.4.1'
|
||||
compile ('org.slf4j:slf4j-api:1.7.25') {
|
||||
force = true // don't upgrade to "1.8.0-alpha2"
|
||||
}
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'ch.qos.logback:logback-classic:1.2.3'
|
||||
}
|
||||
|
||||
gitPublish {
|
||||
@@ -107,6 +108,11 @@ gitPublish {
|
||||
preserve {
|
||||
include '0.1.0/**'
|
||||
include '0.1.1/**'
|
||||
include '0.1.2/**'
|
||||
include '0.2.0/**'
|
||||
include '0.3.0/**'
|
||||
include '0.4.0/**'
|
||||
include '0.5.0/**'
|
||||
}
|
||||
commitMessage = "Published javadoc '$project.version' via Gradle ${GradleVersion.current().version}."
|
||||
}
|
||||
|
||||
+1
-1
Submodule server updated: 15dc7ba786...ca88ea9ce6.
@@ -68,5 +68,5 @@ public interface Client {
|
||||
* @param message The message to send.
|
||||
* @return Placeholder return type to allow chaining operations.
|
||||
*/
|
||||
Deferred<Boolean> send(Message message);
|
||||
Deferred<Boolean> send(UncollatedMessage message);
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A listener for receiving {@code Client} events.
|
||||
*/
|
||||
@@ -24,4 +26,46 @@ public interface ClientListener {
|
||||
* Called when the client socket disconnects.
|
||||
*/
|
||||
void onDisconnect();
|
||||
|
||||
/**
|
||||
* Called when a new topic message has been received.
|
||||
*
|
||||
* @param message The {@code TopicMessage} received.
|
||||
*/
|
||||
void onTopicMessage(TopicMessage message);
|
||||
|
||||
/**
|
||||
* Called when a new topic presence update has been received.
|
||||
*
|
||||
* @param presence The {@code TopicPresence} received.
|
||||
*/
|
||||
void onTopicPresence(TopicPresence presence);
|
||||
|
||||
/**
|
||||
* Called when a matchmaking has found a match.
|
||||
*
|
||||
* @param matched The {@code MatchmakeMatched} received.
|
||||
*/
|
||||
void onMatchmakeMatched(MatchmakeMatched matched);
|
||||
|
||||
/**
|
||||
* Called when a new match data is received.
|
||||
*
|
||||
* @param matchData The {@code MatchData} received.
|
||||
*/
|
||||
void onMatchData(MatchData matchData);
|
||||
|
||||
/**
|
||||
* Called when a new match presence update is received.
|
||||
*
|
||||
* @param matchPresence The {@code MatchPresence} received.
|
||||
*/
|
||||
void onMatchPresence(MatchPresence matchPresence);
|
||||
|
||||
/**
|
||||
* Called when the client receives new notifications.
|
||||
*
|
||||
* @param notifications The list of {@code Notification} received.
|
||||
*/
|
||||
void onNotifications(List<Notification> notifications);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public interface Cursor {
|
||||
/**
|
||||
* @return The encoded pointer which represents a position in the database records.
|
||||
*/
|
||||
byte[] getValue();
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* @return Encode the cursor so it can be cached.
|
||||
|
||||
@@ -62,9 +62,9 @@ public class DefaultClient implements Client {
|
||||
|
||||
private long serverTime;
|
||||
|
||||
private DefaultClient(final String serverKey, final String host, final int port, final String lang,
|
||||
final boolean ssl, final int connectTimeout, final int timeout, final boolean trace,
|
||||
final ClientListener listener) {
|
||||
private DefaultClient(final @NonNull String serverKey, final @NonNull String host, final int port,
|
||||
final @NonNull String lang, final boolean ssl, final int connectTimeout, final int timeout,
|
||||
final boolean trace, final @NonNull ClientListener listener) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.serverKey = serverKey;
|
||||
@@ -126,7 +126,7 @@ public class DefaultClient implements Client {
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
deferred.callback(new DefaultError("Error sending message to server", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Error sending message to server", e));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ public class DefaultClient implements Client {
|
||||
try {
|
||||
authResponse = com.heroiclabs.nakama.Api.AuthenticateResponse.parseFrom(body.byteStream());
|
||||
} catch (IOException e) {
|
||||
deferred.callback(new DefaultError("Error reading response from server", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Error reading response from server", e));
|
||||
return;
|
||||
} finally {
|
||||
response.close();
|
||||
@@ -152,13 +152,13 @@ public class DefaultClient implements Client {
|
||||
|
||||
switch (authResponse.getIdCase()) {
|
||||
case ERROR:
|
||||
deferred.callback(new DefaultError(authResponse.getError().getMessage(), authResponse.getError().getCode()));
|
||||
deferred.callback(new DefaultError(authResponse.getError().getMessage(), authResponse.getError().getCode(), authResponse.getCollationId()));
|
||||
break;
|
||||
case SESSION:
|
||||
deferred.callback(DefaultSession.restore(authResponse.getSession().getToken()));
|
||||
break;
|
||||
default:
|
||||
deferred.callback(new DefaultError("Unknown response format from server", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Unknown response format from server for message", Error.ErrorCode.UNKNOWN, authResponse.getCollationId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public class DefaultClient implements Client {
|
||||
}
|
||||
|
||||
final String collationId = envelope.getCollationId();
|
||||
if (collationId == null) {
|
||||
if (collationId == null || "".equals(collationId)) {
|
||||
switch (envelope.getPayloadCase()) {
|
||||
case PAYLOAD_NOT_SET:
|
||||
log.error("No payload in incoming uncollated message from server: " + envelope.toString());
|
||||
@@ -237,6 +237,28 @@ public class DefaultClient implements Client {
|
||||
serverTime = newServerTime;
|
||||
}
|
||||
break;
|
||||
case TOPIC_MESSAGE:
|
||||
listener.onTopicMessage(DefaultTopicMessage.fromProto(envelope.getTopicMessage()));
|
||||
break;
|
||||
case TOPIC_PRESENCE:
|
||||
listener.onTopicPresence(DefaultTopicPresence.fromProto(envelope.getTopicPresence()));
|
||||
break;
|
||||
case MATCH_DATA:
|
||||
listener.onMatchData(DefaultMatchData.fromProto(envelope.getMatchData()));
|
||||
break;
|
||||
case MATCH_PRESENCE:
|
||||
listener.onMatchPresence(DefaultMatchPresence.fromProto(envelope.getMatchPresence()));
|
||||
break;
|
||||
case MATCHMAKE_MATCHED:
|
||||
listener.onMatchmakeMatched(DefaultMatchmakeMatched.fromProto(envelope.getMatchmakeMatched()));
|
||||
break;
|
||||
case LIVE_NOTIFICATIONS:
|
||||
final List<Notification> notifications = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.Notification notification : envelope.getLiveNotifications().getNotificationsList()) {
|
||||
notifications.add(DefaultNotification.fromProto(notification));
|
||||
}
|
||||
listener.onNotifications(notifications);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -254,7 +276,7 @@ public class DefaultClient implements Client {
|
||||
def.callback(Boolean.TRUE);
|
||||
break;
|
||||
case ERROR:
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode()));
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode(), collationId));
|
||||
break;
|
||||
case SELF:
|
||||
def.callback(DefaultSelf.fromProto(envelope.getSelf().getSelf()));
|
||||
@@ -266,14 +288,42 @@ public class DefaultClient implements Client {
|
||||
}
|
||||
def.callback(new DefaultResultSet<User>(null, users));
|
||||
break;
|
||||
case FRIENDS:
|
||||
final List<Friend> friends = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.Friend friend : envelope.getFriends().getFriendsList()) {
|
||||
friends.add(DefaultFriend.fromProto(friend));
|
||||
}
|
||||
def.callback(new DefaultResultSet<Friend>(null, friends));
|
||||
break;
|
||||
case GROUPS:
|
||||
final List<Group> groups = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.Group group : envelope.getGroups().getGroupsList()) {
|
||||
groups.add(DefaultGroup.fromProto(group));
|
||||
}
|
||||
def.callback(new DefaultResultSet<Group>(new DefaultCursor(envelope.getGroups().getCursor()), groups));
|
||||
break;
|
||||
case GROUPS_SELF:
|
||||
final List<GroupSelf> groupsSelf = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.TGroupsSelf.GroupSelf groupSelf : envelope.getGroupsSelf().getGroupsSelfList()) {
|
||||
groupsSelf.add(DefaultGroupSelf.fromProto(groupSelf));
|
||||
}
|
||||
def.callback(new DefaultResultSet<GroupSelf>(null, groupsSelf));
|
||||
break;
|
||||
case GROUP_USERS:
|
||||
final List<GroupUser> groupUsers = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.GroupUser groupUser : envelope.getGroupUsers().getUsersList()) {
|
||||
groupUsers.add(DefaultGroupUser.fromProto(groupUser));
|
||||
}
|
||||
def.callback(new DefaultResultSet<GroupUser>(null, groupUsers));
|
||||
break;
|
||||
case STORAGE_DATA:
|
||||
final List<StorageRecord> records = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.TStorageData.StorageData data : envelope.getStorageData().getDataList()) {
|
||||
records.add(DefaultStorageRecord.fromProto(data));
|
||||
}
|
||||
Cursor cursor = null;
|
||||
if (envelope.getStorageData().getCursor() != null && envelope.getStorageData().getCursor().size() > 0) {
|
||||
cursor = new DefaultCursor(envelope.getStorageData().getCursor().toByteArray());
|
||||
if (envelope.getStorageData().getCursor() != null && envelope.getStorageData().getCursor().length() > 0) {
|
||||
cursor = new DefaultCursor(envelope.getStorageData().getCursor());
|
||||
}
|
||||
def.callback(new DefaultResultSet<StorageRecord>(cursor, records));
|
||||
break;
|
||||
@@ -287,8 +337,59 @@ public class DefaultClient implements Client {
|
||||
case RPC:
|
||||
def.callback(DefaultRpcResult.fromProto(envelope.getRpc()));
|
||||
break;
|
||||
case TOPICS:
|
||||
final List<Topic> topics = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.TTopics.Topic topic : envelope.getTopics().getTopicsList()) {
|
||||
topics.add(DefaultTopic.fromProto(topic));
|
||||
}
|
||||
def.callback(new DefaultResultSet<Topic>(null, topics));
|
||||
break;
|
||||
case TOPIC_MESSAGE_ACK:
|
||||
def.callback(DefaultTopicMessageAck.fromProto(envelope.getTopicMessageAck()));
|
||||
break;
|
||||
case TOPIC_MESSAGES:
|
||||
final List<TopicMessage> messages = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.TopicMessage m : envelope.getTopicMessages().getMessagesList()) {
|
||||
messages.add(DefaultTopicMessage.fromProto(m));
|
||||
}
|
||||
def.callback(new DefaultResultSet<TopicMessage>(new DefaultCursor(envelope.getTopicMessages().getCursor()), messages));
|
||||
break;
|
||||
case MATCH:
|
||||
def.callback(DefaultMatch.fromProto(envelope.getMatch()));
|
||||
break;
|
||||
case MATCHES:
|
||||
final List<Match> matches = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.Match m : envelope.getMatches().getMatchesList()) {
|
||||
matches.add(DefaultMatch.fromProto(m));
|
||||
}
|
||||
def.callback(new DefaultResultSet<Match>(null, matches));
|
||||
break;
|
||||
case MATCHMAKE_TICKET:
|
||||
def.callback(DefaultMatchmakeTicket.fromProto(envelope.getMatchmakeTicket()));
|
||||
break;
|
||||
case LEADERBOARDS:
|
||||
final List<Leaderboard> leaderboards = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.Leaderboard l : envelope.getLeaderboards().getLeaderboardsList()) {
|
||||
leaderboards.add(DefaultLeaderboard.fromProto(l));
|
||||
}
|
||||
def.callback(new DefaultResultSet<Leaderboard>(new DefaultCursor(envelope.getLeaderboards().getCursor()), leaderboards));
|
||||
break;
|
||||
case LEADERBOARD_RECORDS:
|
||||
final List<LeaderboardRecord> leaderboardRecords = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.LeaderboardRecord r : envelope.getLeaderboardRecords().getRecordsList()) {
|
||||
leaderboardRecords.add(DefaultLeaderboardRecord.fromProto(r));
|
||||
}
|
||||
def.callback(new DefaultResultSet<LeaderboardRecord>(new DefaultCursor(envelope.getLeaderboardRecords().getCursor()), leaderboardRecords));
|
||||
break;
|
||||
case NOTIFICATIONS:
|
||||
final List<Notification> notifications = new ArrayList<>();
|
||||
for (final com.heroiclabs.nakama.Api.Notification notification : envelope.getNotifications().getNotificationsList()) {
|
||||
notifications.add(DefaultNotification.fromProto(notification));
|
||||
}
|
||||
def.callback(new DefaultResultSet<Notification>(new DefaultCursor(envelope.getNotifications().getResumableCursor()), notifications));
|
||||
break;
|
||||
default:
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode()));
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode(), collationId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -308,9 +409,7 @@ public class DefaultClient implements Client {
|
||||
// TODO callback any leftover deferred items with a disconnect error message?
|
||||
collationIds.clear();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onDisconnect();
|
||||
}
|
||||
listener.onDisconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -322,9 +421,7 @@ public class DefaultClient implements Client {
|
||||
// TODO callback any leftover deferred items with a disconnect error message?
|
||||
collationIds.clear();
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onDisconnect();
|
||||
}
|
||||
listener.onDisconnect();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -365,7 +462,7 @@ public class DefaultClient implements Client {
|
||||
|
||||
final boolean isEnqueued = socket.send(ByteString.of(payload));
|
||||
if (!isEnqueued) {
|
||||
deferred.callback(new DefaultError("Failed to send message, make sure the client is connected", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Failed to send message, make sure the client is connected", Error.ErrorCode.UNKNOWN, collationId));
|
||||
return deferred;
|
||||
}
|
||||
|
||||
@@ -374,7 +471,7 @@ public class DefaultClient implements Client {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Deferred<Boolean> send(final @NonNull Message message) {
|
||||
public Deferred<Boolean> send(final @NonNull UncollatedMessage message) {
|
||||
final Deferred<Boolean> deferred = new Deferred<>();
|
||||
|
||||
if (socket == null) {
|
||||
@@ -412,7 +509,7 @@ public class DefaultClient implements Client {
|
||||
private int connectTimeout = 3000;
|
||||
private int timeout = 5000;
|
||||
private boolean trace = false;
|
||||
private ClientListener listener;
|
||||
private ClientListener listener = new NoopClientListener();
|
||||
|
||||
public Client build() {
|
||||
return new DefaultClient(serverKey, host, port, lang, ssl, connectTimeout, timeout, trace, listener);
|
||||
@@ -453,7 +550,7 @@ public class DefaultClient implements Client {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder listener(final ClientListener listener) {
|
||||
public Builder listener(final @NonNull ClientListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -20,17 +20,16 @@ import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import okio.ByteString;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultCursor implements Cursor {
|
||||
|
||||
private final byte[] value;
|
||||
private final String value;
|
||||
|
||||
public String serialize() {
|
||||
return ByteString.of(value).base64();
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +37,6 @@ public class DefaultCursor implements Cursor {
|
||||
* @return A new cursor which was stored.
|
||||
*/
|
||||
public static Cursor restore(final String serializedCursor) {
|
||||
final byte[] cursor = ByteString.decodeBase64(serializedCursor).toByteArray();
|
||||
return new DefaultCursor(cursor);
|
||||
return new DefaultCursor(serializedCursor);
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,30 @@ import lombok.*;
|
||||
class DefaultError extends Error {
|
||||
|
||||
private final ErrorCode code;
|
||||
private final String collationId;
|
||||
|
||||
DefaultError(final @NonNull String message, final @NonNull ErrorCode code) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.collationId = null;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final int code) {
|
||||
DefaultError(final @NonNull String message, final @NonNull ErrorCode code, final String collationId) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.collationId = collationId;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final @NonNull Throwable cause) {
|
||||
super(message, cause);
|
||||
this.code = ErrorCode.UNKNOWN;
|
||||
this.collationId = null;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final int code, final String collationId) {
|
||||
super(message);
|
||||
this.code = ErrorCode.fromInt(code);
|
||||
this.collationId = collationId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultFriend implements Friend {
|
||||
|
||||
private final String avatarUrl;
|
||||
|
||||
private final long createdAt;
|
||||
|
||||
private final String fullname;
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
private final long lastOnlineAt;
|
||||
|
||||
private final String location;
|
||||
|
||||
private final String metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
private final FriendType state;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static Friend fromProto(final @NonNull com.heroiclabs.nakama.Api.Friend friend) {
|
||||
return new DefaultFriend(friend.getUser().getAvatarUrl(), friend.getUser().getCreatedAt(),
|
||||
friend.getUser().getFullname(), friend.getUser().getHandle(), friend.getUser().getId(),
|
||||
friend.getUser().getLang(), friend.getUser().getLastOnlineAt(), friend.getUser().getLocation(),
|
||||
friend.getUser().getMetadata(), friend.getUser().getTimezone(), friend.getUser().getUpdatedAt(),
|
||||
Friend.FriendType.fromLong(friend.getState()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultFriendsAddMessage implements FriendsAddMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultFriendsBlockMessage implements FriendsBlockMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultFriendsListMessage implements FriendsListMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultFriendsRemoveMessage implements FriendsRemoveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultGroup implements Group {
|
||||
|
||||
private final String id;
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
private final boolean priv;
|
||||
private final String creatorId;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String avatarUrl;
|
||||
private final String lang;
|
||||
private final long utcOffsetMs;
|
||||
private final String metadata;
|
||||
private final long count;
|
||||
private final long createdAt;
|
||||
private final long updatedAt;
|
||||
|
||||
public boolean isPrivate() {
|
||||
return priv;
|
||||
}
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static Group fromProto(final @NonNull com.heroiclabs.nakama.Api.Group group) {
|
||||
return new DefaultGroup(group.getId(), group.getPrivate(), group.getCreatorId(), group.getName(),
|
||||
group.getDescription(), group.getAvatarUrl(), group.getLang(), group.getUtcOffsetMs(),
|
||||
group.getMetadata(), group.getCount(), group.getCreatedAt(), group.getUpdatedAt());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultGroupSelf implements GroupSelf {
|
||||
|
||||
private final String id;
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
private final boolean priv;
|
||||
private final String creatorId;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String avatarUrl;
|
||||
private final String lang;
|
||||
private final long utcOffsetMs;
|
||||
private final String metadata;
|
||||
private final long count;
|
||||
private final long createdAt;
|
||||
private final long updatedAt;
|
||||
private final Group.MembershipType state;
|
||||
|
||||
public boolean isPrivate() {
|
||||
return priv;
|
||||
}
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static GroupSelf fromProto(final @NonNull com.heroiclabs.nakama.Api.TGroupsSelf.GroupSelf groupSelf) {
|
||||
return new DefaultGroupSelf(groupSelf.getGroup().getId(), groupSelf.getGroup().getPrivate(),
|
||||
groupSelf.getGroup().getCreatorId(), groupSelf.getGroup().getName(),
|
||||
groupSelf.getGroup().getDescription(), groupSelf.getGroup().getAvatarUrl(),
|
||||
groupSelf.getGroup().getLang(), groupSelf.getGroup().getUtcOffsetMs(),
|
||||
groupSelf.getGroup().getMetadata(), groupSelf.getGroup().getCount(),
|
||||
groupSelf.getGroup().getCreatedAt(), groupSelf.getGroup().getUpdatedAt(),
|
||||
Group.MembershipType.fromLong(groupSelf.getState()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupUser implements GroupUser {
|
||||
|
||||
private final String avatarUrl;
|
||||
|
||||
private final long createdAt;
|
||||
|
||||
private final String fullname;
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
private final long lastOnlineAt;
|
||||
|
||||
private final String location;
|
||||
|
||||
private final String metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
private final Group.MembershipType state;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static GroupUser fromProto(final @NonNull com.heroiclabs.nakama.Api.GroupUser groupUser) {
|
||||
return new DefaultGroupUser(groupUser.getUser().getAvatarUrl(), groupUser.getUser().getCreatedAt(),
|
||||
groupUser.getUser().getFullname(), groupUser.getUser().getHandle(), groupUser.getUser().getId(),
|
||||
groupUser.getUser().getLang(), groupUser.getUser().getLastOnlineAt(),
|
||||
groupUser.getUser().getLocation(), groupUser.getUser().getMetadata(),
|
||||
groupUser.getUser().getTimezone(), groupUser.getUser().getUpdatedAt(),
|
||||
Group.MembershipType.fromLong(groupUser.getState()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupUsersAddMessage implements GroupUsersAddMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupUsersKickMessage implements GroupUsersKickMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupUsersListMessage implements GroupUsersListMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupUsersPromoteMessage implements GroupUsersPromoteMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsCreateMessage implements GroupsCreateMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsFetchMessage implements GroupsFetchMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsJoinMessage implements GroupsJoinMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsLeaveMessage implements GroupsLeaveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsListMessage implements GroupsListMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsRemoveMessage implements GroupsRemoveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsSelfListMessage implements GroupsSelfListMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultGroupsUpdateMessage implements GroupsUpdateMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboard implements Leaderboard {
|
||||
private final String id;
|
||||
private final boolean authoritative;
|
||||
private final SortOrder sort;
|
||||
private final long count;
|
||||
private final String resetSchedule;
|
||||
private final String metadata;
|
||||
private final String nextId;
|
||||
private final String prevId;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static Leaderboard fromProto(final @NonNull com.heroiclabs.nakama.Api.Leaderboard leaderboard) {
|
||||
return new DefaultLeaderboard(
|
||||
leaderboard.getId(),
|
||||
leaderboard.getAuthoritative(),
|
||||
Leaderboard.SortOrder.fromLong(leaderboard.getSort()),
|
||||
leaderboard.getCount(),
|
||||
leaderboard.getResetSchedule(),
|
||||
leaderboard.getMetadata(),
|
||||
leaderboard.getNextId(),
|
||||
leaderboard.getPrevId()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboardRecord implements LeaderboardRecord {
|
||||
private final String leaderboardId;
|
||||
private final String ownerId;
|
||||
private final String handle;
|
||||
private final String lang;
|
||||
private final String location;
|
||||
private final String timezone;
|
||||
private final long rank;
|
||||
private final long score;
|
||||
private final long numScore;
|
||||
private final String metadata;
|
||||
private final long rankedAt;
|
||||
private final long updatedAt;
|
||||
private final long expiresAt;
|
||||
|
||||
static LeaderboardRecord fromProto(final @NonNull com.heroiclabs.nakama.Api.LeaderboardRecord record) {
|
||||
return new DefaultLeaderboardRecord(
|
||||
record.getLeaderboardId(),
|
||||
record.getOwnerId(),
|
||||
record.getHandle(),
|
||||
record.getLang(),
|
||||
record.getLocation(),
|
||||
record.getTimezone(),
|
||||
record.getRank(),
|
||||
record.getScore(),
|
||||
record.getNumScore(),
|
||||
record.getMetadata(),
|
||||
record.getRankedAt(),
|
||||
record.getUpdatedAt(),
|
||||
record.getExpiresAt()
|
||||
);
|
||||
}
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboardRecordWriteMessage implements LeaderboardRecordWriteMessage {
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboardRecordsFetchMessage implements LeaderboardRecordsFetchMessage {
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboardRecordsListMessage implements LeaderboardRecordsListMessage {
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboardsListMessage implements LeaderboardsListMessage {
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatch implements Match {
|
||||
private final String id;
|
||||
private final List<UserPresence> presence;
|
||||
private final UserPresence self;
|
||||
|
||||
static Match fromProto(final @NonNull com.heroiclabs.nakama.Api.TMatch match) {
|
||||
return DefaultMatch.fromProto(match.getMatch());
|
||||
}
|
||||
|
||||
static Match fromProto(final @NonNull com.heroiclabs.nakama.Api.Match match) {
|
||||
List<UserPresence> userPresences = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : match.getPresencesList()) {
|
||||
userPresences.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultMatch(match.getMatchId(), userPresences, DefaultUserPresence.fromProto(match.getSelf()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchCreateMessage implements MatchCreateMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchData implements MatchData {
|
||||
private final String id;
|
||||
private final byte[] data;
|
||||
private final long opCode;
|
||||
private final UserPresence presence;
|
||||
|
||||
static MatchData fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchData matchData) {
|
||||
return new DefaultMatchData(matchData.getMatchId(), matchData.getData().toByteArray(), matchData.getOpCode(), DefaultUserPresence.fromProto(matchData.getPresence()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchDataSendMessage implements MatchDataSendMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes() {
|
||||
return payload.clone().build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultMatchPresence implements MatchPresence {
|
||||
|
||||
private final String id;
|
||||
private final List<UserPresence> join;
|
||||
private final List<UserPresence> leave;
|
||||
|
||||
static MatchPresence fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchPresence matchPresence) {
|
||||
List<UserPresence> joins = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : matchPresence.getJoinsList()) {
|
||||
joins.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
List<UserPresence> leaves = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : matchPresence.getLeavesList()) {
|
||||
leaves.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultMatchPresence(matchPresence.getMatchId(), joins, leaves);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchToken implements MatchToken {
|
||||
private final String token;
|
||||
|
||||
static MatchToken fromProto(final @NonNull String token) {
|
||||
return new DefaultMatchToken(token);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchesJoinMessage implements MatchesJoinMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchesLeaveMessage implements MatchesLeaveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeAddMessage implements MatchmakeAddMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeCheckFilter implements MatchmakeCheckFilter {
|
||||
private final boolean value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeMatched implements MatchmakeMatched {
|
||||
private final MatchmakeTicket ticket;
|
||||
private final List<UserPresence> presence;
|
||||
private final MatchToken token;
|
||||
private final UserPresence self;
|
||||
private final List<MatchmakeUserProperty> properties;
|
||||
|
||||
static MatchmakeMatched fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeMatched matched) {
|
||||
List<UserPresence> userPresences = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : matched.getPresencesList()) {
|
||||
userPresences.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
List<MatchmakeUserProperty> userProperties = new ArrayList<MatchmakeUserProperty>();
|
||||
for (com.heroiclabs.nakama.Api.MatchmakeMatched.UserProperty u : matched.getPropertiesList()) {
|
||||
userProperties.add(DefaultMatchmakeUserProperty.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultMatchmakeMatched(
|
||||
DefaultMatchmakeTicket.fromProto(matched.getTicket()),
|
||||
userPresences,
|
||||
DefaultMatchToken.fromProto(matched.getToken()),
|
||||
DefaultUserPresence.fromProto(matched.getSelf()),
|
||||
userProperties
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeRangeFilter implements MatchmakeRangeFilter {
|
||||
private final long lowerbound;
|
||||
private final long upperbound;
|
||||
|
||||
static MatchmakeRangeFilter fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeFilter.RangeFilter filter) {
|
||||
return new DefaultMatchmakeRangeFilter(filter.getLowerBound(), filter.getUpperBound());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeRemoveMessage implements MatchmakeRemoveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeTermFilter implements MatchmakeTermFilter {
|
||||
private final List<String> terms;
|
||||
private final boolean matchingAllTerms;
|
||||
|
||||
static MatchmakeTermFilter fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeFilter.TermFilter filter) {
|
||||
return new DefaultMatchmakeTermFilter(filter.getTermsList(), filter.getMatchAllTerms());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeTicket implements MatchmakeTicket {
|
||||
private final String ticket;
|
||||
|
||||
static MatchmakeTicket fromProto(final @NonNull com.heroiclabs.nakama.Api.TMatchmakeTicket matchmakeTicket) {
|
||||
return new DefaultMatchmakeTicket(matchmakeTicket.getTicket());
|
||||
}
|
||||
|
||||
static MatchmakeTicket fromProto(final @NonNull String matchmakeTicket) {
|
||||
return new DefaultMatchmakeTicket(matchmakeTicket);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeUserProperty implements MatchmakeUserProperty {
|
||||
private final String userId;
|
||||
private final Map<String, Object> properties;
|
||||
private final Map<String, MatchmakeFilter> filters;
|
||||
|
||||
static DefaultMatchmakeUserProperty fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeMatched.UserProperty p) {
|
||||
Map<String, Object> props = new HashMap<>();
|
||||
for (com.heroiclabs.nakama.Api.PropertyPair pp : p.getPropertiesList()) {
|
||||
switch (pp.getValueCase()) {
|
||||
case INTVALUE:
|
||||
props.put(pp.getKey(), pp.getIntValue());
|
||||
break;
|
||||
case BOOLVALUE:
|
||||
props.put(pp.getKey(), pp.getBoolValue());
|
||||
break;
|
||||
case STRINGSET:
|
||||
props.put(pp.getKey(), pp.getStringSet().getValuesList());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, MatchmakeFilter> filters = new HashMap<>();
|
||||
for (com.heroiclabs.nakama.Api.MatchmakeFilter f : p.getFiltersList()) {
|
||||
switch (f.getValueCase()) {
|
||||
case TERM:
|
||||
filters.put(f.getName(), DefaultMatchmakeTermFilter.fromProto(f.getTerm()));
|
||||
break;
|
||||
case RANGE:
|
||||
filters.put(f.getName(), DefaultMatchmakeRangeFilter.fromProto(f.getRange()));
|
||||
break;
|
||||
case CHECK:
|
||||
filters.put(f.getName(), new DefaultMatchmakeCheckFilter(f.getCheck()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new DefaultMatchmakeUserProperty(p.getUserId(), props, filters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultNotification implements Notification {
|
||||
private final String id;
|
||||
private final String subject;
|
||||
private final String content;
|
||||
private final long code;
|
||||
private final String senderId;
|
||||
private final long createdAt;
|
||||
private final long expiresAt;
|
||||
private final boolean persistent;
|
||||
|
||||
static Notification fromProto(final @NonNull com.heroiclabs.nakama.Api.Notification notification) {
|
||||
return new DefaultNotification(notification.getId(), notification.getSubject(), notification.getContent(),
|
||||
notification.getCode(), notification.getSenderId(), notification.getCreatedAt(),
|
||||
notification.getExpiresAt(), notification.getPersistent());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultNotificationsListMessage implements NotificationsListMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultNotificationsRemoveMessage implements NotificationsRemoveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,9 +29,9 @@ class DefaultRecordId implements RecordId {
|
||||
|
||||
private final String key;
|
||||
|
||||
private final byte[] version;
|
||||
private final String version;
|
||||
|
||||
static RecordId fromProto(final @NonNull com.heroiclabs.nakama.Api.TStorageKeys.StorageKey key) {
|
||||
return new DefaultRecordId(key.getBucket(), key.getCollection(), key.getRecord(), key.getVersion().toByteArray());
|
||||
return new DefaultRecordId(key.getBucket(), key.getCollection(), key.getRecord(), key.getVersion());
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,15 @@ class DefaultRpcResult implements RpcResult {
|
||||
|
||||
private final String id;
|
||||
|
||||
private final byte[] payload;
|
||||
private final String payload;
|
||||
|
||||
@Override
|
||||
public <T> T getPayload(Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(payload), clazz);
|
||||
return DefaultClient.GSON.fromJson(payload, clazz);
|
||||
}
|
||||
|
||||
static RpcResult fromProto(final @NonNull com.heroiclabs.nakama.Api.TRpc rpc) {
|
||||
return new DefaultRpcResult(rpc.getId(), rpc.getPayload().toByteArray());
|
||||
return new DefaultRpcResult(rpc.getId(), rpc.getPayload());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class DefaultSelf implements Self {
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
@@ -41,7 +41,7 @@ class DefaultSelf implements Self {
|
||||
|
||||
private final String location;
|
||||
|
||||
private final byte[] metadata;
|
||||
private final String metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
@@ -64,14 +64,14 @@ class DefaultSelf implements Self {
|
||||
private final boolean verified;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static Self fromProto(final @NonNull com.heroiclabs.nakama.Api.Self self) {
|
||||
return new DefaultSelf(self.getUser().getAvatarUrl(), self.getUser().getCreatedAt(),
|
||||
self.getUser().getFullname(), self.getUser().getHandle(), self.getUser().getId().toByteArray(),
|
||||
self.getUser().getFullname(), self.getUser().getHandle(), self.getUser().getId(),
|
||||
self.getUser().getLang(), self.getUser().getLastOnlineAt(), self.getUser().getLocation(),
|
||||
self.getUser().getMetadata().toByteArray(), self.getUser().getTimezone(), self.getUser().getUpdatedAt(),
|
||||
self.getUser().getMetadata(), self.getUser().getTimezone(), self.getUser().getUpdatedAt(),
|
||||
self.getCustomId(), self.getDeviceIdsList(), self.getEmail(), self.getFacebookId(),
|
||||
self.getGamecenterId(), self.getGoogleId(), self.getSteamId(), self.getVerified());
|
||||
}
|
||||
|
||||
@@ -21,12 +21,10 @@ import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.ByteBuffer;
|
||||
import okio.*;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@@ -38,7 +36,7 @@ public class DefaultSession implements Session {
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
|
||||
private final String token;
|
||||
|
||||
@@ -54,12 +52,7 @@ public class DefaultSession implements Session {
|
||||
createdAt = System.currentTimeMillis();
|
||||
expiresAt = Math.round(((Double) jsonMap.get("exp")) * 1000L);
|
||||
handle = jsonMap.get("han").toString();
|
||||
|
||||
final UUID uid = UUID.fromString(jsonMap.get("uid").toString());
|
||||
final ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
||||
bb.putLong(uid.getMostSignificantBits());
|
||||
bb.putLong(uid.getLeastSignificantBits());
|
||||
id = bb.array();
|
||||
id = jsonMap.get("uid").toString();
|
||||
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@@ -37,23 +37,23 @@ class DefaultStorageRecord implements StorageRecord {
|
||||
|
||||
private final PermissionWrite permissionWrite;
|
||||
|
||||
private final byte[] value;
|
||||
private final String value;
|
||||
|
||||
private final byte[] version;
|
||||
private final String version;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
private final byte[] userId;
|
||||
private final String userId;
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(value), clazz);
|
||||
return DefaultClient.GSON.fromJson(value, clazz);
|
||||
}
|
||||
|
||||
static StorageRecord fromProto(final @NonNull com.heroiclabs.nakama.Api.TStorageData.StorageData data) {
|
||||
return new DefaultStorageRecord(data.getBucket(), data.getCreatedAt(), data.getCollection(),
|
||||
data.getExpiresAt(), data.getRecord(), PermissionRead.fromInt(data.getPermissionRead()),
|
||||
PermissionWrite.fromInt(data.getPermissionWrite()), data.getValue().toByteArray(),
|
||||
data.getVersion().toByteArray(), data.getUpdatedAt(), data.getUserId().toByteArray());
|
||||
PermissionWrite.fromInt(data.getPermissionWrite()), data.getValue(),
|
||||
data.getVersion(), data.getUpdatedAt(), data.getUserId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopic implements Topic {
|
||||
private final TopicId topicId;
|
||||
private final List<UserPresence> presences;
|
||||
private final UserPresence self;
|
||||
|
||||
static Topic fromProto(final @NonNull com.heroiclabs.nakama.Api.TTopics.Topic topic) {
|
||||
List<UserPresence> userPresences = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : topic.getPresencesList()) {
|
||||
userPresences.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultTopic(DefaultTopicId.fromProto(topic.getTopic()), userPresences, DefaultUserPresence.fromProto(topic.getSelf()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicId implements TopicId {
|
||||
private final String Id;
|
||||
private final TopicType topicType;
|
||||
|
||||
static TopicId fromProto(final @NonNull com.heroiclabs.nakama.Api.TopicId topicId) {
|
||||
switch (topicId.getIdCase()) {
|
||||
case DM:
|
||||
return new DefaultTopicId(topicId.getDm(), TopicType.DirectMessage);
|
||||
case ROOM:
|
||||
return new DefaultTopicId(topicId.getRoom(), TopicType.Room);
|
||||
case GROUP_ID:
|
||||
return new DefaultTopicId(topicId.getGroupId(), TopicType.Group);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicJoinMessage implements TopicJoinMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicLeaveMessage implements TopicLeaveMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultTopicMessage implements TopicMessage {
|
||||
private final TopicId topic;
|
||||
private final String userId;
|
||||
private final String messageId;
|
||||
private final long createdAt;
|
||||
private final long expiresAt;
|
||||
private final String handle;
|
||||
private final TopicMessageType type;
|
||||
private final String data;
|
||||
|
||||
static TopicMessage fromProto(final @NonNull com.heroiclabs.nakama.Api.TopicMessage message) {
|
||||
return new DefaultTopicMessage(
|
||||
DefaultTopicId.fromProto(message.getTopic()),
|
||||
message.getUserId(),
|
||||
message.getMessageId(),
|
||||
message.getCreatedAt(),
|
||||
message.getExpiresAt(),
|
||||
message.getHandle(),
|
||||
TopicMessageType.fromProto((int)message.getType()),
|
||||
message.getData()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicMessageAck implements TopicMessageAck {
|
||||
private final String messageId;
|
||||
private final String handle;
|
||||
private final long createdAt;
|
||||
private final long expiresAt;
|
||||
|
||||
static TopicMessageAck fromProto(final @NonNull com.heroiclabs.nakama.Api.TTopicMessageAck ack) {
|
||||
return new DefaultTopicMessageAck(ack.getMessageId(), ack.getHandle(), ack.getCreatedAt(), ack.getExpiresAt());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicMessageSendMessage implements TopicMessageSendMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicMessagesListMessage implements TopicMessagesListMessage {
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultTopicPresence implements TopicPresence {
|
||||
|
||||
private final TopicId topic;
|
||||
private final List<UserPresence> join;
|
||||
private final List<UserPresence> leave;
|
||||
|
||||
static TopicPresence fromProto(final @NonNull com.heroiclabs.nakama.Api.TopicPresence topicPresence) {
|
||||
List<UserPresence> joins = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : topicPresence.getJoinsList()) {
|
||||
joins.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
List<UserPresence> leaves = new ArrayList<UserPresence>();
|
||||
for (com.heroiclabs.nakama.Api.UserPresence u : topicPresence.getLeavesList()) {
|
||||
leaves.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultTopicPresence(DefaultTopicId.fromProto(topicPresence.getTopic()), joins, leaves);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class DefaultUser implements User {
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
@@ -39,21 +39,21 @@ class DefaultUser implements User {
|
||||
|
||||
private final String location;
|
||||
|
||||
private final byte[] metadata;
|
||||
private final String metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static User fromProto(final @NonNull com.heroiclabs.nakama.Api.User user) {
|
||||
return new DefaultUser(user.getAvatarUrl(), user.getCreatedAt(),
|
||||
user.getFullname(), user.getHandle(), user.getId().toByteArray(),
|
||||
user.getFullname(), user.getHandle(), user.getId(),
|
||||
user.getLang(), user.getLastOnlineAt(), user.getLocation(),
|
||||
user.getMetadata().toByteArray(), user.getTimezone(), user.getUpdatedAt());
|
||||
user.getMetadata(), user.getTimezone(), user.getUpdatedAt());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultUserPresence implements UserPresence {
|
||||
private final String userId;
|
||||
private final String sessionId;
|
||||
private final String handle;
|
||||
|
||||
static UserPresence fromProto(final @NonNull com.heroiclabs.nakama.Api.UserPresence presence) {
|
||||
return new DefaultUserPresence(presence.getUserId(), presence.getSessionId(), presence.getHandle());
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,13 @@ public abstract class Error extends Exception {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The error message to construct with.
|
||||
*/
|
||||
public Error(final @NonNull String message, final @NonNull Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error code for the problem.
|
||||
*/
|
||||
@@ -108,4 +115,9 @@ public abstract class Error extends Exception {
|
||||
* @return The code for the error.
|
||||
*/
|
||||
public abstract ErrorCode getCode();
|
||||
|
||||
/**
|
||||
* @return The collation ID associated with this error. Could be null.
|
||||
*/
|
||||
public abstract String getCollationId();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface Friend extends User {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
enum FriendType {
|
||||
/** A standard friend relationship. */
|
||||
FRIEND(0),
|
||||
/** An incoming friend request. */
|
||||
INVITE(1),
|
||||
/** A sent friend request. */
|
||||
INVITED(2),
|
||||
/** A blocked user. */
|
||||
BLOCKED(3);
|
||||
|
||||
@Getter
|
||||
private final int code;
|
||||
|
||||
static Friend.FriendType fromLong(final long state) {
|
||||
switch ((int) state) {
|
||||
case 0:
|
||||
return FRIEND;
|
||||
case 1:
|
||||
return INVITE;
|
||||
case 2:
|
||||
return INVITED;
|
||||
case 3:
|
||||
return BLOCKED;
|
||||
default:
|
||||
String message = String.format("Unrecognised friend state type: %s", state);
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An enum representing the type of relationship to this friend.
|
||||
*/
|
||||
FriendType getState();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface FriendsAddMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static FriendsAddMessage.Builder newBuilder() {
|
||||
return new FriendsAddMessage.Builder(com.heroiclabs.nakama.Api.TFriendsAdd.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TFriendsAdd.Builder adds;
|
||||
|
||||
public FriendsAddMessage.Builder id(final @NonNull String userId) {
|
||||
this.adds.addFriends(com.heroiclabs.nakama.Api.TFriendsAdd.FriendsAdd.newBuilder()
|
||||
.setUserId(userId)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public FriendsAddMessage.Builder handle(final @NonNull String handle) {
|
||||
this.adds.addFriends(com.heroiclabs.nakama.Api.TFriendsAdd.FriendsAdd.newBuilder()
|
||||
.setHandle(handle)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public FriendsAddMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setFriendsAdd(adds);
|
||||
return new DefaultFriendsAddMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface FriendsBlockMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static FriendsBlockMessage.Builder newBuilder() {
|
||||
return new FriendsBlockMessage.Builder(com.heroiclabs.nakama.Api.TFriendsBlock.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TFriendsBlock.Builder blocks;
|
||||
|
||||
public FriendsBlockMessage.Builder id(final @NonNull String userId) {
|
||||
this.blocks.addUserIds(userId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FriendsBlockMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setFriendsBlock(blocks);
|
||||
return new DefaultFriendsBlockMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface FriendsListMessage extends CollatedMessage<ResultSet<Friend>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static FriendsListMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setFriendsList(com.heroiclabs.nakama.Api.TFriendsList.newBuilder().build());
|
||||
return new DefaultFriendsListMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface FriendsRemoveMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static FriendsRemoveMessage.Builder newBuilder() {
|
||||
return new FriendsRemoveMessage.Builder(com.heroiclabs.nakama.Api.TFriendsRemove.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TFriendsRemove.Builder removes;
|
||||
|
||||
public FriendsRemoveMessage.Builder id(final @NonNull String userId) {
|
||||
this.removes.addUserIds(userId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FriendsRemoveMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setFriendsRemove(removes);
|
||||
return new DefaultFriendsRemoveMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Represents a group with user members.
|
||||
*/
|
||||
public interface Group {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
enum MembershipType {
|
||||
/** The user is a group administrator. */
|
||||
ADMIN(0),
|
||||
/** The user is a regular group member. */
|
||||
MEMBER(1),
|
||||
/** The user has submitted a request to join the group. */
|
||||
JOIN(2);
|
||||
|
||||
@Getter
|
||||
private final int code;
|
||||
|
||||
static Group.MembershipType fromLong(final long state) {
|
||||
switch ((int) state) {
|
||||
case 0:
|
||||
return ADMIN;
|
||||
case 1:
|
||||
return MEMBER;
|
||||
case 2:
|
||||
return JOIN;
|
||||
default:
|
||||
String message = String.format("Unrecognised group state type: %s", state);
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The group unique ID.
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return true if it's a private group requiring approval to join, false otherwise.
|
||||
*/
|
||||
boolean isPrivate();
|
||||
|
||||
/**
|
||||
* @return The ID of the user that created the group.
|
||||
*/
|
||||
String getCreatorId();
|
||||
|
||||
/**
|
||||
* @return The name of the group.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return The group's description.
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* @return The group's avatar URL.
|
||||
*/
|
||||
String getAvatarUrl();
|
||||
|
||||
/**
|
||||
* @return The group's lang tag.
|
||||
*/
|
||||
String getLang();
|
||||
|
||||
/**
|
||||
* @return The offset in milliseconds representing the group's timezone relative to UTC.
|
||||
*/
|
||||
long getUtcOffsetMs();
|
||||
|
||||
/**
|
||||
* @return The metadata stored for the group.
|
||||
*/
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
* @param <T> A type parameter for the metadata to decode.
|
||||
* @return The decoded metadata for the group.
|
||||
*/
|
||||
<T> T getMetadata(final Class<T> clazz);
|
||||
|
||||
/**
|
||||
* @return The number of group members.
|
||||
*/
|
||||
long getCount();
|
||||
|
||||
/**
|
||||
* @return The UTC milliseconds timestamp when the group was created.
|
||||
*/
|
||||
long getCreatedAt();
|
||||
|
||||
/**
|
||||
* @return The UTC milliseconds timestamp when the group data was last updated.
|
||||
*/
|
||||
long getUpdatedAt();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
/**
|
||||
* Represents a group with additional information about the current user's membership type.
|
||||
*/
|
||||
public interface GroupSelf extends Group {
|
||||
|
||||
/**
|
||||
* @return An enum representing the user's relationship to the group.
|
||||
*/
|
||||
Group.MembershipType getState();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
/**
|
||||
* Represents details about a user belonging to a group.
|
||||
*/
|
||||
public interface GroupUser extends User {
|
||||
|
||||
/**
|
||||
* @return An enum representing the user's relationship to the group.
|
||||
*/
|
||||
Group.MembershipType getState();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupUsersAddMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupUsersAddMessage.Builder newBuilder() {
|
||||
return new GroupUsersAddMessage.Builder(com.heroiclabs.nakama.Api.TGroupUsersAdd.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupUsersAdd.Builder adds;
|
||||
|
||||
public GroupUsersAddMessage.Builder add(final @NonNull String groupId, final @NonNull String userId) {
|
||||
this.adds.addGroupUsers(com.heroiclabs.nakama.Api.TGroupUsersAdd.GroupUserAdd.newBuilder()
|
||||
.setGroupId(groupId)
|
||||
.setUserId(userId)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupUsersAddMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupUsersAdd(adds);
|
||||
return new DefaultGroupUsersAddMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupUsersKickMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupUsersKickMessage.Builder newBuilder() {
|
||||
return new GroupUsersKickMessage.Builder(com.heroiclabs.nakama.Api.TGroupUsersKick.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupUsersKick.Builder kicks;
|
||||
|
||||
public GroupUsersKickMessage.Builder add(final @NonNull String groupId, final @NonNull String userId) {
|
||||
this.kicks.addGroupUsers(com.heroiclabs.nakama.Api.TGroupUsersKick.GroupUserKick.newBuilder()
|
||||
.setGroupId(groupId)
|
||||
.setUserId(userId)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupUsersKickMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupUsersKick(kicks);
|
||||
return new DefaultGroupUsersKickMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupUsersListMessage extends CollatedMessage<ResultSet<GroupUser>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupUsersListMessage build(final @NonNull String groupId) {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupUsersList(com.heroiclabs.nakama.Api.TGroupUsersList.newBuilder()
|
||||
.setGroupId(groupId)
|
||||
.build());
|
||||
return new DefaultGroupUsersListMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupUsersPromoteMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupUsersPromoteMessage.Builder newBuilder() {
|
||||
return new GroupUsersPromoteMessage.Builder(com.heroiclabs.nakama.Api.TGroupUsersPromote.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupUsersPromote.Builder promotes;
|
||||
|
||||
public GroupUsersPromoteMessage.Builder add(final @NonNull String groupId, final @NonNull String userId) {
|
||||
this.promotes.addGroupUsers(com.heroiclabs.nakama.Api.TGroupUsersPromote.GroupUserPromote.newBuilder()
|
||||
.setGroupId(groupId)
|
||||
.setUserId(userId)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupUsersPromoteMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupUsersPromote(promotes);
|
||||
return new DefaultGroupUsersPromoteMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsCreateMessage extends CollatedMessage<ResultSet<Group>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsCreateMessage.Builder newBuilder() {
|
||||
return new GroupsCreateMessage.Builder(com.heroiclabs.nakama.Api.TGroupsCreate.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsCreate.Builder creates;
|
||||
|
||||
public GroupsCreateMessage.Builder group(final @NonNull String name, final String description,
|
||||
final String avatarUrl, final String lang,
|
||||
final @NonNull String metadata, final boolean isPrivate) {
|
||||
com.heroiclabs.nakama.Api.TGroupsCreate.GroupCreate.Builder g =
|
||||
com.heroiclabs.nakama.Api.TGroupsCreate.GroupCreate.newBuilder()
|
||||
.setName(name)
|
||||
.setMetadata(metadata)
|
||||
.setPrivate(isPrivate);
|
||||
if (description != null) {
|
||||
g.setDescription(description);
|
||||
}
|
||||
if (avatarUrl != null) {
|
||||
g.setAvatarUrl(avatarUrl);
|
||||
}
|
||||
if (lang != null) {
|
||||
g.setLang(lang);
|
||||
}
|
||||
this.creates.addGroups(g.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsCreateMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsCreate(creates);
|
||||
return new DefaultGroupsCreateMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsFetchMessage extends CollatedMessage<ResultSet<Group>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsFetchMessage.Builder newBuilder() {
|
||||
return new GroupsFetchMessage.Builder(com.heroiclabs.nakama.Api.TGroupsFetch.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsFetch.Builder fetches;
|
||||
|
||||
public GroupsFetchMessage.Builder id(final @NonNull String groupId) {
|
||||
this.fetches.addGroups(com.heroiclabs.nakama.Api.TGroupsFetch.GroupFetch.newBuilder()
|
||||
.setGroupId(groupId)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsFetchMessage.Builder name(final @NonNull String name) {
|
||||
this.fetches.addGroups(com.heroiclabs.nakama.Api.TGroupsFetch.GroupFetch.newBuilder()
|
||||
.setName(name)
|
||||
.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsFetchMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsFetch(fetches);
|
||||
return new DefaultGroupsFetchMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsJoinMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsJoinMessage.Builder newBuilder() {
|
||||
return new GroupsJoinMessage.Builder(com.heroiclabs.nakama.Api.TGroupsJoin.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsJoin.Builder joins;
|
||||
|
||||
public GroupsJoinMessage.Builder id(final @NonNull String groupId) {
|
||||
this.joins.addGroupIds(groupId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsJoinMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsJoin(joins);
|
||||
return new DefaultGroupsJoinMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsLeaveMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsLeaveMessage.Builder newBuilder() {
|
||||
return new GroupsLeaveMessage.Builder(com.heroiclabs.nakama.Api.TGroupsLeave.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsLeave.Builder leaves;
|
||||
|
||||
public GroupsLeaveMessage.Builder id(final @NonNull String groupId) {
|
||||
this.leaves.addGroupIds(groupId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsLeaveMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsLeave(leaves);
|
||||
return new DefaultGroupsLeaveMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsListMessage extends CollatedMessage<ResultSet<Group>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsListMessage.Builder newBuilder() {
|
||||
return new GroupsListMessage.Builder(com.heroiclabs.nakama.Api.TGroupsList.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsList.Builder list;
|
||||
|
||||
public GroupsListMessage.Builder limit(final long limit) {
|
||||
this.list.setPageLimit(limit);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsListMessage.Builder orderAscending(final boolean orderAscending) {
|
||||
this.list.setOrderByAsc(orderAscending);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsListMessage.Builder filterByLang(final @NonNull String lang) {
|
||||
this.list.clearFilter();
|
||||
this.list.setLang(lang);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsListMessage.Builder filterByCreatedAt(final long createdAt) {
|
||||
this.list.clearFilter();
|
||||
this.list.setCreatedAt(createdAt);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsListMessage.Builder filterByCount(final long count) {
|
||||
this.list.clearFilter();
|
||||
this.list.setCount(count);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsListMessage.Builder cursor(final @NonNull Cursor cursor) {
|
||||
this.list.setCursor(cursor.getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsListMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsList(list);
|
||||
return new DefaultGroupsListMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsRemoveMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsRemoveMessage.Builder newBuilder() {
|
||||
return new GroupsRemoveMessage.Builder(com.heroiclabs.nakama.Api.TGroupsRemove.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsRemove.Builder removes;
|
||||
|
||||
public GroupsRemoveMessage.Builder id(final @NonNull String groupId) {
|
||||
this.removes.addGroupIds(groupId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsRemoveMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsRemove(removes);
|
||||
return new DefaultGroupsRemoveMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsSelfListMessage extends CollatedMessage<ResultSet<GroupSelf>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsSelfListMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsSelfList(com.heroiclabs.nakama.Api.TGroupsSelfList.newBuilder().build());
|
||||
return new DefaultGroupsSelfListMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface GroupsUpdateMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static GroupsUpdateMessage.Builder newBuilder() {
|
||||
return new GroupsUpdateMessage.Builder(com.heroiclabs.nakama.Api.TGroupsUpdate.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TGroupsUpdate.Builder updates;
|
||||
|
||||
public GroupsUpdateMessage.Builder group(final @NonNull String groupId,
|
||||
final @NonNull String name, final String description,
|
||||
final String avatarUrl, final String lang,
|
||||
final @NonNull String metadata, final boolean isPrivate) {
|
||||
com.heroiclabs.nakama.Api.TGroupsUpdate.GroupUpdate.Builder g =
|
||||
com.heroiclabs.nakama.Api.TGroupsUpdate.GroupUpdate.newBuilder()
|
||||
.setGroupId(groupId)
|
||||
.setName(name)
|
||||
.setMetadata(metadata)
|
||||
.setPrivate(isPrivate);
|
||||
if (description != null) {
|
||||
g.setDescription(description);
|
||||
}
|
||||
if (avatarUrl != null) {
|
||||
g.setAvatarUrl(avatarUrl);
|
||||
}
|
||||
if (lang != null) {
|
||||
g.setLang(lang);
|
||||
}
|
||||
this.updates.addGroups(g.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupsUpdateMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setGroupsUpdate(updates);
|
||||
return new DefaultGroupsUpdateMessage(payload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* The object which represents a leaderboard object.
|
||||
*/
|
||||
public interface Leaderboard {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
enum SortOrder {
|
||||
ASCENDING(0),
|
||||
DESCENDING(1);
|
||||
|
||||
@Getter
|
||||
private final int code;
|
||||
|
||||
static Leaderboard.SortOrder fromLong(final long sort) {
|
||||
switch ((int) sort) {
|
||||
case 0:
|
||||
return ASCENDING;
|
||||
case 1:
|
||||
return DESCENDING;
|
||||
default:
|
||||
String message = String.format("Unrecognised leaderboard sort order: %s", sort);
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Leaderboard ID.
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return Whether leaderboard is server authoritative or not.
|
||||
*/
|
||||
boolean isAuthoritative();
|
||||
|
||||
/**
|
||||
* @return Sort order for the record.
|
||||
*/
|
||||
SortOrder getSort();
|
||||
|
||||
/**
|
||||
* @return Record count.
|
||||
*/
|
||||
long getCount();
|
||||
|
||||
/**
|
||||
* @return Reset schedule.
|
||||
*/
|
||||
String getResetSchedule();
|
||||
|
||||
/**
|
||||
* @return Metadata associated with the leaderboard.
|
||||
*/
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
* @param <T> A type parameter for the metadata to decode.
|
||||
* @return Metadata associated with the leaderboard.
|
||||
*/
|
||||
<T> T getMetadata(final Class<T> clazz);
|
||||
|
||||
String getNextId();
|
||||
|
||||
String getPrevId();
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object which represents a leaderboard record.
|
||||
*/
|
||||
public interface LeaderboardRecord {
|
||||
|
||||
/**
|
||||
* @return Leaderboard ID.
|
||||
*/
|
||||
String getLeaderboardId();
|
||||
|
||||
/**
|
||||
* @return User ID that owns this record.
|
||||
*/
|
||||
String getOwnerId();
|
||||
|
||||
/**
|
||||
* @return User handle.
|
||||
*/
|
||||
String getHandle();
|
||||
|
||||
/**
|
||||
* @return Language associated with the record.
|
||||
*/
|
||||
String getLang();
|
||||
|
||||
/**
|
||||
* @return Location associated with the record.
|
||||
*/
|
||||
String getLocation();
|
||||
|
||||
/**
|
||||
* @return Timezone associated with the record.
|
||||
*/
|
||||
String getTimezone();
|
||||
|
||||
long getRank();
|
||||
|
||||
long getScore();
|
||||
|
||||
long getNumScore();
|
||||
|
||||
/**
|
||||
* @return Metadata associated with the leaderboard record.
|
||||
*/
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
* @param <T> A type parameter for the metadata to decode.
|
||||
* @return Metadata associated with the leaderboard.
|
||||
*/
|
||||
<T> T getMetadata(final Class<T> clazz);
|
||||
|
||||
long getRankedAt();
|
||||
|
||||
/**
|
||||
* @return When the record was last updated
|
||||
*/
|
||||
long getUpdatedAt();
|
||||
|
||||
/**
|
||||
* @return When the record expires.
|
||||
*/
|
||||
long getExpiresAt();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface LeaderboardRecordWriteMessage extends CollatedMessage<ResultSet<LeaderboardRecord>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class LeaderboardRecordWrite {
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.Builder write;
|
||||
|
||||
public static LeaderboardRecordWriteMessage.LeaderboardRecordWrite newBuilder(final @NonNull String leaderboardId) {
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.Builder b = com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.newBuilder();
|
||||
b.setLeaderboardId(leaderboardId);
|
||||
return new LeaderboardRecordWriteMessage.LeaderboardRecordWrite(b);
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite location(final @NonNull String location) {
|
||||
write.setLocation(location);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite timezone(final @NonNull String timezone) {
|
||||
write.setTimezone(timezone);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite metadata(final @NonNull String metadata) {
|
||||
write.setMetadata(metadata);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite increment(final long value) {
|
||||
write.setIncr(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite decrement(final long value) {
|
||||
write.setDecr(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite set(final long value) {
|
||||
write.setSet(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite best(final long value) {
|
||||
write.setBest(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
private com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.Builder build() {
|
||||
return write;
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static LeaderboardRecordWriteMessage.Builder newBuilder() {
|
||||
return new LeaderboardRecordWriteMessage.Builder(com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.Builder writes;
|
||||
|
||||
public LeaderboardRecordWriteMessage.Builder add(final @NonNull LeaderboardRecordWrite write) {
|
||||
writes.addRecords(write.build());
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setLeaderboardRecordsWrite(writes);
|
||||
return new DefaultLeaderboardRecordWriteMessage(payload);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface LeaderboardRecordsFetchMessage extends CollatedMessage<ResultSet<LeaderboardRecord>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static LeaderboardRecordsFetchMessage.Builder newBuilder() {
|
||||
return new LeaderboardRecordsFetchMessage.Builder(com.heroiclabs.nakama.Api.TLeaderboardRecordsFetch.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsFetch.Builder fetch;
|
||||
|
||||
public LeaderboardRecordsFetchMessage.Builder fetch(final @NonNull String leaderboardId) {
|
||||
fetch.addLeaderboardIds(leaderboardId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsFetchMessage.Builder limit(final long limit) {
|
||||
fetch.setLimit(limit);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsFetchMessage.Builder cursor(final @NonNull String cursor) {
|
||||
fetch.setCursor(cursor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsFetchMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setLeaderboardRecordsFetch(fetch);
|
||||
return new DefaultLeaderboardRecordsFetchMessage(payload);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LeaderboardRecordsListMessage extends CollatedMessage<ResultSet<LeaderboardRecord>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static LeaderboardRecordsListMessage.Builder newBuilder(final @NonNull String leaderboardId) {
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Builder b = com.heroiclabs.nakama.Api.TLeaderboardRecordsList.newBuilder();
|
||||
b.setLeaderboardId(leaderboardId);
|
||||
return new DefaultLeaderboardRecordsListMessage.Builder(b);
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Builder listing;
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerId(final @NonNull String ownerId) {
|
||||
listing.setOwnerId(ownerId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerIds(final @NonNull List<String> ownerIds) {
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Owners.Builder o = com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Owners.newBuilder();
|
||||
for (String b : ownerIds) {
|
||||
o.addOwnerIds(b);
|
||||
}
|
||||
listing.setOwnerIds(o);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder filterByLang(final @NonNull String lang) {
|
||||
listing.setLang(lang);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder filterByTimezone(final @NonNull String tz) {
|
||||
listing.setTimezone(tz);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder limit(final long limit) {
|
||||
listing.setLimit(limit);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder cursor(final @NonNull Cursor cursor) {
|
||||
listing.setCursor(cursor.getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setLeaderboardRecordsList(listing);
|
||||
return new DefaultLeaderboardRecordsListMessage(payload);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public interface LeaderboardsListMessage extends CollatedMessage<ResultSet<Leaderboard>> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static LeaderboardsListMessage.Builder newBuilder() {
|
||||
return new LeaderboardsListMessage.Builder(com.heroiclabs.nakama.Api.TLeaderboardsList.newBuilder());
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardsList.Builder listing;
|
||||
|
||||
public LeaderboardsListMessage.Builder limit(final long limit) {
|
||||
listing.setLimit(limit);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardsListMessage.Builder addFilter(final @NonNull String leaderboardId) {
|
||||
listing.addFilterLeaderboardId(leaderboardId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardsListMessage.Builder cursor(final @NonNull String cursor) {
|
||||
listing.setCursor(cursor);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardsListMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setLeaderboardsList(listing);
|
||||
return new DefaultLeaderboardsListMessage(payload);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package com.heroiclabs.nakama;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
public interface LogoutMessage extends Message {
|
||||
public interface LogoutMessage extends UncollatedMessage {
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object which represents a match.
|
||||
*/
|
||||
public interface Match {
|
||||
/**
|
||||
* @return Match ID.
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return List of presences in this match.
|
||||
*/
|
||||
List<UserPresence> getPresence();
|
||||
|
||||
/**
|
||||
* @return Match presence for the current user.
|
||||
*/
|
||||
UserPresence getSelf();
|
||||
}
|
||||
Loaded 100 of 165 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user