Compare commits

..
14 Commits
142 changed files with 4542 additions and 391 deletions

No files matched your search

+27
View File
@@ -4,6 +4,33 @@ 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.
+8 -3
View File
@@ -25,7 +25,7 @@ plugins {
}
group = 'com.heroiclabs.nakama'
version = '0.2.0'
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 {
@@ -108,6 +109,10 @@ gitPublish {
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.
@@ -16,6 +16,8 @@
package com.heroiclabs.nakama;
import java.util.List;
/**
* A listener for receiving {@code Client} events.
*/
@@ -27,26 +29,43 @@ public interface ClientListener {
/**
* 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.
@@ -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;
}
}
@@ -252,6 +252,13 @@ public class DefaultClient implements Client {
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;
}
@@ -269,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()));
@@ -281,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;
@@ -317,7 +352,7 @@ public class DefaultClient implements Client {
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().toByteArray()), messages));
def.callback(new DefaultResultSet<TopicMessage>(new DefaultCursor(envelope.getTopicMessages().getCursor()), messages));
break;
case MATCH:
def.callback(DefaultMatch.fromProto(envelope.getMatch()));
@@ -337,17 +372,24 @@ public class DefaultClient implements Client {
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().toByteArray()), leaderboards));
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().toByteArray()), leaderboardRecords));
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;
}
}
@@ -420,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;
}
@@ -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();
}
}
@@ -22,29 +22,29 @@ import lombok.*;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboard implements Leaderboard {
private final byte[] id;
private final String id;
private final boolean authoritative;
private final long sort;
private final SortOrder sort;
private final long count;
private final String resetSchedule;
private final byte[] metadata;
private final byte[] nextId;
private final byte[] prevId;
private final String metadata;
private final String nextId;
private final String prevId;
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
return DefaultClient.GSON.fromJson(metadata, clazz);
}
static Leaderboard fromProto(final @NonNull com.heroiclabs.nakama.Api.Leaderboard leaderboard) {
return new DefaultLeaderboard(
leaderboard.getId().toByteArray(),
leaderboard.getId(),
leaderboard.getAuthoritative(),
leaderboard.getSort(),
Leaderboard.SortOrder.fromLong(leaderboard.getSort()),
leaderboard.getCount(),
leaderboard.getResetSchedule(),
leaderboard.getMetadata().toByteArray(),
leaderboard.getNextId().toByteArray(),
leaderboard.getPrevId().toByteArray()
leaderboard.getMetadata(),
leaderboard.getNextId(),
leaderboard.getPrevId()
);
}
@@ -22,8 +22,8 @@ import lombok.*;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboardRecord implements LeaderboardRecord {
private final byte[] leaderboardId;
private final byte[] ownerId;
private final String leaderboardId;
private final String ownerId;
private final String handle;
private final String lang;
private final String location;
@@ -31,15 +31,15 @@ class DefaultLeaderboardRecord implements LeaderboardRecord {
private final long rank;
private final long score;
private final long numScore;
private final byte[] metadata;
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().toByteArray(),
record.getOwnerId().toByteArray(),
record.getLeaderboardId(),
record.getOwnerId(),
record.getHandle(),
record.getLang(),
record.getLocation(),
@@ -47,7 +47,7 @@ class DefaultLeaderboardRecord implements LeaderboardRecord {
record.getRank(),
record.getScore(),
record.getNumScore(),
record.getMetadata().toByteArray(),
record.getMetadata(),
record.getRankedAt(),
record.getUpdatedAt(),
record.getExpiresAt()
@@ -55,7 +55,7 @@ class DefaultLeaderboardRecord implements LeaderboardRecord {
}
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
return DefaultClient.GSON.fromJson(metadata, clazz);
}
}
@@ -25,7 +25,7 @@ import java.util.List;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatch implements Match {
private final byte[] id;
private final String id;
private final List<UserPresence> presence;
private final UserPresence self;
@@ -39,7 +39,7 @@ class DefaultMatch implements Match {
userPresences.add(DefaultUserPresence.fromProto(u));
}
return new DefaultMatch(match.getMatchId().toByteArray(), userPresences, DefaultUserPresence.fromProto(match.getSelf()));
return new DefaultMatch(match.getMatchId(), userPresences, DefaultUserPresence.fromProto(match.getSelf()));
}
}
@@ -18,20 +18,17 @@ package com.heroiclabs.nakama;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchData implements MatchData {
private final byte[] id;
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().toByteArray(), matchData.getData().toByteArray(), matchData.getOpCode(), DefaultUserPresence.fromProto(matchData.getPresence()));
return new DefaultMatchData(matchData.getMatchId(), matchData.getData().toByteArray(), matchData.getOpCode(), DefaultUserPresence.fromProto(matchData.getPresence()));
}
}
@@ -26,7 +26,7 @@ import java.util.List;
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DefaultMatchPresence implements MatchPresence {
private final byte[] id;
private final String id;
private final List<UserPresence> join;
private final List<UserPresence> leave;
@@ -41,6 +41,6 @@ public class DefaultMatchPresence implements MatchPresence {
leaves.add(DefaultUserPresence.fromProto(u));
}
return new DefaultMatchPresence(matchPresence.getMatchId().toByteArray(), joins, leaves);
return new DefaultMatchPresence(matchPresence.getMatchId(), joins, leaves);
}
}
@@ -22,9 +22,9 @@ import lombok.*;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchToken implements MatchToken {
private final byte[] token;
private final String token;
static MatchToken fromProto(final @NonNull byte[] token) {
static MatchToken fromProto(final @NonNull String token) {
return new DefaultMatchToken(token);
}
}
@@ -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;
}
@@ -29,6 +29,7 @@ class DefaultMatchmakeMatched implements MatchmakeMatched {
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>();
@@ -36,11 +37,17 @@ class DefaultMatchmakeMatched implements MatchmakeMatched {
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().toByteArray()),
DefaultMatchmakeTicket.fromProto(matched.getTicket()),
userPresences,
DefaultMatchToken.fromProto(matched.getToken().toByteArray()),
DefaultUserPresence.fromProto(matched.getSelf())
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,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());
}
}
@@ -22,13 +22,13 @@ import lombok.*;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchmakeTicket implements MatchmakeTicket {
private final byte[] ticket;
private final String ticket;
static MatchmakeTicket fromProto(final @NonNull com.heroiclabs.nakama.Api.TMatchmakeTicket matchmakeTicket) {
return new DefaultMatchmakeTicket(matchmakeTicket.getTicket().toByteArray());
return new DefaultMatchmakeTicket(matchmakeTicket.getTicket());
}
static MatchmakeTicket fromProto(final @NonNull byte[] matchmakeTicket) {
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());
}
}
@@ -22,17 +22,17 @@ import lombok.*;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultTopicId implements TopicId {
private final byte[] Id;
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().toByteArray(), TopicType.DirectMessage);
return new DefaultTopicId(topicId.getDm(), TopicType.DirectMessage);
case ROOM:
return new DefaultTopicId(topicId.getRoom().toByteArray(), TopicType.Room);
return new DefaultTopicId(topicId.getRoom(), TopicType.Room);
case GROUP_ID:
return new DefaultTopicId(topicId.getGroupId().toByteArray(), TopicType.Group);
return new DefaultTopicId(topicId.getGroupId(), TopicType.Group);
default:
return null;
}
@@ -23,24 +23,24 @@ import lombok.*;
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DefaultTopicMessage implements TopicMessage {
private final TopicId topic;
private final byte[] userId;
private final byte[] messageId;
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 byte[] data;
private final String data;
static TopicMessage fromProto(final @NonNull com.heroiclabs.nakama.Api.TopicMessage message) {
return new DefaultTopicMessage(
DefaultTopicId.fromProto(message.getTopic()),
message.getUserId().toByteArray(),
message.getMessageId().toByteArray(),
message.getUserId(),
message.getMessageId(),
message.getCreatedAt(),
message.getExpiresAt(),
message.getHandle(),
TopicMessageType.fromProto((int)message.getType()),
message.getData().toByteArray()
message.getData()
);
}
}
@@ -22,12 +22,12 @@ import lombok.*;
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultTopicMessageAck implements TopicMessageAck {
private final byte[] messageId;
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().toByteArray(), ack.getHandle(), ack.getCreatedAt(), ack.getExpiresAt());
return new DefaultTopicMessageAck(ack.getMessageId(), ack.getHandle(), ack.getCreatedAt(), ack.getExpiresAt());
}
}
@@ -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());
}
}
@@ -18,18 +18,15 @@ package com.heroiclabs.nakama;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultUserPresence implements UserPresence {
private final byte[] userId;
private final byte[] sessionId;
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().toByteArray(), presence.getSessionId().toByteArray(), presence.getHandle());
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);
}
}
}
@@ -16,39 +16,65 @@
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* The object which represents a leaderboard object.
*/
public interface Leaderboard {
/**
* @returns Leaderboard ID
*/
byte[] getId();
@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);
}
}
}
/**
* @returns Whether leaderboard is server authoritative or not.
* @return Leaderboard ID.
*/
String getId();
/**
* @return Whether leaderboard is server authoritative or not.
*/
boolean isAuthoritative();
/**
* @returns Sort order for the record
* @return Sort order for the record.
*/
long getSort();
SortOrder getSort();
/**
* @returns Record count
* @return Record count.
*/
long getCount();
/**
* @returns Reset schedule
* @return Reset schedule.
*/
String getResetSchedule();
/**
* @returns Metadata associated with the leaderboard
* @return Metadata associated with the leaderboard.
*/
byte[] getMetadata();
String getMetadata();
/**
* @param clazz A hint for the type of the class.
@@ -57,7 +83,7 @@ public interface Leaderboard {
*/
<T> T getMetadata(final Class<T> clazz);
byte[] getNextId();
String getNextId();
byte[] getPrevId();
String getPrevId();
}
@@ -24,32 +24,32 @@ import java.util.List;
public interface LeaderboardRecord {
/**
* @returns Leaderboard ID.
* @return Leaderboard ID.
*/
byte[] getLeaderboardId();
String getLeaderboardId();
/**
* @returns User ID that owns this record.
* @return User ID that owns this record.
*/
byte[] getOwnerId();
String getOwnerId();
/**
* @returns User handle.
* @return User handle.
*/
String getHandle();
/**
* @returns Language associated with the record.
* @return Language associated with the record.
*/
String getLang();
/**
* @returns Location associated with the record.
* @return Location associated with the record.
*/
String getLocation();
/**
* @returns Timezone associated with the record.
* @return Timezone associated with the record.
*/
String getTimezone();
@@ -60,9 +60,9 @@ public interface LeaderboardRecord {
long getNumScore();
/**
* @returns Metadata associated with the leaderboard record.
* @return Metadata associated with the leaderboard record.
*/
byte[] getMetadata();
String getMetadata();
/**
* @param clazz A hint for the type of the class.
@@ -74,12 +74,12 @@ public interface LeaderboardRecord {
long getRankedAt();
/**
* @returns When the record was last updated
* @return When the record was last updated
*/
long getUpdatedAt();
/**
* @returns When the record expires.
* @return When the record expires.
*/
long getExpiresAt();
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -28,9 +27,9 @@ public interface LeaderboardRecordWriteMessage extends CollatedMessage<ResultSet
private final @NonNull
com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.Builder write;
public static LeaderboardRecordWriteMessage.LeaderboardRecordWrite newBuilder(final @NonNull byte[] leaderboardId) {
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(ByteString.copyFrom(leaderboardId));
b.setLeaderboardId(leaderboardId);
return new LeaderboardRecordWriteMessage.LeaderboardRecordWrite(b);
}
@@ -44,8 +43,8 @@ public interface LeaderboardRecordWriteMessage extends CollatedMessage<ResultSet
return this;
}
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite metadata(final @NonNull byte[] metadata) {
write.setMetadata(ByteString.copyFrom(metadata));
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite metadata(final @NonNull String metadata) {
write.setMetadata(metadata);
return this;
}
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -33,8 +32,8 @@ public interface LeaderboardRecordsFetchMessage extends CollatedMessage<ResultSe
private final @NonNull
com.heroiclabs.nakama.Api.TLeaderboardRecordsFetch.Builder fetch;
public LeaderboardRecordsFetchMessage.Builder fetch(final @NonNull byte[] leaderboardId) {
fetch.addLeaderboardIds(ByteString.copyFrom(leaderboardId));
public LeaderboardRecordsFetchMessage.Builder fetch(final @NonNull String leaderboardId) {
fetch.addLeaderboardIds(leaderboardId);
return this;
}
@@ -43,8 +42,8 @@ public interface LeaderboardRecordsFetchMessage extends CollatedMessage<ResultSe
return this;
}
public LeaderboardRecordsFetchMessage.Builder cursor(final @NonNull byte[] cursor) {
fetch.setCursor(ByteString.copyFrom(cursor));
public LeaderboardRecordsFetchMessage.Builder cursor(final @NonNull String cursor) {
fetch.setCursor(cursor);
return this;
}
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -28,24 +27,24 @@ public interface LeaderboardRecordsListMessage extends CollatedMessage<ResultSet
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static LeaderboardRecordsListMessage.Builder newBuilder(final @NonNull byte[] leaderboardId) {
public static LeaderboardRecordsListMessage.Builder newBuilder(final @NonNull String leaderboardId) {
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Builder b = com.heroiclabs.nakama.Api.TLeaderboardRecordsList.newBuilder();
b.setLeaderboardId(ByteString.copyFrom(leaderboardId));
b.setLeaderboardId(leaderboardId);
return new DefaultLeaderboardRecordsListMessage.Builder(b);
}
private final @NonNull
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Builder listing;
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerId(final @NonNull byte[] ownerId) {
listing.setOwnerId(ByteString.copyFrom(ownerId));
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerId(final @NonNull String ownerId) {
listing.setOwnerId(ownerId);
return this;
}
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerIds(final @NonNull List<byte[]> ownerIds) {
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 (byte[] b : ownerIds) {
o.addOwnerIds(ByteString.copyFrom(b));
for (String b : ownerIds) {
o.addOwnerIds(b);
}
listing.setOwnerIds(o);
return this;
@@ -66,8 +65,8 @@ public interface LeaderboardRecordsListMessage extends CollatedMessage<ResultSet
return this;
}
public LeaderboardRecordsListMessage.Builder cursor(final @NonNull byte[] cursor) {
listing.setCursor(ByteString.copyFrom(cursor));
public LeaderboardRecordsListMessage.Builder cursor(final @NonNull Cursor cursor) {
listing.setCursor(cursor.getValue());
return this;
}
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -38,13 +37,13 @@ public interface LeaderboardsListMessage extends CollatedMessage<ResultSet<Leade
return this;
}
public LeaderboardsListMessage.Builder addFilter(final @NonNull byte[] leaderboardId) {
listing.addFilterLeaderboardId(ByteString.copyFrom(leaderboardId));
public LeaderboardsListMessage.Builder addFilter(final @NonNull String leaderboardId) {
listing.addFilterLeaderboardId(leaderboardId);
return this;
}
public LeaderboardsListMessage.Builder cursor(final @NonNull byte[] cursor) {
listing.setCursor(ByteString.copyFrom(cursor));
public LeaderboardsListMessage.Builder cursor(final @NonNull String cursor) {
listing.setCursor(cursor);
return this;
}
@@ -19,21 +19,21 @@ package com.heroiclabs.nakama;
import java.util.List;
/**
* The object which represents a match object.
* The object which represents a match.
*/
public interface Match {
/**
* @returns Match ID
* @return Match ID.
*/
byte[] getId();
String getId();
/**
* @returns List of presences in this match.
* @return List of presences in this match.
*/
List<UserPresence> getPresence();
/**
* @returns Match presence for the current user.
* @return Match presence for the current user.
*/
UserPresence getSelf();
}
@@ -16,29 +16,27 @@
package com.heroiclabs.nakama;
import java.util.List;
/**
* The object which represents a match data object.
* The object which represents match data.
*/
public interface MatchData {
/**
* @returns Match ID
* @return Match ID.
*/
byte[] getId();
String getId();
/**
* @returns Match Data
* @return Match Data.
*/
byte[] getData();
/**
* @returns Data opcode
* @return Data opcode.
*/
long getOpCode();
/**
* @returns Presence for the current match data.
* @return Presence for the current match data.
*/
UserPresence getPresence();
}
@@ -25,9 +25,9 @@ public interface MatchDataSendMessage extends UncollatedMessage {
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static MatchDataSendMessage.Builder newBuilder(final @NonNull byte[] matchId) {
public static MatchDataSendMessage.Builder newBuilder(final @NonNull String matchId) {
return new DefaultMatchDataSendMessage.Builder(com.heroiclabs.nakama.Api.MatchDataSend.newBuilder()
.setMatchId(ByteString.copyFrom(matchId)));
.setMatchId(matchId));
}
private final @NonNull
@@ -47,8 +47,8 @@ public interface MatchDataSendMessage extends UncollatedMessage {
for (UserPresence p : presences) {
com.heroiclabs.nakama.Api.UserPresence.Builder up = com.heroiclabs.nakama.Api.UserPresence.newBuilder();
up.setHandle(p.getHandle());
up.setSessionId(ByteString.copyFrom(p.getSessionId()));
up.setUserId(ByteString.copyFrom(p.getUserId()));
up.setSessionId(p.getSessionId());
up.setUserId(p.getUserId());
matchData.addPresences(up);
}
@@ -22,7 +22,7 @@ public interface MatchPresence {
/**
* @return The ID associated with this presence update
*/
byte[] getId();
String getId();
/**
* @return Users that have joined
@@ -17,11 +17,11 @@
package com.heroiclabs.nakama;
/**
* The object which represents a match token object.
* The object which represents a match token.
*/
public interface MatchToken {
/**
* @returns Match Token
* @return Match Token.
*/
byte[] getToken();
String getToken();
}
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -33,16 +32,16 @@ public interface MatchesJoinMessage extends CollatedMessage<ResultSet<Match>> {
private final @NonNull
com.heroiclabs.nakama.Api.TMatchesJoin.Builder joins;
public MatchesJoinMessage.Builder matchId(final @NonNull byte[] matchId) {
public MatchesJoinMessage.Builder matchId(final @NonNull String matchId) {
com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.newBuilder();
topicJoinBuilder.setMatchId(ByteString.copyFrom(matchId));
topicJoinBuilder.setMatchId(matchId);
joins.addMatches(topicJoinBuilder);
return this;
}
public MatchesJoinMessage.Builder token(final @NonNull MatchToken token) {
com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.newBuilder();
topicJoinBuilder.setToken(ByteString.copyFrom(token.getToken()));
topicJoinBuilder.setToken(token.getToken());
joins.addMatches(topicJoinBuilder);
return this;
}
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -33,8 +32,8 @@ public interface MatchesLeaveMessage extends CollatedMessage<Boolean> {
private final @NonNull
com.heroiclabs.nakama.Api.TMatchesLeave.Builder leaves;
public MatchesLeaveMessage.Builder matchId(final @NonNull byte[] matchId) {
leaves.addMatchIds(ByteString.copyFrom(matchId));
public MatchesLeaveMessage.Builder matchId(final @NonNull String matchId) {
leaves.addMatchIds(matchId);
return this;
}
@@ -17,13 +17,89 @@
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.Set;
public interface MatchmakeAddMessage extends CollatedMessage<MatchmakeTicket> {
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static MatchmakeAddMessage.Builder newBuilder(long requiredCount) {
com.heroiclabs.nakama.Api.TMatchmakeAdd.Builder add = com.heroiclabs.nakama.Api.TMatchmakeAdd.newBuilder()
.setRequiredCount(requiredCount);
return new MatchmakeAddMessage.Builder(add);
}
private final @NonNull
com.heroiclabs.nakama.Api.TMatchmakeAdd.Builder add;
public MatchmakeAddMessage.Builder addTermFilter(String name, Set<String> terms, boolean matchAllTerms)
{
com.heroiclabs.nakama.Api.MatchmakeFilter.TermFilter.Builder f = com.heroiclabs.nakama.Api.MatchmakeFilter.TermFilter.newBuilder()
.addAllTerms(terms)
.setMatchAllTerms(matchAllTerms);
add.addFilters(com.heroiclabs.nakama.Api.MatchmakeFilter.newBuilder().setName(name).setTerm(f));
return this;
}
public MatchmakeAddMessage.Builder addRangeFilter(String name, long lowerbound, long upperbound)
{
com.heroiclabs.nakama.Api.MatchmakeFilter.RangeFilter.Builder f = com.heroiclabs.nakama.Api.MatchmakeFilter.RangeFilter.newBuilder()
.setLowerBound(lowerbound)
.setUpperBound(upperbound);
add.addFilters(com.heroiclabs.nakama.Api.MatchmakeFilter.newBuilder().setName(name).setRange(f));
return this;
}
public MatchmakeAddMessage.Builder addCheckFilter(String name, boolean value)
{
add.addFilters(com.heroiclabs.nakama.Api.MatchmakeFilter.newBuilder().setName(name).setCheck(value));
return this;
}
public MatchmakeAddMessage.Builder addProperty(String key, boolean value)
{
com.heroiclabs.nakama.Api.PropertyPair.Builder p = com.heroiclabs.nakama.Api.PropertyPair.newBuilder()
.setKey(key)
.setBoolValue(value);
add.addProperties(p);
return this;
}
public MatchmakeAddMessage.Builder addProperty(String key, long value)
{
com.heroiclabs.nakama.Api.PropertyPair.Builder p = com.heroiclabs.nakama.Api.PropertyPair.newBuilder()
.setKey(key)
.setIntValue(value);
add.addProperties(p);
return this;
}
public MatchmakeAddMessage.Builder addProperty(String key, Set<String> values)
{
com.heroiclabs.nakama.Api.PropertyPair.Builder p = com.heroiclabs.nakama.Api.PropertyPair.newBuilder()
.setKey(key)
.setStringSet(com.heroiclabs.nakama.Api.PropertyPair.StringSet.newBuilder().addAllValues(values));
add.addProperties(p);
return this;
}
public MatchmakeAddMessage build() {
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
com.heroiclabs.nakama.Api.Envelope.newBuilder()
.setMatchmakeAdd(add);
return new DefaultMatchmakeAddMessage(payload);
}
public static MatchmakeAddMessage build(long requiredCount) {
com.heroiclabs.nakama.Api.TMatchmakeAdd.Builder add = com.heroiclabs.nakama.Api.TMatchmakeAdd.newBuilder()
.setRequiredCount(requiredCount);
@@ -0,0 +1,24 @@
/*
* 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;
public interface MatchmakeCheckFilter extends MatchmakeFilter {
/**
* @return Filter value
*/
boolean isValue();
}
@@ -0,0 +1,19 @@
/*
* 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;
public interface MatchmakeFilter { }
@@ -19,26 +19,31 @@ package com.heroiclabs.nakama;
import java.util.List;
/**
* The object which represents a matchmake matched object.
* The object which represents a matchmake matched.
*/
public interface MatchmakeMatched {
/**
* @returns Matchmaking Ticket.
* @return Matchmaking Ticket.
*/
MatchmakeTicket getTicket();
/**
* @returns List of presences in this match.
* @return List of presences in this match.
*/
List<UserPresence> getPresence();
/**
* @returns Match token.
* @return Match token.
*/
MatchToken getToken();
/**
* @returns Match presence for the current user.
* @return Match presence for the current user.
*/
UserPresence getSelf();
/**
* @return Match properties for matched users.
*/
List<MatchmakeUserProperty> getProperties();
}
@@ -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;
public interface MatchmakeRangeFilter extends MatchmakeFilter {
/**
* @return Range lower bound
*/
long getLowerbound();
/**
* @return Range upper bound
*/
long getUpperbound();
}
@@ -16,7 +16,6 @@
package com.heroiclabs.nakama;
import com.google.protobuf.ByteString;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -28,7 +27,7 @@ public interface MatchmakeRemoveMessage extends CollatedMessage<Boolean> {
public static MatchmakeRemoveMessage build(@NonNull MatchmakeTicket ticket) {
com.heroiclabs.nakama.Api.TMatchmakeRemove.Builder remove = com.heroiclabs.nakama.Api.TMatchmakeRemove.newBuilder();
remove.setTicket(ByteString.copyFrom(ticket.getTicket()));
remove.setTicket(ticket.getTicket());
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
com.heroiclabs.nakama.Api.Envelope.newBuilder()
@@ -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 java.util.List;
public interface MatchmakeTermFilter extends MatchmakeFilter {
/**
* @return Matching terms
*/
List<String> getTerms();
/**
* @return Whether to match all terms, or match any of the terms
*/
boolean isMatchingAllTerms();
}
@@ -17,11 +17,11 @@
package com.heroiclabs.nakama;
/**
* The object which represents a matchmake object.
* The object which represents a matchmake.
*/
public interface MatchmakeTicket {
/**
* @returns Matchmake Ticket
* @return Matchmake Ticket
*/
byte[] getTicket();
String getTicket();
}
@@ -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.Map;
/**
* Properties associated with each matched user
*/
public interface MatchmakeUserProperty {
/**
* @return Matchmake user ID
*/
String getUserId();
/**
* @return Matchmake user properties
*/
Map<String, Object> getProperties();
/**
* @return Matchmake user filters
*/
Map<String, MatchmakeFilter> getFilters();
}
@@ -16,6 +16,8 @@
package com.heroiclabs.nakama;
import java.util.List;
/**
* Default implementation of client listener, all operations are no-op.
*/
@@ -26,4 +28,5 @@ public class NoopClientListener implements ClientListener {
@Override public void onMatchmakeMatched(MatchmakeMatched matched) {}
@Override public void onMatchData(MatchData matchData) {}
@Override public void onMatchPresence(MatchPresence matchPresence) {}
@Override public void onNotifications(List<Notification> notifications) {}
}
@@ -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;
/**
* Represents a notification aimed at a particular user.
*/
public interface Notification {
/**
* @return The unique ID of the notification.
*/
String getId();
/**
* @return The subject text.
*/
String getSubject();
/**
* @return The notification body.
*/
String getContent();
/**
* @return The notification code.
*/
long getCode();
/**
* @return The user ID of the sender, or an empty string if it's a system notification.
*/
String getSenderId();
/**
* @return The UTC milliseconds timestamp when the notification was created.
*/
long getCreatedAt();
/**
* @return The UTC milliseconds timestamp when the notification expires.
*/
long getExpiresAt();
/**
* @return true if the notification was persisted and may be retrieved later, false if
* the notification was only delivered and not stored.
*/
boolean isPersistent();
}
@@ -0,0 +1,49 @@
/*
* 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 NotificationsListMessage extends CollatedMessage<ResultSet<Notification>> {
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static NotificationsListMessage.Builder newBuilder(final long limit) {
return new NotificationsListMessage.Builder(com.heroiclabs.nakama.Api.TNotificationsList.newBuilder()
.setLimit(limit));
}
private final @NonNull
com.heroiclabs.nakama.Api.TNotificationsList.Builder list;
public NotificationsListMessage.Builder cursor(final @NonNull Cursor cursor) {
this.list.setResumableCursor(cursor.getValue());
return this;
}
public NotificationsListMessage build() {
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
com.heroiclabs.nakama.Api.Envelope.newBuilder()
.setNotificationsList(list);
return new DefaultNotificationsListMessage(payload);
}
}
}
@@ -0,0 +1,53 @@
/*
* 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 NotificationsRemoveMessage extends CollatedMessage<Boolean> {
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static NotificationsRemoveMessage.Builder newBuilder() {
return new NotificationsRemoveMessage.Builder(com.heroiclabs.nakama.Api.TNotificationsRemove.newBuilder());
}
private final @NonNull
com.heroiclabs.nakama.Api.TNotificationsRemove.Builder removes;
public NotificationsRemoveMessage.Builder id(final @NonNull String notificationId) {
this.removes.addNotificationIds(notificationId);
return this;
}
public NotificationsRemoveMessage.Builder ids(final @NonNull Iterable<String> notificationIds) {
this.removes.addAllNotificationIds(notificationIds);
return this;
}
public NotificationsRemoveMessage build() {
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
com.heroiclabs.nakama.Api.Envelope.newBuilder()
.setNotificationsRemove(removes);
return new DefaultNotificationsRemoveMessage(payload);
}
}
}
Loaded 100 of 142 files, more files were not shown because too many files have changed in this diff. Show more