mirror of
https://github.com/heroiclabs/nakama-java.git
synced 2026-11-24 08:55:49 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
113d21a1e1 | ||
|
|
95a8571b4c | ||
|
|
b8de50d4e0 | ||
|
|
11d758e48c | ||
|
|
6e8e08519b | ||
|
|
0e3e237656 |
No files matched your search
@@ -4,6 +4,24 @@ 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/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [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.
|
||||
|
||||
+6
-3
@@ -25,7 +25,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com.heroiclabs.nakama'
|
||||
version = '0.3.0'
|
||||
version = '0.5.0'
|
||||
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 {
|
||||
@@ -109,6 +110,8 @@ gitPublish {
|
||||
include '0.1.1/**'
|
||||
include '0.1.2/**'
|
||||
include '0.2.0/**'
|
||||
include '0.3.0/**'
|
||||
include '0.4.0/**'
|
||||
}
|
||||
commitMessage = "Published javadoc '$project.version' via Gradle ${GradleVersion.current().version}."
|
||||
}
|
||||
|
||||
+1
-1
Submodule server updated: e0a93a8615...ca88ea9ce6.
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A listener for receiving {@code Client} events.
|
||||
*/
|
||||
@@ -59,4 +61,11 @@ public interface ClientListener {
|
||||
* @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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,14 +372,21 @@ 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(), collationId));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -43,9 +43,9 @@ class DefaultMatchmakeMatched implements MatchmakeMatched {
|
||||
}
|
||||
|
||||
return new DefaultMatchmakeMatched(
|
||||
DefaultMatchmakeTicket.fromProto(matched.getTicket().toByteArray()),
|
||||
DefaultMatchmakeTicket.fromProto(matched.getTicket()),
|
||||
userPresences,
|
||||
DefaultMatchToken.fromProto(matched.getToken().toByteArray()),
|
||||
DefaultMatchToken.fromProto(matched.getToken()),
|
||||
DefaultUserPresence.fromProto(matched.getSelf()),
|
||||
userProperties
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,14 @@ package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeUserProperty implements MatchmakeUserProperty {
|
||||
private final byte[] userId;
|
||||
private final String userId;
|
||||
private final Map<String, Object> properties;
|
||||
private final Map<String, MatchmakeFilter> filters;
|
||||
|
||||
@@ -62,6 +60,6 @@ class DefaultMatchmakeUserProperty implements MatchmakeUserProperty {
|
||||
}
|
||||
}
|
||||
|
||||
return new DefaultMatchmakeUserProperty(p.getUserId().toByteArray(), props, filters);
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -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,14 +16,40 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* The object which represents a leaderboard object.
|
||||
*/
|
||||
public interface Leaderboard {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
enum SortOrder {
|
||||
ASCENDING(0),
|
||||
DESCENDING(1);
|
||||
|
||||
@Getter
|
||||
private final int code;
|
||||
|
||||
static Leaderboard.SortOrder fromLong(final long sort) {
|
||||
switch ((int) sort) {
|
||||
case 0:
|
||||
return ASCENDING;
|
||||
case 1:
|
||||
return DESCENDING;
|
||||
default:
|
||||
String message = String.format("Unrecognised leaderboard sort order: %s", sort);
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Leaderboard ID.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return Whether leaderboard is server authoritative or not.
|
||||
@@ -33,7 +59,7 @@ public interface Leaderboard {
|
||||
/**
|
||||
* @return Sort order for the record.
|
||||
*/
|
||||
long getSort();
|
||||
SortOrder getSort();
|
||||
|
||||
/**
|
||||
* @return Record count.
|
||||
@@ -48,7 +74,7 @@ public interface 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();
|
||||
}
|
||||
@@ -26,12 +26,12 @@ public interface LeaderboardRecord {
|
||||
/**
|
||||
* @return Leaderboard ID.
|
||||
*/
|
||||
byte[] getLeaderboardId();
|
||||
String getLeaderboardId();
|
||||
|
||||
/**
|
||||
* @return User ID that owns this record.
|
||||
*/
|
||||
byte[] getOwnerId();
|
||||
String getOwnerId();
|
||||
|
||||
/**
|
||||
* @return User handle.
|
||||
@@ -62,7 +62,7 @@ public interface LeaderboardRecord {
|
||||
/**
|
||||
* @return Metadata associated with the leaderboard record.
|
||||
*/
|
||||
byte[] getMetadata();
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface Match {
|
||||
/**
|
||||
* @return Match ID.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return List of presences in this match.
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object which represents match data.
|
||||
*/
|
||||
@@ -25,7 +23,7 @@ public interface MatchData {
|
||||
/**
|
||||
* @return Match ID.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return Match Data.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,5 +23,5 @@ public interface MatchToken {
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -23,5 +23,5 @@ public interface MatchmakeTicket {
|
||||
/**
|
||||
* @return Matchmake Ticket
|
||||
*/
|
||||
byte[] getTicket();
|
||||
String getTicket();
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -26,7 +25,7 @@ public interface MatchmakeUserProperty {
|
||||
/**
|
||||
* @return Matchmake user ID
|
||||
*/
|
||||
byte[] getUserId();
|
||||
String getUserId();
|
||||
|
||||
/**
|
||||
* @return Matchmake user properties
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,5 +38,5 @@ public interface RecordId {
|
||||
/**
|
||||
* @return The version of the record which has been fetched.
|
||||
*/
|
||||
byte[] getVersion();
|
||||
String getVersion();
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,8 +31,8 @@ public interface RpcMessage extends CollatedMessage<RpcResult> {
|
||||
|
||||
private final @NonNull com.heroiclabs.nakama.Api.TRpc.Builder rpc;
|
||||
|
||||
public Builder payload(final @NonNull byte[] payload) {
|
||||
rpc.setPayload(ByteString.copyFrom(payload));
|
||||
public Builder payload(final @NonNull String payload) {
|
||||
rpc.setPayload(payload);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface RpcResult {
|
||||
/**
|
||||
* @return The payload result sent back from the function call. May be {@code null}.
|
||||
*/
|
||||
byte[] getPayload();
|
||||
String getPayload();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -57,8 +56,8 @@ public interface SelfUpdateMessage extends CollatedMessage<Boolean> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder metadata(final @NonNull byte[] metadata) {
|
||||
update.setMetadata(ByteString.copyFrom(metadata));
|
||||
public Builder metadata(final @NonNull String metadata) {
|
||||
update.setMetadata(metadata);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public interface Session {
|
||||
/**
|
||||
* @return The ID of the user.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return The session token returned by the server after register or login.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,14 +32,14 @@ public interface StorageFetchMessage extends CollatedMessage<ResultSet<StorageRe
|
||||
private final @NonNull com.heroiclabs.nakama.Api.TStorageFetch.Builder fetch;
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final byte[] userId) {
|
||||
final String userId) {
|
||||
com.heroiclabs.nakama.Api.TStorageFetch.StorageKey.Builder record =
|
||||
com.heroiclabs.nakama.Api.TStorageFetch.StorageKey.newBuilder()
|
||||
.setBucket(bucket)
|
||||
.setCollection(collection)
|
||||
.setRecord(key);
|
||||
if (userId != null) {
|
||||
record = record.setUserId(ByteString.copyFrom(userId));
|
||||
record = record.setUserId(userId);
|
||||
}
|
||||
fetch.addKeys(record);
|
||||
return this;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -26,20 +25,20 @@ public interface StorageListMessage extends CollatedMessage<ResultSet<StorageRec
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static Builder newBuilder(final @NonNull byte[] userId) {
|
||||
public static Builder newBuilderUserId(final @NonNull String userId) {
|
||||
return new Builder(com.heroiclabs.nakama.Api.TStorageList.newBuilder()
|
||||
.setUserId(ByteString.copyFrom(userId)));
|
||||
.setUserId(userId));
|
||||
}
|
||||
|
||||
public static Builder newBuilder(final @NonNull String bucket) {
|
||||
public static Builder newBuilderBucket(final @NonNull String bucket) {
|
||||
return new Builder(com.heroiclabs.nakama.Api.TStorageList.newBuilder()
|
||||
.setBucket(bucket));
|
||||
}
|
||||
|
||||
private final @NonNull com.heroiclabs.nakama.Api.TStorageList.Builder list;
|
||||
|
||||
public Builder userId(final @NonNull byte[] userId) {
|
||||
list.setUserId(ByteString.copyFrom(userId));
|
||||
public Builder userId(final @NonNull String userId) {
|
||||
list.setUserId(userId);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -59,7 +58,7 @@ public interface StorageListMessage extends CollatedMessage<ResultSet<StorageRec
|
||||
}
|
||||
|
||||
public Builder cursor(final @NonNull Cursor cursor) {
|
||||
list.setCursor(ByteString.copyFrom(cursor.getValue()));
|
||||
list.setCursor(cursor.getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A record from the storage engine in the server.
|
||||
*/
|
||||
@@ -102,7 +98,7 @@ public interface StorageRecord extends RecordId {
|
||||
/**
|
||||
* @return The value (content) of the record.
|
||||
*/
|
||||
byte[] getValue();
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
@@ -119,5 +115,5 @@ public interface StorageRecord extends RecordId {
|
||||
/**
|
||||
* @return The Id of the user who owns the record.
|
||||
*/
|
||||
byte[] getUserId();
|
||||
String getUserId();
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -43,14 +42,14 @@ public interface StorageRemoveMessage extends CollatedMessage<Boolean> {
|
||||
}
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final byte[] version) {
|
||||
final String version) {
|
||||
com.heroiclabs.nakama.Api.TStorageRemove.StorageKey.Builder record =
|
||||
com.heroiclabs.nakama.Api.TStorageRemove.StorageKey.newBuilder()
|
||||
.setBucket(bucket)
|
||||
.setCollection(collection)
|
||||
.setRecord(key);
|
||||
if (version != null) {
|
||||
record = record.setVersion(ByteString.copyFrom(version));
|
||||
record = record.setVersion(version);
|
||||
}
|
||||
remove.addKeys(record);
|
||||
return this;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
@@ -33,7 +32,7 @@ public interface StorageUpdateMessage extends CollatedMessage<ResultSet<RecordId
|
||||
private final @NonNull com.heroiclabs.nakama.Api.TStorageUpdate.Builder updates;
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final @NonNull OpBuilder ops, final byte[] version,
|
||||
final @NonNull OpBuilder ops, final String version,
|
||||
final StorageRecord.PermissionRead read,
|
||||
final StorageRecord.PermissionWrite write) {
|
||||
com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.StorageKey.Builder updateKey =
|
||||
@@ -42,7 +41,7 @@ public interface StorageUpdateMessage extends CollatedMessage<ResultSet<RecordId
|
||||
.setCollection(collection)
|
||||
.setRecord(key);
|
||||
if (version != null) {
|
||||
updateKey = updateKey.setVersion(ByteString.copyFrom(version));
|
||||
updateKey = updateKey.setVersion(version);
|
||||
}
|
||||
com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.Builder record =
|
||||
com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.newBuilder()
|
||||
@@ -70,7 +69,7 @@ public interface StorageUpdateMessage extends CollatedMessage<ResultSet<RecordId
|
||||
}
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final @NonNull OpBuilder ops, final byte[] version) {
|
||||
final @NonNull OpBuilder ops, final String version) {
|
||||
return record(bucket, collection, key, ops, version, null, null);
|
||||
}
|
||||
|
||||
@@ -92,19 +91,19 @@ public interface StorageUpdateMessage extends CollatedMessage<ResultSet<RecordId
|
||||
|
||||
final @NonNull com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.Builder ops;
|
||||
|
||||
public OpBuilder add(final @NonNull String path, final @NonNull byte[] value) {
|
||||
public OpBuilder add(final @NonNull String path, final @NonNull String value) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.ADD.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value)));
|
||||
.setValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OpBuilder append(final @NonNull String path, final @NonNull byte[] value) {
|
||||
public OpBuilder append(final @NonNull String path, final @NonNull String value) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.APPEND.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value)));
|
||||
.setValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -120,23 +119,23 @@ public interface StorageUpdateMessage extends CollatedMessage<ResultSet<RecordId
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.INCR.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(Long.toString(value).getBytes())));
|
||||
.setValue(Long.toString(value)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OpBuilder init(final @NonNull String path, final @NonNull byte[] value) {
|
||||
public OpBuilder init(final @NonNull String path, final @NonNull String value) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.INIT.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value)));
|
||||
.setValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OpBuilder merge(final @NonNull String path, final @NonNull byte[] value) {
|
||||
public OpBuilder merge(final @NonNull String path, final @NonNull String value) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.MERGE.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value)));
|
||||
.setValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -158,27 +157,27 @@ public interface StorageUpdateMessage extends CollatedMessage<ResultSet<RecordId
|
||||
return this;
|
||||
}
|
||||
|
||||
public OpBuilder replace(final @NonNull String path, final @NonNull byte[] value) {
|
||||
public OpBuilder replace(final @NonNull String path, final @NonNull String value) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.REPLACE.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value)));
|
||||
.setValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OpBuilder test(final @NonNull String path, final @NonNull byte[] value) {
|
||||
public OpBuilder test(final @NonNull String path, final @NonNull String value) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.TEST.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value)));
|
||||
.setValue(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public OpBuilder compare(final @NonNull String path, final @NonNull byte[] value, final long assertValue) {
|
||||
public OpBuilder compare(final @NonNull String path, final @NonNull String value, final long assertValue) {
|
||||
ops.addOps(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.newBuilder()
|
||||
.setOp(com.heroiclabs.nakama.Api.TStorageUpdate.StorageUpdate.UpdateOp.UpdateOpCode.COMPARE.getNumber())
|
||||
.setPath(path)
|
||||
.setValue(ByteString.copyFrom(value))
|
||||
.setValue(value)
|
||||
.setAssert(assertValue));
|
||||
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,7 +32,7 @@ public interface StorageWriteMessage extends CollatedMessage<ResultSet<RecordId>
|
||||
private final @NonNull com.heroiclabs.nakama.Api.TStorageWrite.Builder writes;
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final @NonNull byte[] value, final byte[] version,
|
||||
final @NonNull String value, final String version,
|
||||
final StorageRecord.PermissionRead read,
|
||||
final StorageRecord.PermissionWrite write) {
|
||||
com.heroiclabs.nakama.Api.TStorageWrite.StorageData.Builder record =
|
||||
@@ -41,9 +40,9 @@ public interface StorageWriteMessage extends CollatedMessage<ResultSet<RecordId>
|
||||
.setBucket(bucket)
|
||||
.setCollection(collection)
|
||||
.setRecord(key)
|
||||
.setValue(ByteString.copyFrom(value));
|
||||
.setValue(value);
|
||||
if (version != null) {
|
||||
record = record.setVersion(ByteString.copyFrom(version));
|
||||
record = record.setVersion(version);
|
||||
}
|
||||
if (read != null) {
|
||||
record = record.setPermissionRead(read.getCode());
|
||||
@@ -56,18 +55,18 @@ public interface StorageWriteMessage extends CollatedMessage<ResultSet<RecordId>
|
||||
}
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final @NonNull byte[] value) {
|
||||
final @NonNull String value) {
|
||||
return record(bucket, collection, key, value, null, null, null);
|
||||
}
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final @NonNull byte[] value, final StorageRecord.PermissionRead read,
|
||||
final @NonNull String value, final StorageRecord.PermissionRead read,
|
||||
final StorageRecord.PermissionWrite write) {
|
||||
return record(bucket, collection, key, value, null, read, write);
|
||||
}
|
||||
|
||||
public Builder record(final @NonNull String bucket, final @NonNull String collection, final @NonNull String key,
|
||||
final @NonNull byte[] value, final byte[] version) {
|
||||
final @NonNull String value, final String version) {
|
||||
return record(bucket, collection, key, value, version, null, null);
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user