mirror of
https://github.com/heroiclabs/nakama-java.git
synced 2026-11-24 08:55:49 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11d758e48c | ||
|
|
6e8e08519b | ||
|
|
0e3e237656 | ||
|
|
8cd7bd7e71 | ||
|
|
d9c2ffe343 | ||
|
|
5f044e2cf7 | ||
|
|
55119792d9 | ||
|
|
38362c56ef |
No files matched your search
@@ -4,6 +4,19 @@ 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.4.0] - 2017-11-07
|
||||
### Changed
|
||||
- Expose a simpler interface for identifier fields.
|
||||
|
||||
## [0.3.0] - 2017-10-17
|
||||
### Added
|
||||
- Advanced Matchmaking with custom filters and user properties.
|
||||
|
||||
### Fixed
|
||||
- Improved errors to contain the underlying error reason.
|
||||
|
||||
## [0.2.0] - 2017-09-24
|
||||
### Added
|
||||
- Leaderboard messages.
|
||||
|
||||
+4
-1
@@ -25,7 +25,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com.heroiclabs.nakama'
|
||||
version = '0.2.0'
|
||||
version = '0.4.0'
|
||||
def description = 'Android optimized Java client for Nakama server.'
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
@@ -108,6 +108,9 @@ gitPublish {
|
||||
include '0.1.0/**'
|
||||
include '0.1.1/**'
|
||||
include '0.1.2/**'
|
||||
include '0.2.0/**'
|
||||
include '0.3.0/**'
|
||||
include '0.4.0/**'
|
||||
}
|
||||
commitMessage = "Published javadoc '$project.version' via Gradle ${GradleVersion.current().version}."
|
||||
}
|
||||
|
||||
+1
-1
Submodule server updated: 15dc7ba786...b6f073bb4e.
@@ -27,26 +27,36 @@ public interface ClientListener {
|
||||
|
||||
/**
|
||||
* Called when a new topic message has been received.
|
||||
*
|
||||
* @param message The {@code TopicMessage} received.
|
||||
*/
|
||||
void onTopicMessage(TopicMessage message);
|
||||
|
||||
/**
|
||||
* Called when a new topic presence update has been received.
|
||||
*
|
||||
* @param presence The {@code TopicPresence} received.
|
||||
*/
|
||||
void onTopicPresence(TopicPresence presence);
|
||||
|
||||
/**
|
||||
* Called when a matchmaking has found a match.
|
||||
*
|
||||
* @param matched The {@code MatchmakeMatched} received.
|
||||
*/
|
||||
void onMatchmakeMatched(MatchmakeMatched matched);
|
||||
|
||||
/**
|
||||
* Called when a new match data is received.
|
||||
*
|
||||
* @param matchData The {@code MatchData} received.
|
||||
*/
|
||||
void onMatchData(MatchData matchData);
|
||||
|
||||
/**
|
||||
* Called when a new match presence update is received.
|
||||
*
|
||||
* @param matchPresence The {@code MatchPresence} received.
|
||||
*/
|
||||
void onMatchPresence(MatchPresence matchPresence);
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public interface Cursor {
|
||||
/**
|
||||
* @return The encoded pointer which represents a position in the database records.
|
||||
*/
|
||||
byte[] getValue();
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* @return Encode the cursor so it can be cached.
|
||||
|
||||
@@ -126,7 +126,7 @@ public class DefaultClient implements Client {
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
deferred.callback(new DefaultError("Error sending message to server", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Error sending message to server", e));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ public class DefaultClient implements Client {
|
||||
try {
|
||||
authResponse = com.heroiclabs.nakama.Api.AuthenticateResponse.parseFrom(body.byteStream());
|
||||
} catch (IOException e) {
|
||||
deferred.callback(new DefaultError("Error reading response from server", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Error reading response from server", e));
|
||||
return;
|
||||
} finally {
|
||||
response.close();
|
||||
@@ -152,13 +152,13 @@ public class DefaultClient implements Client {
|
||||
|
||||
switch (authResponse.getIdCase()) {
|
||||
case ERROR:
|
||||
deferred.callback(new DefaultError(authResponse.getError().getMessage(), authResponse.getError().getCode()));
|
||||
deferred.callback(new DefaultError(authResponse.getError().getMessage(), authResponse.getError().getCode(), authResponse.getCollationId()));
|
||||
break;
|
||||
case SESSION:
|
||||
deferred.callback(DefaultSession.restore(authResponse.getSession().getToken()));
|
||||
break;
|
||||
default:
|
||||
deferred.callback(new DefaultError("Unknown response format from server", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Unknown response format from server for message", Error.ErrorCode.UNKNOWN, authResponse.getCollationId()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public class DefaultClient implements Client {
|
||||
def.callback(Boolean.TRUE);
|
||||
break;
|
||||
case ERROR:
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode()));
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode(), collationId));
|
||||
break;
|
||||
case SELF:
|
||||
def.callback(DefaultSelf.fromProto(envelope.getSelf().getSelf()));
|
||||
@@ -287,8 +287,8 @@ public class DefaultClient implements Client {
|
||||
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 +317,7 @@ public class DefaultClient implements Client {
|
||||
for (final com.heroiclabs.nakama.Api.TopicMessage m : envelope.getTopicMessages().getMessagesList()) {
|
||||
messages.add(DefaultTopicMessage.fromProto(m));
|
||||
}
|
||||
def.callback(new DefaultResultSet<TopicMessage>(new DefaultCursor(envelope.getTopicMessages().getCursor().toByteArray()), messages));
|
||||
def.callback(new DefaultResultSet<TopicMessage>(new DefaultCursor(envelope.getTopicMessages().getCursor()), messages));
|
||||
break;
|
||||
case MATCH:
|
||||
def.callback(DefaultMatch.fromProto(envelope.getMatch()));
|
||||
@@ -337,17 +337,17 @@ 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;
|
||||
default:
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode()));
|
||||
def.callback(new DefaultError(envelope.getError().getMessage(), envelope.getError().getCode(), collationId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -420,7 +420,7 @@ public class DefaultClient implements Client {
|
||||
|
||||
final boolean isEnqueued = socket.send(ByteString.of(payload));
|
||||
if (!isEnqueued) {
|
||||
deferred.callback(new DefaultError("Failed to send message, make sure the client is connected", Error.ErrorCode.UNKNOWN));
|
||||
deferred.callback(new DefaultError("Failed to send message, make sure the client is connected", Error.ErrorCode.UNKNOWN, collationId));
|
||||
return deferred;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,16 @@ import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import okio.ByteString;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultCursor implements Cursor {
|
||||
|
||||
private final byte[] value;
|
||||
private final String value;
|
||||
|
||||
public String serialize() {
|
||||
return ByteString.of(value).base64();
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +37,6 @@ public class DefaultCursor implements Cursor {
|
||||
* @return A new cursor which was stored.
|
||||
*/
|
||||
public static Cursor restore(final String serializedCursor) {
|
||||
final byte[] cursor = ByteString.decodeBase64(serializedCursor).toByteArray();
|
||||
return new DefaultCursor(cursor);
|
||||
return new DefaultCursor(serializedCursor);
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,30 @@ import lombok.*;
|
||||
class DefaultError extends Error {
|
||||
|
||||
private final ErrorCode code;
|
||||
private final String collationId;
|
||||
|
||||
DefaultError(final @NonNull String message, final @NonNull ErrorCode code) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.collationId = null;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final int code) {
|
||||
DefaultError(final @NonNull String message, final @NonNull ErrorCode code, final String collationId) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.collationId = collationId;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final @NonNull Throwable cause) {
|
||||
super(message, cause);
|
||||
this.code = ErrorCode.UNKNOWN;
|
||||
this.collationId = null;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final int code, final String collationId) {
|
||||
super(message);
|
||||
this.code = ErrorCode.fromInt(code);
|
||||
this.collationId = collationId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 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.getCount(),
|
||||
leaderboard.getResetSchedule(),
|
||||
leaderboard.getMetadata().toByteArray(),
|
||||
leaderboard.getNextId().toByteArray(),
|
||||
leaderboard.getPrevId().toByteArray()
|
||||
leaderboard.getMetadata(),
|
||||
leaderboard.getNextId(),
|
||||
leaderboard.getPrevId()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import lombok.*;
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultLeaderboardRecord implements LeaderboardRecord {
|
||||
private final byte[] leaderboardId;
|
||||
private final byte[] ownerId;
|
||||
private final String leaderboardId;
|
||||
private final String ownerId;
|
||||
private final String handle;
|
||||
private final String lang;
|
||||
private final String location;
|
||||
@@ -31,15 +31,15 @@ class DefaultLeaderboardRecord implements LeaderboardRecord {
|
||||
private final long rank;
|
||||
private final long score;
|
||||
private final long numScore;
|
||||
private final byte[] metadata;
|
||||
private final String metadata;
|
||||
private final long rankedAt;
|
||||
private final long updatedAt;
|
||||
private final long expiresAt;
|
||||
|
||||
static LeaderboardRecord fromProto(final @NonNull com.heroiclabs.nakama.Api.LeaderboardRecord record) {
|
||||
return new DefaultLeaderboardRecord(
|
||||
record.getLeaderboardId().toByteArray(),
|
||||
record.getOwnerId().toByteArray(),
|
||||
record.getLeaderboardId(),
|
||||
record.getOwnerId(),
|
||||
record.getHandle(),
|
||||
record.getLang(),
|
||||
record.getLocation(),
|
||||
@@ -47,7 +47,7 @@ class DefaultLeaderboardRecord implements LeaderboardRecord {
|
||||
record.getRank(),
|
||||
record.getScore(),
|
||||
record.getNumScore(),
|
||||
record.getMetadata().toByteArray(),
|
||||
record.getMetadata(),
|
||||
record.getRankedAt(),
|
||||
record.getUpdatedAt(),
|
||||
record.getExpiresAt()
|
||||
@@ -55,7 +55,7 @@ class DefaultLeaderboardRecord implements LeaderboardRecord {
|
||||
}
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatch implements Match {
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
private final List<UserPresence> presence;
|
||||
private final UserPresence self;
|
||||
|
||||
@@ -39,7 +39,7 @@ class DefaultMatch implements Match {
|
||||
userPresences.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultMatch(match.getMatchId().toByteArray(), userPresences, DefaultUserPresence.fromProto(match.getSelf()));
|
||||
return new DefaultMatch(match.getMatchId(), userPresences, DefaultUserPresence.fromProto(match.getSelf()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,20 +18,17 @@ package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchData implements MatchData {
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
private final byte[] data;
|
||||
private final long opCode;
|
||||
private final UserPresence presence;
|
||||
|
||||
static MatchData fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchData matchData) {
|
||||
return new DefaultMatchData(matchData.getMatchId().toByteArray(), matchData.getData().toByteArray(), matchData.getOpCode(), DefaultUserPresence.fromProto(matchData.getPresence()));
|
||||
return new DefaultMatchData(matchData.getMatchId(), matchData.getData().toByteArray(), matchData.getOpCode(), DefaultUserPresence.fromProto(matchData.getPresence()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultMatchPresence implements MatchPresence {
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
private final List<UserPresence> join;
|
||||
private final List<UserPresence> leave;
|
||||
|
||||
@@ -41,6 +41,6 @@ public class DefaultMatchPresence implements MatchPresence {
|
||||
leaves.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultMatchPresence(matchPresence.getMatchId().toByteArray(), joins, leaves);
|
||||
return new DefaultMatchPresence(matchPresence.getMatchId(), joins, leaves);
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,9 @@ import lombok.*;
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchToken implements MatchToken {
|
||||
private final byte[] token;
|
||||
private final String token;
|
||||
|
||||
static MatchToken fromProto(final @NonNull byte[] token) {
|
||||
static MatchToken fromProto(final @NonNull String token) {
|
||||
return new DefaultMatchToken(token);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeCheckFilter implements MatchmakeCheckFilter {
|
||||
private final boolean value;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class DefaultMatchmakeMatched implements MatchmakeMatched {
|
||||
private final List<UserPresence> presence;
|
||||
private final MatchToken token;
|
||||
private final UserPresence self;
|
||||
private final List<MatchmakeUserProperty> properties;
|
||||
|
||||
static MatchmakeMatched fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeMatched matched) {
|
||||
List<UserPresence> userPresences = new ArrayList<UserPresence>();
|
||||
@@ -36,11 +37,17 @@ class DefaultMatchmakeMatched implements MatchmakeMatched {
|
||||
userPresences.add(DefaultUserPresence.fromProto(u));
|
||||
}
|
||||
|
||||
List<MatchmakeUserProperty> userProperties = new ArrayList<MatchmakeUserProperty>();
|
||||
for (com.heroiclabs.nakama.Api.MatchmakeMatched.UserProperty u : matched.getPropertiesList()) {
|
||||
userProperties.add(DefaultMatchmakeUserProperty.fromProto(u));
|
||||
}
|
||||
|
||||
return new DefaultMatchmakeMatched(
|
||||
DefaultMatchmakeTicket.fromProto(matched.getTicket().toByteArray()),
|
||||
DefaultMatchmakeTicket.fromProto(matched.getTicket()),
|
||||
userPresences,
|
||||
DefaultMatchToken.fromProto(matched.getToken().toByteArray()),
|
||||
DefaultUserPresence.fromProto(matched.getSelf())
|
||||
DefaultMatchToken.fromProto(matched.getToken()),
|
||||
DefaultUserPresence.fromProto(matched.getSelf()),
|
||||
userProperties
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeRangeFilter implements MatchmakeRangeFilter {
|
||||
private final long lowerbound;
|
||||
private final long upperbound;
|
||||
|
||||
static MatchmakeRangeFilter fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeFilter.RangeFilter filter) {
|
||||
return new DefaultMatchmakeRangeFilter(filter.getLowerBound(), filter.getUpperBound());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeTermFilter implements MatchmakeTermFilter {
|
||||
private final List<String> terms;
|
||||
private final boolean matchingAllTerms;
|
||||
|
||||
static MatchmakeTermFilter fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeFilter.TermFilter filter) {
|
||||
return new DefaultMatchmakeTermFilter(filter.getTermsList(), filter.getMatchAllTerms());
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,13 @@ import lombok.*;
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeTicket implements MatchmakeTicket {
|
||||
private final byte[] ticket;
|
||||
private final String ticket;
|
||||
|
||||
static MatchmakeTicket fromProto(final @NonNull com.heroiclabs.nakama.Api.TMatchmakeTicket matchmakeTicket) {
|
||||
return new DefaultMatchmakeTicket(matchmakeTicket.getTicket().toByteArray());
|
||||
return new DefaultMatchmakeTicket(matchmakeTicket.getTicket());
|
||||
}
|
||||
|
||||
static MatchmakeTicket fromProto(final @NonNull byte[] matchmakeTicket) {
|
||||
static MatchmakeTicket fromProto(final @NonNull String matchmakeTicket) {
|
||||
return new DefaultMatchmakeTicket(matchmakeTicket);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultMatchmakeUserProperty implements MatchmakeUserProperty {
|
||||
private final String userId;
|
||||
private final Map<String, Object> properties;
|
||||
private final Map<String, MatchmakeFilter> filters;
|
||||
|
||||
static DefaultMatchmakeUserProperty fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchmakeMatched.UserProperty p) {
|
||||
Map<String, Object> props = new HashMap<>();
|
||||
for (com.heroiclabs.nakama.Api.PropertyPair pp : p.getPropertiesList()) {
|
||||
switch (pp.getValueCase()) {
|
||||
case INTVALUE:
|
||||
props.put(pp.getKey(), pp.getIntValue());
|
||||
break;
|
||||
case BOOLVALUE:
|
||||
props.put(pp.getKey(), pp.getBoolValue());
|
||||
break;
|
||||
case STRINGSET:
|
||||
props.put(pp.getKey(), pp.getStringSet().getValuesList());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, MatchmakeFilter> filters = new HashMap<>();
|
||||
for (com.heroiclabs.nakama.Api.MatchmakeFilter f : p.getFiltersList()) {
|
||||
switch (f.getValueCase()) {
|
||||
case TERM:
|
||||
filters.put(f.getName(), DefaultMatchmakeTermFilter.fromProto(f.getTerm()));
|
||||
break;
|
||||
case RANGE:
|
||||
filters.put(f.getName(), DefaultMatchmakeRangeFilter.fromProto(f.getRange()));
|
||||
break;
|
||||
case CHECK:
|
||||
filters.put(f.getName(), new DefaultMatchmakeCheckFilter(f.getCheck()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new DefaultMatchmakeUserProperty(p.getUserId(), props, filters);
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,9 @@ class DefaultRecordId implements RecordId {
|
||||
|
||||
private final String key;
|
||||
|
||||
private final byte[] version;
|
||||
private final String version;
|
||||
|
||||
static RecordId fromProto(final @NonNull com.heroiclabs.nakama.Api.TStorageKeys.StorageKey key) {
|
||||
return new DefaultRecordId(key.getBucket(), key.getCollection(), key.getRecord(), key.getVersion().toByteArray());
|
||||
return new DefaultRecordId(key.getBucket(), key.getCollection(), key.getRecord(), key.getVersion());
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,15 @@ class DefaultRpcResult implements RpcResult {
|
||||
|
||||
private final String id;
|
||||
|
||||
private final byte[] payload;
|
||||
private final String payload;
|
||||
|
||||
@Override
|
||||
public <T> T getPayload(Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(payload), clazz);
|
||||
return DefaultClient.GSON.fromJson(payload, clazz);
|
||||
}
|
||||
|
||||
static RpcResult fromProto(final @NonNull com.heroiclabs.nakama.Api.TRpc rpc) {
|
||||
return new DefaultRpcResult(rpc.getId(), rpc.getPayload().toByteArray());
|
||||
return new DefaultRpcResult(rpc.getId(), rpc.getPayload());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class DefaultSelf implements Self {
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
@@ -41,7 +41,7 @@ class DefaultSelf implements Self {
|
||||
|
||||
private final String location;
|
||||
|
||||
private final byte[] metadata;
|
||||
private final String metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
@@ -64,14 +64,14 @@ class DefaultSelf implements Self {
|
||||
private final boolean verified;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static Self fromProto(final @NonNull com.heroiclabs.nakama.Api.Self self) {
|
||||
return new DefaultSelf(self.getUser().getAvatarUrl(), self.getUser().getCreatedAt(),
|
||||
self.getUser().getFullname(), self.getUser().getHandle(), self.getUser().getId().toByteArray(),
|
||||
self.getUser().getFullname(), self.getUser().getHandle(), self.getUser().getId(),
|
||||
self.getUser().getLang(), self.getUser().getLastOnlineAt(), self.getUser().getLocation(),
|
||||
self.getUser().getMetadata().toByteArray(), self.getUser().getTimezone(), self.getUser().getUpdatedAt(),
|
||||
self.getUser().getMetadata(), self.getUser().getTimezone(), self.getUser().getUpdatedAt(),
|
||||
self.getCustomId(), self.getDeviceIdsList(), self.getEmail(), self.getFacebookId(),
|
||||
self.getGamecenterId(), self.getGoogleId(), self.getSteamId(), self.getVerified());
|
||||
}
|
||||
|
||||
@@ -21,12 +21,10 @@ import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.ByteBuffer;
|
||||
import okio.*;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@@ -38,7 +36,7 @@ public class DefaultSession implements Session {
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
|
||||
private final String token;
|
||||
|
||||
@@ -54,12 +52,7 @@ public class DefaultSession implements Session {
|
||||
createdAt = System.currentTimeMillis();
|
||||
expiresAt = Math.round(((Double) jsonMap.get("exp")) * 1000L);
|
||||
handle = jsonMap.get("han").toString();
|
||||
|
||||
final UUID uid = UUID.fromString(jsonMap.get("uid").toString());
|
||||
final ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
||||
bb.putLong(uid.getMostSignificantBits());
|
||||
bb.putLong(uid.getLeastSignificantBits());
|
||||
id = bb.array();
|
||||
id = jsonMap.get("uid").toString();
|
||||
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@@ -37,23 +37,23 @@ class DefaultStorageRecord implements StorageRecord {
|
||||
|
||||
private final PermissionWrite permissionWrite;
|
||||
|
||||
private final byte[] value;
|
||||
private final String value;
|
||||
|
||||
private final byte[] version;
|
||||
private final String version;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
private final byte[] userId;
|
||||
private final String userId;
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(value), clazz);
|
||||
return DefaultClient.GSON.fromJson(value, clazz);
|
||||
}
|
||||
|
||||
static StorageRecord fromProto(final @NonNull com.heroiclabs.nakama.Api.TStorageData.StorageData data) {
|
||||
return new DefaultStorageRecord(data.getBucket(), data.getCreatedAt(), data.getCollection(),
|
||||
data.getExpiresAt(), data.getRecord(), PermissionRead.fromInt(data.getPermissionRead()),
|
||||
PermissionWrite.fromInt(data.getPermissionWrite()), data.getValue().toByteArray(),
|
||||
data.getVersion().toByteArray(), data.getUpdatedAt(), data.getUserId().toByteArray());
|
||||
PermissionWrite.fromInt(data.getPermissionWrite()), data.getValue(),
|
||||
data.getVersion(), data.getUpdatedAt(), data.getUserId());
|
||||
}
|
||||
}
|
||||
@@ -22,17 +22,17 @@ import lombok.*;
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicId implements TopicId {
|
||||
private final byte[] Id;
|
||||
private final String Id;
|
||||
private final TopicType topicType;
|
||||
|
||||
static TopicId fromProto(final @NonNull com.heroiclabs.nakama.Api.TopicId topicId) {
|
||||
switch (topicId.getIdCase()) {
|
||||
case DM:
|
||||
return new DefaultTopicId(topicId.getDm().toByteArray(), TopicType.DirectMessage);
|
||||
return new DefaultTopicId(topicId.getDm(), TopicType.DirectMessage);
|
||||
case ROOM:
|
||||
return new DefaultTopicId(topicId.getRoom().toByteArray(), TopicType.Room);
|
||||
return new DefaultTopicId(topicId.getRoom(), TopicType.Room);
|
||||
case GROUP_ID:
|
||||
return new DefaultTopicId(topicId.getGroupId().toByteArray(), TopicType.Group);
|
||||
return new DefaultTopicId(topicId.getGroupId(), TopicType.Group);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,24 +23,24 @@ import lombok.*;
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultTopicMessage implements TopicMessage {
|
||||
private final TopicId topic;
|
||||
private final byte[] userId;
|
||||
private final byte[] messageId;
|
||||
private final String userId;
|
||||
private final String messageId;
|
||||
private final long createdAt;
|
||||
private final long expiresAt;
|
||||
private final String handle;
|
||||
private final TopicMessageType type;
|
||||
private final byte[] data;
|
||||
private final String data;
|
||||
|
||||
static TopicMessage fromProto(final @NonNull com.heroiclabs.nakama.Api.TopicMessage message) {
|
||||
return new DefaultTopicMessage(
|
||||
DefaultTopicId.fromProto(message.getTopic()),
|
||||
message.getUserId().toByteArray(),
|
||||
message.getMessageId().toByteArray(),
|
||||
message.getUserId(),
|
||||
message.getMessageId(),
|
||||
message.getCreatedAt(),
|
||||
message.getExpiresAt(),
|
||||
message.getHandle(),
|
||||
TopicMessageType.fromProto((int)message.getType()),
|
||||
message.getData().toByteArray()
|
||||
message.getData()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,12 @@ import lombok.*;
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultTopicMessageAck implements TopicMessageAck {
|
||||
private final byte[] messageId;
|
||||
private final String messageId;
|
||||
private final String handle;
|
||||
private final long createdAt;
|
||||
private final long expiresAt;
|
||||
|
||||
static TopicMessageAck fromProto(final @NonNull com.heroiclabs.nakama.Api.TTopicMessageAck ack) {
|
||||
return new DefaultTopicMessageAck(ack.getMessageId().toByteArray(), ack.getHandle(), ack.getCreatedAt(), ack.getExpiresAt());
|
||||
return new DefaultTopicMessageAck(ack.getMessageId(), ack.getHandle(), ack.getCreatedAt(), ack.getExpiresAt());
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class DefaultUser implements User {
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
private final String id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
@@ -39,21 +39,21 @@ class DefaultUser implements User {
|
||||
|
||||
private final String location;
|
||||
|
||||
private final byte[] metadata;
|
||||
private final String metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
return DefaultClient.GSON.fromJson(metadata, clazz);
|
||||
}
|
||||
|
||||
static User fromProto(final @NonNull com.heroiclabs.nakama.Api.User user) {
|
||||
return new DefaultUser(user.getAvatarUrl(), user.getCreatedAt(),
|
||||
user.getFullname(), user.getHandle(), user.getId().toByteArray(),
|
||||
user.getFullname(), user.getHandle(), user.getId(),
|
||||
user.getLang(), user.getLastOnlineAt(), user.getLocation(),
|
||||
user.getMetadata().toByteArray(), user.getTimezone(), user.getUpdatedAt());
|
||||
user.getMetadata(), user.getTimezone(), user.getUpdatedAt());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,18 +18,15 @@ package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultUserPresence implements UserPresence {
|
||||
private final byte[] userId;
|
||||
private final byte[] sessionId;
|
||||
private final String userId;
|
||||
private final String sessionId;
|
||||
private final String handle;
|
||||
|
||||
static UserPresence fromProto(final @NonNull com.heroiclabs.nakama.Api.UserPresence presence) {
|
||||
return new DefaultUserPresence(presence.getUserId().toByteArray(), presence.getSessionId().toByteArray(), presence.getHandle());
|
||||
return new DefaultUserPresence(presence.getUserId(), presence.getSessionId(), presence.getHandle());
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,13 @@ public abstract class Error extends Exception {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The error message to construct with.
|
||||
*/
|
||||
public Error(final @NonNull String message, final @NonNull Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error code for the problem.
|
||||
*/
|
||||
@@ -108,4 +115,9 @@ public abstract class Error extends Exception {
|
||||
* @return The code for the error.
|
||||
*/
|
||||
public abstract ErrorCode getCode();
|
||||
|
||||
/**
|
||||
* @return The collation ID associated with this error. Could be null.
|
||||
*/
|
||||
public abstract String getCollationId();
|
||||
}
|
||||
@@ -21,34 +21,34 @@ package com.heroiclabs.nakama;
|
||||
*/
|
||||
public interface Leaderboard {
|
||||
/**
|
||||
* @returns Leaderboard ID
|
||||
* @return Leaderboard ID.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @returns Whether leaderboard is server authoritative or not.
|
||||
* @return Whether leaderboard is server authoritative or not.
|
||||
*/
|
||||
boolean isAuthoritative();
|
||||
|
||||
/**
|
||||
* @returns Sort order for the record
|
||||
* @return Sort order for the record.
|
||||
*/
|
||||
long getSort();
|
||||
|
||||
/**
|
||||
* @returns Record count
|
||||
* @return Record count.
|
||||
*/
|
||||
long getCount();
|
||||
|
||||
/**
|
||||
* @returns Reset schedule
|
||||
* @return Reset schedule.
|
||||
*/
|
||||
String getResetSchedule();
|
||||
|
||||
/**
|
||||
* @returns Metadata associated with the leaderboard
|
||||
* @return Metadata associated with the leaderboard.
|
||||
*/
|
||||
byte[] getMetadata();
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
@@ -57,7 +57,7 @@ public interface Leaderboard {
|
||||
*/
|
||||
<T> T getMetadata(final Class<T> clazz);
|
||||
|
||||
byte[] getNextId();
|
||||
String getNextId();
|
||||
|
||||
byte[] getPrevId();
|
||||
String getPrevId();
|
||||
}
|
||||
@@ -24,32 +24,32 @@ import java.util.List;
|
||||
public interface LeaderboardRecord {
|
||||
|
||||
/**
|
||||
* @returns Leaderboard ID.
|
||||
* @return Leaderboard ID.
|
||||
*/
|
||||
byte[] getLeaderboardId();
|
||||
String getLeaderboardId();
|
||||
|
||||
/**
|
||||
* @returns User ID that owns this record.
|
||||
* @return User ID that owns this record.
|
||||
*/
|
||||
byte[] getOwnerId();
|
||||
String getOwnerId();
|
||||
|
||||
/**
|
||||
* @returns User handle.
|
||||
* @return User handle.
|
||||
*/
|
||||
String getHandle();
|
||||
|
||||
/**
|
||||
* @returns Language associated with the record.
|
||||
* @return Language associated with the record.
|
||||
*/
|
||||
String getLang();
|
||||
|
||||
/**
|
||||
* @returns Location associated with the record.
|
||||
* @return Location associated with the record.
|
||||
*/
|
||||
String getLocation();
|
||||
|
||||
/**
|
||||
* @returns Timezone associated with the record.
|
||||
* @return Timezone associated with the record.
|
||||
*/
|
||||
String getTimezone();
|
||||
|
||||
@@ -60,9 +60,9 @@ public interface LeaderboardRecord {
|
||||
long getNumScore();
|
||||
|
||||
/**
|
||||
* @returns Metadata associated with the leaderboard record.
|
||||
* @return Metadata associated with the leaderboard record.
|
||||
*/
|
||||
byte[] getMetadata();
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
@@ -74,12 +74,12 @@ public interface LeaderboardRecord {
|
||||
long getRankedAt();
|
||||
|
||||
/**
|
||||
* @returns When the record was last updated
|
||||
* @return When the record was last updated
|
||||
*/
|
||||
long getUpdatedAt();
|
||||
|
||||
/**
|
||||
* @returns When the record expires.
|
||||
* @return When the record expires.
|
||||
*/
|
||||
long getExpiresAt();
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -28,9 +27,9 @@ public interface LeaderboardRecordWriteMessage extends CollatedMessage<ResultSet
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.Builder write;
|
||||
|
||||
public static LeaderboardRecordWriteMessage.LeaderboardRecordWrite newBuilder(final @NonNull byte[] leaderboardId) {
|
||||
public static LeaderboardRecordWriteMessage.LeaderboardRecordWrite newBuilder(final @NonNull String leaderboardId) {
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.Builder b = com.heroiclabs.nakama.Api.TLeaderboardRecordsWrite.LeaderboardRecordWrite.newBuilder();
|
||||
b.setLeaderboardId(ByteString.copyFrom(leaderboardId));
|
||||
b.setLeaderboardId(leaderboardId);
|
||||
return new LeaderboardRecordWriteMessage.LeaderboardRecordWrite(b);
|
||||
}
|
||||
|
||||
@@ -44,8 +43,8 @@ public interface LeaderboardRecordWriteMessage extends CollatedMessage<ResultSet
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite metadata(final @NonNull byte[] metadata) {
|
||||
write.setMetadata(ByteString.copyFrom(metadata));
|
||||
public LeaderboardRecordWriteMessage.LeaderboardRecordWrite metadata(final @NonNull String metadata) {
|
||||
write.setMetadata(metadata);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,8 +32,8 @@ public interface LeaderboardRecordsFetchMessage extends CollatedMessage<ResultSe
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsFetch.Builder fetch;
|
||||
|
||||
public LeaderboardRecordsFetchMessage.Builder fetch(final @NonNull byte[] leaderboardId) {
|
||||
fetch.addLeaderboardIds(ByteString.copyFrom(leaderboardId));
|
||||
public LeaderboardRecordsFetchMessage.Builder fetch(final @NonNull String leaderboardId) {
|
||||
fetch.addLeaderboardIds(leaderboardId);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -43,8 +42,8 @@ public interface LeaderboardRecordsFetchMessage extends CollatedMessage<ResultSe
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsFetchMessage.Builder cursor(final @NonNull byte[] cursor) {
|
||||
fetch.setCursor(ByteString.copyFrom(cursor));
|
||||
public LeaderboardRecordsFetchMessage.Builder cursor(final @NonNull String cursor) {
|
||||
fetch.setCursor(cursor);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -28,24 +27,24 @@ public interface LeaderboardRecordsListMessage extends CollatedMessage<ResultSet
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static LeaderboardRecordsListMessage.Builder newBuilder(final @NonNull byte[] leaderboardId) {
|
||||
public static LeaderboardRecordsListMessage.Builder newBuilder(final @NonNull String leaderboardId) {
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Builder b = com.heroiclabs.nakama.Api.TLeaderboardRecordsList.newBuilder();
|
||||
b.setLeaderboardId(ByteString.copyFrom(leaderboardId));
|
||||
b.setLeaderboardId(leaderboardId);
|
||||
return new DefaultLeaderboardRecordsListMessage.Builder(b);
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Builder listing;
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerId(final @NonNull byte[] ownerId) {
|
||||
listing.setOwnerId(ByteString.copyFrom(ownerId));
|
||||
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerId(final @NonNull String ownerId) {
|
||||
listing.setOwnerId(ownerId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerIds(final @NonNull List<byte[]> ownerIds) {
|
||||
public LeaderboardRecordsListMessage.Builder filterByPagingToOwnerIds(final @NonNull List<String> ownerIds) {
|
||||
com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Owners.Builder o = com.heroiclabs.nakama.Api.TLeaderboardRecordsList.Owners.newBuilder();
|
||||
for (byte[] b : ownerIds) {
|
||||
o.addOwnerIds(ByteString.copyFrom(b));
|
||||
for (String b : ownerIds) {
|
||||
o.addOwnerIds(b);
|
||||
}
|
||||
listing.setOwnerIds(o);
|
||||
return this;
|
||||
@@ -66,8 +65,8 @@ public interface LeaderboardRecordsListMessage extends CollatedMessage<ResultSet
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardRecordsListMessage.Builder cursor(final @NonNull byte[] cursor) {
|
||||
listing.setCursor(ByteString.copyFrom(cursor));
|
||||
public LeaderboardRecordsListMessage.Builder cursor(final @NonNull String cursor) {
|
||||
listing.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;
|
||||
@@ -38,13 +37,13 @@ public interface LeaderboardsListMessage extends CollatedMessage<ResultSet<Leade
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardsListMessage.Builder addFilter(final @NonNull byte[] leaderboardId) {
|
||||
listing.addFilterLeaderboardId(ByteString.copyFrom(leaderboardId));
|
||||
public LeaderboardsListMessage.Builder addFilter(final @NonNull String leaderboardId) {
|
||||
listing.addFilterLeaderboardId(leaderboardId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LeaderboardsListMessage.Builder cursor(final @NonNull byte[] cursor) {
|
||||
listing.setCursor(ByteString.copyFrom(cursor));
|
||||
public LeaderboardsListMessage.Builder cursor(final @NonNull String cursor) {
|
||||
listing.setCursor(cursor);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,21 +19,21 @@ package com.heroiclabs.nakama;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object which represents a match object.
|
||||
* The object which represents a match.
|
||||
*/
|
||||
public interface Match {
|
||||
/**
|
||||
* @returns Match ID
|
||||
* @return Match ID.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @returns List of presences in this match.
|
||||
* @return List of presences in this match.
|
||||
*/
|
||||
List<UserPresence> getPresence();
|
||||
|
||||
/**
|
||||
* @returns Match presence for the current user.
|
||||
* @return Match presence for the current user.
|
||||
*/
|
||||
UserPresence getSelf();
|
||||
}
|
||||
@@ -16,29 +16,27 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object which represents a match data object.
|
||||
* The object which represents match data.
|
||||
*/
|
||||
public interface MatchData {
|
||||
/**
|
||||
* @returns Match ID
|
||||
* @return Match ID.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @returns Match Data
|
||||
* @return Match Data.
|
||||
*/
|
||||
byte[] getData();
|
||||
|
||||
/**
|
||||
* @returns Data opcode
|
||||
* @return Data opcode.
|
||||
*/
|
||||
long getOpCode();
|
||||
|
||||
/**
|
||||
* @returns Presence for the current match data.
|
||||
* @return Presence for the current match data.
|
||||
*/
|
||||
UserPresence getPresence();
|
||||
}
|
||||
@@ -25,9 +25,9 @@ public interface MatchDataSendMessage extends UncollatedMessage {
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static MatchDataSendMessage.Builder newBuilder(final @NonNull byte[] matchId) {
|
||||
public static MatchDataSendMessage.Builder newBuilder(final @NonNull String matchId) {
|
||||
return new DefaultMatchDataSendMessage.Builder(com.heroiclabs.nakama.Api.MatchDataSend.newBuilder()
|
||||
.setMatchId(ByteString.copyFrom(matchId)));
|
||||
.setMatchId(matchId));
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
@@ -47,8 +47,8 @@ public interface MatchDataSendMessage extends UncollatedMessage {
|
||||
for (UserPresence p : presences) {
|
||||
com.heroiclabs.nakama.Api.UserPresence.Builder up = com.heroiclabs.nakama.Api.UserPresence.newBuilder();
|
||||
up.setHandle(p.getHandle());
|
||||
up.setSessionId(ByteString.copyFrom(p.getSessionId()));
|
||||
up.setUserId(ByteString.copyFrom(p.getUserId()));
|
||||
up.setSessionId(p.getSessionId());
|
||||
up.setUserId(p.getUserId());
|
||||
matchData.addPresences(up);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface MatchPresence {
|
||||
/**
|
||||
* @return The ID associated with this presence update
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return Users that have joined
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
/**
|
||||
* The object which represents a match token object.
|
||||
* The object which represents a match token.
|
||||
*/
|
||||
public interface MatchToken {
|
||||
/**
|
||||
* @returns Match Token
|
||||
* @return Match Token.
|
||||
*/
|
||||
byte[] getToken();
|
||||
String getToken();
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,16 +32,16 @@ public interface MatchesJoinMessage extends CollatedMessage<ResultSet<Match>> {
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TMatchesJoin.Builder joins;
|
||||
|
||||
public MatchesJoinMessage.Builder matchId(final @NonNull byte[] matchId) {
|
||||
public MatchesJoinMessage.Builder matchId(final @NonNull String matchId) {
|
||||
com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.newBuilder();
|
||||
topicJoinBuilder.setMatchId(ByteString.copyFrom(matchId));
|
||||
topicJoinBuilder.setMatchId(matchId);
|
||||
joins.addMatches(topicJoinBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchesJoinMessage.Builder token(final @NonNull MatchToken token) {
|
||||
com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TMatchesJoin.MatchJoin.newBuilder();
|
||||
topicJoinBuilder.setToken(ByteString.copyFrom(token.getToken()));
|
||||
topicJoinBuilder.setToken(token.getToken());
|
||||
joins.addMatches(topicJoinBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,8 +32,8 @@ public interface MatchesLeaveMessage extends CollatedMessage<Boolean> {
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TMatchesLeave.Builder leaves;
|
||||
|
||||
public MatchesLeaveMessage.Builder matchId(final @NonNull byte[] matchId) {
|
||||
leaves.addMatchIds(ByteString.copyFrom(matchId));
|
||||
public MatchesLeaveMessage.Builder matchId(final @NonNull String matchId) {
|
||||
leaves.addMatchIds(matchId);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,89 @@
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MatchmakeAddMessage extends CollatedMessage<MatchmakeTicket> {
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static MatchmakeAddMessage.Builder newBuilder(long requiredCount) {
|
||||
com.heroiclabs.nakama.Api.TMatchmakeAdd.Builder add = com.heroiclabs.nakama.Api.TMatchmakeAdd.newBuilder()
|
||||
.setRequiredCount(requiredCount);
|
||||
return new MatchmakeAddMessage.Builder(add);
|
||||
}
|
||||
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TMatchmakeAdd.Builder add;
|
||||
|
||||
public MatchmakeAddMessage.Builder addTermFilter(String name, Set<String> terms, boolean matchAllTerms)
|
||||
{
|
||||
com.heroiclabs.nakama.Api.MatchmakeFilter.TermFilter.Builder f = com.heroiclabs.nakama.Api.MatchmakeFilter.TermFilter.newBuilder()
|
||||
.addAllTerms(terms)
|
||||
.setMatchAllTerms(matchAllTerms);
|
||||
|
||||
add.addFilters(com.heroiclabs.nakama.Api.MatchmakeFilter.newBuilder().setName(name).setTerm(f));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchmakeAddMessage.Builder addRangeFilter(String name, long lowerbound, long upperbound)
|
||||
{
|
||||
com.heroiclabs.nakama.Api.MatchmakeFilter.RangeFilter.Builder f = com.heroiclabs.nakama.Api.MatchmakeFilter.RangeFilter.newBuilder()
|
||||
.setLowerBound(lowerbound)
|
||||
.setUpperBound(upperbound);
|
||||
|
||||
add.addFilters(com.heroiclabs.nakama.Api.MatchmakeFilter.newBuilder().setName(name).setRange(f));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchmakeAddMessage.Builder addCheckFilter(String name, boolean value)
|
||||
{
|
||||
add.addFilters(com.heroiclabs.nakama.Api.MatchmakeFilter.newBuilder().setName(name).setCheck(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchmakeAddMessage.Builder addProperty(String key, boolean value)
|
||||
{
|
||||
com.heroiclabs.nakama.Api.PropertyPair.Builder p = com.heroiclabs.nakama.Api.PropertyPair.newBuilder()
|
||||
.setKey(key)
|
||||
.setBoolValue(value);
|
||||
|
||||
add.addProperties(p);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchmakeAddMessage.Builder addProperty(String key, long value)
|
||||
{
|
||||
com.heroiclabs.nakama.Api.PropertyPair.Builder p = com.heroiclabs.nakama.Api.PropertyPair.newBuilder()
|
||||
.setKey(key)
|
||||
.setIntValue(value);
|
||||
|
||||
add.addProperties(p);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchmakeAddMessage.Builder addProperty(String key, Set<String> values)
|
||||
{
|
||||
com.heroiclabs.nakama.Api.PropertyPair.Builder p = com.heroiclabs.nakama.Api.PropertyPair.newBuilder()
|
||||
.setKey(key)
|
||||
.setStringSet(com.heroiclabs.nakama.Api.PropertyPair.StringSet.newBuilder().addAllValues(values));
|
||||
|
||||
add.addProperties(p);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MatchmakeAddMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setMatchmakeAdd(add);
|
||||
return new DefaultMatchmakeAddMessage(payload);
|
||||
}
|
||||
|
||||
public static MatchmakeAddMessage build(long requiredCount) {
|
||||
com.heroiclabs.nakama.Api.TMatchmakeAdd.Builder add = com.heroiclabs.nakama.Api.TMatchmakeAdd.newBuilder()
|
||||
.setRequiredCount(requiredCount);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
public interface MatchmakeCheckFilter extends MatchmakeFilter {
|
||||
/**
|
||||
* @return Filter value
|
||||
*/
|
||||
boolean isValue();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
public interface MatchmakeFilter { }
|
||||
@@ -19,26 +19,31 @@ package com.heroiclabs.nakama;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The object which represents a matchmake matched object.
|
||||
* The object which represents a matchmake matched.
|
||||
*/
|
||||
public interface MatchmakeMatched {
|
||||
/**
|
||||
* @returns Matchmaking Ticket.
|
||||
* @return Matchmaking Ticket.
|
||||
*/
|
||||
MatchmakeTicket getTicket();
|
||||
|
||||
/**
|
||||
* @returns List of presences in this match.
|
||||
* @return List of presences in this match.
|
||||
*/
|
||||
List<UserPresence> getPresence();
|
||||
|
||||
/**
|
||||
* @returns Match token.
|
||||
* @return Match token.
|
||||
*/
|
||||
MatchToken getToken();
|
||||
|
||||
/**
|
||||
* @returns Match presence for the current user.
|
||||
* @return Match presence for the current user.
|
||||
*/
|
||||
UserPresence getSelf();
|
||||
|
||||
/**
|
||||
* @return Match properties for matched users.
|
||||
*/
|
||||
List<MatchmakeUserProperty> getProperties();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
public interface MatchmakeRangeFilter extends MatchmakeFilter {
|
||||
/**
|
||||
* @return Range lower bound
|
||||
*/
|
||||
long getLowerbound();
|
||||
|
||||
/**
|
||||
* @return Range upper bound
|
||||
*/
|
||||
long getUpperbound();
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -28,7 +27,7 @@ public interface MatchmakeRemoveMessage extends CollatedMessage<Boolean> {
|
||||
|
||||
public static MatchmakeRemoveMessage build(@NonNull MatchmakeTicket ticket) {
|
||||
com.heroiclabs.nakama.Api.TMatchmakeRemove.Builder remove = com.heroiclabs.nakama.Api.TMatchmakeRemove.newBuilder();
|
||||
remove.setTicket(ByteString.copyFrom(ticket.getTicket()));
|
||||
remove.setTicket(ticket.getTicket());
|
||||
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MatchmakeTermFilter extends MatchmakeFilter {
|
||||
/**
|
||||
* @return Matching terms
|
||||
*/
|
||||
List<String> getTerms();
|
||||
|
||||
/**
|
||||
* @return Whether to match all terms, or match any of the terms
|
||||
*/
|
||||
boolean isMatchingAllTerms();
|
||||
}
|
||||
@@ -17,11 +17,11 @@
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
/**
|
||||
* The object which represents a matchmake object.
|
||||
* The object which represents a matchmake.
|
||||
*/
|
||||
public interface MatchmakeTicket {
|
||||
/**
|
||||
* @returns Matchmake Ticket
|
||||
* @return Matchmake Ticket
|
||||
*/
|
||||
byte[] getTicket();
|
||||
String getTicket();
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2017 The Nakama Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Properties associated with each matched user
|
||||
*/
|
||||
public interface MatchmakeUserProperty {
|
||||
/**
|
||||
* @return Matchmake user ID
|
||||
*/
|
||||
String getUserId();
|
||||
|
||||
/**
|
||||
* @return Matchmake user properties
|
||||
*/
|
||||
Map<String, Object> getProperties();
|
||||
|
||||
/**
|
||||
* @return Matchmake user filters
|
||||
*/
|
||||
Map<String, MatchmakeFilter> getFilters();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface TopicId {
|
||||
/**
|
||||
* @return Topic ID
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return Type of Topic this is - DM, Group, Room
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -33,23 +32,23 @@ public interface TopicJoinMessage extends CollatedMessage<ResultSet<Topic>> {
|
||||
private final @NonNull
|
||||
com.heroiclabs.nakama.Api.TTopicsJoin.Builder joins;
|
||||
|
||||
public TopicJoinMessage.Builder topicDirectMessage(final @NonNull byte[] userId) {
|
||||
public TopicJoinMessage.Builder topicDirectMessage(final @NonNull String userId) {
|
||||
com.heroiclabs.nakama.Api.TTopicsJoin.TopicJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TTopicsJoin.TopicJoin.newBuilder();
|
||||
topicJoinBuilder.setUserId(ByteString.copyFrom(userId));
|
||||
topicJoinBuilder.setUserId(userId);
|
||||
joins.addJoins(topicJoinBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TopicJoinMessage.Builder topicRoom(final @NonNull byte[] room) {
|
||||
public TopicJoinMessage.Builder topicRoom(final @NonNull String room) {
|
||||
com.heroiclabs.nakama.Api.TTopicsJoin.TopicJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TTopicsJoin.TopicJoin.newBuilder();
|
||||
topicJoinBuilder.setRoom(ByteString.copyFrom(room));
|
||||
topicJoinBuilder.setRoom(room);
|
||||
joins.addJoins(topicJoinBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TopicJoinMessage.Builder topicGroup(final @NonNull byte[] group) {
|
||||
public TopicJoinMessage.Builder topicGroup(final @NonNull String groupId) {
|
||||
com.heroiclabs.nakama.Api.TTopicsJoin.TopicJoin.Builder topicJoinBuilder = com.heroiclabs.nakama.Api.TTopicsJoin.TopicJoin.newBuilder();
|
||||
topicJoinBuilder.setGroupId(ByteString.copyFrom(group));
|
||||
topicJoinBuilder.setGroupId(groupId);
|
||||
joins.addJoins(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;
|
||||
@@ -38,13 +37,13 @@ public interface TopicLeaveMessage extends CollatedMessage<Boolean> {
|
||||
com.heroiclabs.nakama.Api.TopicId.Builder topicBuilder = null;
|
||||
switch (topicId.getTopicType()) {
|
||||
case Room:
|
||||
topicBuilder = com.heroiclabs.nakama.Api.TopicId.newBuilder().setRoom(ByteString.copyFrom(topicId.getId()));
|
||||
topicBuilder = com.heroiclabs.nakama.Api.TopicId.newBuilder().setRoom(topicId.getId());
|
||||
break;
|
||||
case Group:
|
||||
topicBuilder = com.heroiclabs.nakama.Api.TopicId.newBuilder().setGroupId(ByteString.copyFrom(topicId.getId()));
|
||||
topicBuilder = com.heroiclabs.nakama.Api.TopicId.newBuilder().setGroupId(topicId.getId());
|
||||
break;
|
||||
case DirectMessage:
|
||||
topicBuilder = com.heroiclabs.nakama.Api.TopicId.newBuilder().setDm(ByteString.copyFrom(topicId.getId()));
|
||||
topicBuilder = com.heroiclabs.nakama.Api.TopicId.newBuilder().setDm(topicId.getId());
|
||||
break;
|
||||
}
|
||||
topicLeave.addTopics(topicBuilder);
|
||||
|
||||
@@ -46,42 +46,42 @@ public interface TopicMessage {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns Topic ID associated with this message
|
||||
* @return Topic ID associated with this message.
|
||||
*/
|
||||
TopicId getTopic();
|
||||
|
||||
/**
|
||||
* @returns User ID associcated with this message
|
||||
* @return User ID associated with this message.
|
||||
*/
|
||||
byte[] getUserId();
|
||||
String getUserId();
|
||||
|
||||
/**
|
||||
* @returns Message ID
|
||||
* @return Message ID.
|
||||
*/
|
||||
byte[] getMessageId();
|
||||
String getMessageId();
|
||||
|
||||
/**
|
||||
* @returns When message was created
|
||||
* @return When message was created.
|
||||
*/
|
||||
long getCreatedAt();
|
||||
|
||||
/**
|
||||
* @returns When message expires
|
||||
* @return When message expires.
|
||||
*/
|
||||
long getExpiresAt();
|
||||
|
||||
/**
|
||||
* @returns User Handle associated with this message
|
||||
* @return User Handle associated with this message.
|
||||
*/
|
||||
String getHandle();
|
||||
|
||||
/**
|
||||
* @returns Message Type
|
||||
* @return Message Type.
|
||||
*/
|
||||
TopicMessageType getType();
|
||||
|
||||
/**
|
||||
* @returns Data in the message
|
||||
* @return Data in the message.
|
||||
*/
|
||||
byte[] getData();
|
||||
String getData();
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public interface TopicMessageAck {
|
||||
/**
|
||||
* @return ID of this message acked;
|
||||
*/
|
||||
byte[] getMessageId();
|
||||
String getMessageId();
|
||||
|
||||
/**
|
||||
* @return User Handle;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -26,19 +25,19 @@ public interface TopicMessageSendMessage extends CollatedMessage<TopicMessageAck
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
public static TopicMessageSendMessage build(final @NonNull TopicId topicId, final @NonNull byte[] data) {
|
||||
public static TopicMessageSendMessage build(final @NonNull TopicId topicId, final @NonNull String data) {
|
||||
com.heroiclabs.nakama.Api.TTopicMessageSend.Builder msg = com.heroiclabs.nakama.Api.TTopicMessageSend.newBuilder();
|
||||
|
||||
msg.setData(ByteString.copyFrom(data));
|
||||
msg.setData(data);
|
||||
switch (topicId.getTopicType()) {
|
||||
case Room:
|
||||
msg.setTopic(com.heroiclabs.nakama.Api.TopicId.newBuilder().setRoom(ByteString.copyFrom(topicId.getId())));
|
||||
msg.setTopic(com.heroiclabs.nakama.Api.TopicId.newBuilder().setRoom(topicId.getId()));
|
||||
break;
|
||||
case Group:
|
||||
msg.setTopic(com.heroiclabs.nakama.Api.TopicId.newBuilder().setGroupId(ByteString.copyFrom(topicId.getId())));
|
||||
msg.setTopic(com.heroiclabs.nakama.Api.TopicId.newBuilder().setGroupId(topicId.getId()));
|
||||
break;
|
||||
case DirectMessage:
|
||||
msg.setTopic(com.heroiclabs.nakama.Api.TopicId.newBuilder().setDm(ByteString.copyFrom(topicId.getId())));
|
||||
msg.setTopic(com.heroiclabs.nakama.Api.TopicId.newBuilder().setDm(topicId.getId()));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -39,7 +38,7 @@ public interface TopicMessagesListMessage extends CollatedMessage<ResultSet<Topi
|
||||
}
|
||||
|
||||
public TopicMessagesListMessage.Builder cursor(final @NonNull Cursor cursor) {
|
||||
lists.setCursor(ByteString.copyFrom(cursor.getValue()));
|
||||
lists.setCursor(cursor.getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -48,18 +47,18 @@ public interface TopicMessagesListMessage extends CollatedMessage<ResultSet<Topi
|
||||
return this;
|
||||
}
|
||||
|
||||
public TopicMessagesListMessage.Builder topicDirectMessage(final @NonNull byte[] userId) {
|
||||
lists.setUserId(ByteString.copyFrom(userId));
|
||||
public TopicMessagesListMessage.Builder topicDirectMessage(final @NonNull String userId) {
|
||||
lists.setUserId(userId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TopicMessagesListMessage.Builder topicRoom(final @NonNull byte[] room) {
|
||||
lists.setRoom(ByteString.copyFrom(room));
|
||||
public TopicMessagesListMessage.Builder topicRoom(final @NonNull String room) {
|
||||
lists.setRoom(room);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TopicMessagesListMessage.Builder topicGroup(final @NonNull byte[] groupId) {
|
||||
lists.setGroupId(ByteString.copyFrom(groupId));
|
||||
public TopicMessagesListMessage.Builder topicGroup(final @NonNull String groupId) {
|
||||
lists.setGroupId(groupId);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public interface User {
|
||||
/**
|
||||
* @return The ID of the user.
|
||||
*/
|
||||
byte[] getId();
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* @return The (BCP-47) lang tag set by the user.
|
||||
@@ -63,7 +63,7 @@ public interface User {
|
||||
/**
|
||||
* @return The metadata stored for the user.
|
||||
*/
|
||||
byte[] getMetadata();
|
||||
String getMetadata();
|
||||
|
||||
/**
|
||||
* @param clazz A hint for the type of the class.
|
||||
|
||||
@@ -20,12 +20,12 @@ public interface UserPresence {
|
||||
/**
|
||||
* @return User ID
|
||||
*/
|
||||
byte[] getUserId();
|
||||
String getUserId();
|
||||
|
||||
/**
|
||||
* @return Session ID associated with this presence
|
||||
*/
|
||||
byte[] getSessionId();
|
||||
String getSessionId();
|
||||
|
||||
/**
|
||||
* @return User Handle
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -32,9 +31,9 @@ public interface UsersFetchMessage extends CollatedMessage<ResultSet<User>> {
|
||||
|
||||
private final @NonNull com.heroiclabs.nakama.Api.TUsersFetch.Builder usersFetches;
|
||||
|
||||
public Builder id(final @NonNull byte[] id) {
|
||||
public Builder id(final @NonNull String id) {
|
||||
usersFetches.addUsers(com.heroiclabs.nakama.Api.TUsersFetch.UsersFetch.newBuilder()
|
||||
.setUserId(ByteString.copyFrom(id)));
|
||||
.setUserId(id));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ package com.heroiclabs.nakama;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class DefaultSessionTest {
|
||||
|
||||
private static final String JWT_TOKEN =
|
||||
@@ -31,7 +28,7 @@ public final class DefaultSessionTest {
|
||||
|
||||
private static final String JWT_TOKEN_HANDLE = "XaFTAVsJQf";
|
||||
|
||||
private static final UUID JWT_TOKEN_ID = UUID.fromString("f13ac73a-904a-45ce-87f6-ef2db37ff91a");
|
||||
private static final String JWT_TOKEN_ID = "f13ac73a-904a-45ce-87f6-ef2db37ff91a";
|
||||
|
||||
@Test
|
||||
public void sessionRestore() {
|
||||
@@ -39,11 +36,7 @@ public final class DefaultSessionTest {
|
||||
|
||||
Assert.assertEquals(JWT_TOKEN, session.getToken());
|
||||
Assert.assertEquals(JWT_TOKEN_HANDLE, session.getHandle());
|
||||
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(session.getId());
|
||||
Long high = byteBuffer.getLong();
|
||||
Long low = byteBuffer.getLong();
|
||||
Assert.assertEquals(JWT_TOKEN_ID, new UUID(high, low));
|
||||
Assert.assertEquals(JWT_TOKEN_ID, session.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,6 +23,8 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -40,6 +42,9 @@ public class MatchmakeAddMessageTest {
|
||||
private CountDownLatch latch3;
|
||||
private MatchData data;
|
||||
|
||||
private MatchmakeMatched matched1;
|
||||
private MatchmakeMatched matched2;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
client1 = DefaultClient.builder("defaultkey").listener(new ClientListener() {
|
||||
@@ -48,6 +53,7 @@ public class MatchmakeAddMessageTest {
|
||||
@Override public void onTopicPresence(TopicPresence presence) {}
|
||||
@Override public void onMatchmakeMatched(MatchmakeMatched matched) {
|
||||
token1 = matched.getToken();
|
||||
matched1 = matched;
|
||||
latch1.countDown();
|
||||
}
|
||||
@Override public void onMatchData(MatchData matchData) {
|
||||
@@ -65,6 +71,7 @@ public class MatchmakeAddMessageTest {
|
||||
@Override public void onTopicPresence(TopicPresence presence) {}
|
||||
@Override public void onMatchmakeMatched(MatchmakeMatched matched) {
|
||||
token2 = matched.getToken();
|
||||
matched2 = matched;
|
||||
latch2.countDown();
|
||||
}
|
||||
@Override public void onMatchData(MatchData matchData) {}
|
||||
@@ -108,13 +115,27 @@ public class MatchmakeAddMessageTest {
|
||||
}).addCallbackDeferring(new Callback<Deferred<MatchmakeTicket>, Session>() {
|
||||
@Override
|
||||
public Deferred<MatchmakeTicket> call(Session session) throws Exception {
|
||||
final CollatedMessage<MatchmakeTicket> add = MatchmakeAddMessage.Builder.build(2);
|
||||
final CollatedMessage<MatchmakeTicket> add = MatchmakeAddMessage.Builder.newBuilder(2)
|
||||
.addProperty("rank", 12)
|
||||
.addProperty("modes", new HashSet<>(Arrays.asList("tdm", "ffa")))
|
||||
.addProperty("divisions", new HashSet<>(Arrays.asList("silver1")))
|
||||
.addRangeFilter("rank", 10, 15)
|
||||
.addTermFilter("modes", new HashSet<>(Arrays.asList("tdm", "ffa")), false)
|
||||
.addTermFilter("divisions", new HashSet<>(Arrays.asList("bronze3","silver1", "silver2")), false) // like RocketLeague
|
||||
.build();
|
||||
return client1.send(add);
|
||||
}
|
||||
}).addCallbackDeferring(new Callback<Deferred<MatchmakeTicket>, MatchmakeTicket>() {
|
||||
@Override
|
||||
public Deferred<MatchmakeTicket> call(MatchmakeTicket ticket) throws Exception {
|
||||
final CollatedMessage<MatchmakeTicket> add = MatchmakeAddMessage.Builder.build(2);
|
||||
final CollatedMessage<MatchmakeTicket> add = MatchmakeAddMessage.Builder.newBuilder(2)
|
||||
.addProperty("rank", 10)
|
||||
.addProperty("modes", new HashSet<>(Arrays.asList("tdm", "ffa")))
|
||||
.addProperty("divisions", new HashSet<>(Arrays.asList("bronze3")))
|
||||
.addRangeFilter("rank", 8, 12)
|
||||
.addTermFilter("modes", new HashSet<>(Arrays.asList("tdm", "ffa")), false)
|
||||
.addTermFilter("divisions", new HashSet<>(Arrays.asList("bronze2","bronze3", "silver1")), false)
|
||||
.build();
|
||||
return client2.send(add);
|
||||
}
|
||||
});
|
||||
@@ -124,6 +145,15 @@ public class MatchmakeAddMessageTest {
|
||||
Assert.assertNotNull(token1);
|
||||
Assert.assertNotNull(token2);
|
||||
|
||||
MatchmakeUserProperty c1Props = matched1.getProperties().get(0);
|
||||
if (!matched1.getSelf().getUserId().equals(matched1.getProperties().get(0).getUserId()))
|
||||
{
|
||||
c1Props = matched1.getProperties().get(1);
|
||||
}
|
||||
|
||||
Assert.assertEquals(((long)c1Props.getProperties().get("rank")), 12);
|
||||
Assert.assertEquals(((MatchmakeRangeFilter)c1Props.getFilters().get("rank")).getLowerbound(), 10);
|
||||
|
||||
final CollatedMessage<ResultSet<Match>> matchJoin = MatchesJoinMessage.Builder.newBuilder().token(token1).build();
|
||||
final Deferred<ResultSet<Match>> deferred2 = client1.send(matchJoin);
|
||||
deferred2.addCallbackDeferring(new Callback<Deferred<ResultSet<Match>>, ResultSet<Match>>() {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class RpcMessageTest {
|
||||
final String deviceId = UUID.randomUUID().toString();
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final byte[] payload = "foo".getBytes();
|
||||
final String payload = "foo";
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@Override
|
||||
@@ -116,7 +116,7 @@ public class RpcMessageTest {
|
||||
}).addCallback(new Callback<RpcResult, RpcResult>() {
|
||||
@Override
|
||||
public RpcResult call(RpcResult result) throws Exception {
|
||||
Assert.assertArrayEquals(payload, result.getPayload());
|
||||
Assert.assertEquals(payload, result.getPayload());
|
||||
return result;
|
||||
}
|
||||
}).addErrback(new Callback<Error, Error>() {
|
||||
|
||||
@@ -81,7 +81,9 @@ public class SelfUpdateMessageTest {
|
||||
public void testUpdateHandleTooLong() throws Exception {
|
||||
final String deviceId = UUID.randomUUID().toString();
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
final String newHandle = UUID.randomUUID().toString();
|
||||
final String newHandle = UUID.randomUUID().toString() + UUID.randomUUID().toString() +
|
||||
UUID.randomUUID().toString() + UUID.randomUUID().toString() +
|
||||
UUID.randomUUID().toString();
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.UUID;
|
||||
public class StorageFetchMessageTest {
|
||||
|
||||
private Client client;
|
||||
private byte[] userId;
|
||||
private String userId;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -74,7 +74,7 @@ public class StorageFetchMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -121,7 +121,7 @@ public class StorageFetchMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.UUID;
|
||||
public class StorageListMessageTest {
|
||||
|
||||
private Client client;
|
||||
private byte[] userId;
|
||||
private String userId;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -53,7 +53,7 @@ public class StorageListMessageTest {
|
||||
}).addCallbackDeferring(new Callback<Deferred<ResultSet<StorageRecord>>, Session>() {
|
||||
@Override
|
||||
public Deferred<ResultSet<StorageRecord>> call(Session session) throws Exception {
|
||||
final CollatedMessage<ResultSet<StorageRecord>> list = StorageListMessage.Builder.newBuilder(bucket)
|
||||
final CollatedMessage<ResultSet<StorageRecord>> list = StorageListMessage.Builder.newBuilderBucket(bucket)
|
||||
.collection("collection")
|
||||
.build();
|
||||
return client.send(list);
|
||||
@@ -75,7 +75,7 @@ public class StorageListMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -106,7 +106,7 @@ public class StorageListMessageTest {
|
||||
}).addCallbackDeferring(new Callback<Deferred<ResultSet<StorageRecord>>, ResultSet<RecordId>>() {
|
||||
@Override
|
||||
public Deferred<ResultSet<StorageRecord>> call(ResultSet<RecordId> records) throws Exception {
|
||||
final CollatedMessage<ResultSet<StorageRecord>> list = StorageListMessage.Builder.newBuilder(userId)
|
||||
final CollatedMessage<ResultSet<StorageRecord>> list = StorageListMessage.Builder.newBuilderUserId(userId)
|
||||
.bucket(bucket)
|
||||
.collection("collection")
|
||||
.build();
|
||||
@@ -122,8 +122,8 @@ public class StorageListMessageTest {
|
||||
for (StorageRecord record : results.getResults()) {
|
||||
Assert.assertEquals(bucket, record.getBucket());
|
||||
Assert.assertEquals("collection", record.getCollection());
|
||||
Assert.assertArrayEquals(userId, record.getUserId());
|
||||
Assert.assertArrayEquals(value, record.getValue());
|
||||
Assert.assertEquals(userId, record.getUserId());
|
||||
Assert.assertEquals(value, record.getValue());
|
||||
}
|
||||
Assert.assertNull(results.getCursor());
|
||||
return results;
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.UUID;
|
||||
public class StorageRemoveMessageTest {
|
||||
|
||||
private Client client;
|
||||
private byte[] userId;
|
||||
private String userId;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -77,7 +77,7 @@ public class StorageRemoveMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -126,7 +126,7 @@ public class StorageRemoveMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class StorageUpdateMessageTest {
|
||||
public Deferred<ResultSet<RecordId>> call(Session session) throws Exception {
|
||||
final StorageUpdateMessage message = StorageUpdateMessage.Builder.newBuilder()
|
||||
.record(bucket, "collection", "key", StorageUpdateMessage.OpBuilder.newBuilder()
|
||||
.init("/foo", jsonString.getBytes())
|
||||
.init("/foo", jsonString)
|
||||
.incr("/foo/coins", -10))
|
||||
.build();
|
||||
return client.send(message);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StorageWriteMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -78,7 +78,7 @@ public class StorageWriteMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -91,7 +91,7 @@ public class StorageWriteMessageTest {
|
||||
@Override
|
||||
public Deferred<ResultSet<RecordId>> call(Session session) throws Exception {
|
||||
final CollatedMessage<ResultSet<RecordId>> write = StorageWriteMessage.Builder.newBuilder()
|
||||
.record(bucket, "collection", "record", value, "*".getBytes())
|
||||
.record(bucket, "collection", "record", value, "*")
|
||||
.build();
|
||||
return client.send(write);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class StorageWriteMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -143,7 +143,7 @@ public class StorageWriteMessageTest {
|
||||
@Override
|
||||
public Deferred<ResultSet<RecordId>> call(ResultSet<RecordId> records) throws Exception {
|
||||
final CollatedMessage<ResultSet<RecordId>> write = StorageWriteMessage.Builder.newBuilder()
|
||||
.record(bucket, "collection", "record", value, "*".getBytes())
|
||||
.record(bucket, "collection", "record", value, "*")
|
||||
.build();
|
||||
return client.send(write);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class StorageWriteMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -219,7 +219,7 @@ public class StorageWriteMessageTest {
|
||||
final AuthenticateMessage auth = AuthenticateMessage.Builder.device(deviceId);
|
||||
|
||||
final String bucket = UUID.randomUUID().toString();
|
||||
final byte[] value = "{\"foo\":\"bar\"}".getBytes();
|
||||
final String value = "{\"foo\":\"bar\"}";
|
||||
|
||||
final Deferred<Session> deferred = client.register(auth);
|
||||
deferred.addCallbackDeferring(new Callback<Deferred<Session>, Session>() {
|
||||
@@ -246,7 +246,7 @@ public class StorageWriteMessageTest {
|
||||
@Override
|
||||
public Deferred<ResultSet<RecordId>> call(ResultSet<RecordId> records) throws Exception {
|
||||
final CollatedMessage<ResultSet<RecordId>> write = StorageWriteMessage.Builder.newBuilder()
|
||||
.record(bucket, "collection", "record", value, "bad version".getBytes())
|
||||
.record(bucket, "collection", "record", value, "bad version")
|
||||
.build();
|
||||
return client.send(write);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.UUID;
|
||||
public class UsersFetchMessageTest {
|
||||
|
||||
private Client client;
|
||||
private byte[] userId;
|
||||
private String userId;
|
||||
private String handle;
|
||||
|
||||
@Before
|
||||
@@ -56,7 +56,7 @@ public class UsersFetchMessageTest {
|
||||
public Deferred<ResultSet<User>> call(Session session) throws Exception {
|
||||
final CollatedMessage<ResultSet<User>> fetch = UsersFetchMessage.Builder.newBuilder()
|
||||
.handle("not found")
|
||||
.id(new byte[]{})
|
||||
.id("")
|
||||
.build();
|
||||
return client.send(fetch);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class UsersFetchMessageTest {
|
||||
public ResultSet<User> call(ResultSet<User> results) throws Exception {
|
||||
Assert.assertEquals(1, results.getResults().size());
|
||||
Assert.assertEquals(handle, results.getResults().get(0).getHandle());
|
||||
Assert.assertArrayEquals(userId, results.getResults().get(0).getId());
|
||||
Assert.assertEquals(userId, results.getResults().get(0).getId());
|
||||
Assert.assertNull(results.getCursor());
|
||||
return results;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class UsersFetchMessageTest {
|
||||
@Override
|
||||
public ResultSet<User> call(ResultSet<User> results) throws Exception {
|
||||
Assert.assertEquals(1, results.getResults().size());
|
||||
Assert.assertArrayEquals(userId, results.getResults().get(0).getId());
|
||||
Assert.assertEquals(userId, results.getResults().get(0).getId());
|
||||
Assert.assertEquals(handle, results.getResults().get(0).getHandle());
|
||||
Assert.assertNull(results.getCursor());
|
||||
return results;
|
||||
|
||||
Reference in new issue
Block a user