Compare commits

...
74 Commits
Author SHA1 Message Date
Luke Gehorsam 60cdc891e3 update build version in build.gradle 2021-02-17 10:01:30 -05:00
Luke Gehorsam b93b814550 update changelog, releaseinst 2021-02-17 09:44:53 -05:00
Lokesh Jangid 8090c059e9 DefaultError: allow null collationId in constructor 2021-02-17 10:28:45 +00:00
Luke Gehorsam a83e4626cf tweak readme 2021-01-25 20:59:22 -05:00
Luke 8669697d95 Add Facebook Instant Game authentication and Apple authentication (#49)
* update nakama protos

* update grpc gateway proto files

* implement auth., link, unlink apple

* add facebook instant game authentication

* add link and unlink facebook instant game

* implement demote group users and test their promotion and demotion
2021-01-25 20:59:22 -05:00
Luke Gehorsam 308d5cf6a7 update changelog 2021-01-25 20:55:23 -05:00
Luke Gehorsam 7ad14bee4a update grpc gateway proto files 2021-01-06 14:57:32 -05:00
Luke Gehorsam e7c0d9d05e update nakama protos 2021-01-06 11:09:53 -05:00
dependabot[bot] 98c59ca363 Bump junit from 4.11 to 4.13.1 in /examples/example-maven (#47)
Bumps [junit](https://github.com/junit-team/junit4) from 4.11 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.11.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.11...r4.13.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-16 09:10:54 -04:00
Luke Gehorsam 08cc768111 fix url to jitpack build log 2020-10-16 09:07:00 -04:00
Luke 30a24ff7ab example android, gradle and maven projects (#46)
* example android, gradle and maven projects

* remove redundant globs

* use more idiomatic android package name for example

* add license headers to java and groovy files

* use correct ListenableFuture pattern in example project code

* use separate artifactId instead of separate classifier for shadowJar

* update readme with new fatjar artifact id

* switch maven coordinates yet again and clean up examples for fat jar support

* fix gitignore newlines

* remove underscores from android test packagees
2020-10-16 09:02:42 -04:00
Luke Gehorsam 724d882ef4 update readme integration instructions 2020-09-30 13:24:31 -04:00
Luke Gehorsam 26fc0acad3 set com.github.heroiclabs as group 2020-09-30 12:59:45 -04:00
Luke Gehorsam 85f1080964 use same artifact id but differentiate via jars by classifier 2020-09-30 12:32:33 -04:00
Luke 3dde5b3baf Fix Eclipse/IDEA support and web socket message executor (#44)
* fix idea and eclipse support for protobuf intellisense

* process web socket messages using a single thread

* allow executor service to be passed into socket, but default to single-threaded

* add multithreading socket note to java sdk

* Fix extra newline
2020-09-06 12:01:49 -04:00
Luke 6c95cc5b55 Improved Jar Maven Coordinates (#42)
* use all suffix in artifactid rather than classifier

* Fix sources jar and description not being published. Tighten up maven coordinates to be less redundant

* fix incorrectly written logger-simple addition
2020-08-26 20:33:30 -04:00
Luke ce4caaa886 Integrate Gradle and Jitpack, update to latest dependencies (#41)
* add distribution plugin

* ignore all built code

* try shadow task

* remove git-publish and bintray for now

* upgrade lombok from 1.18.10 to 1.18.12

* upgrade grpc, protobuf

* upgrade okhttp

* update slf4j to 1.7.40 and don't force it

* remove manual pulling in of common protos from protobufjava

* include slf4j-simple as a test

* use thin and fat terminology for jar ids

* configure all tasks of type AbstractPublishToMaven

* update readme

* fix xml indentation

* add parent tags to maven examples

* move logger implementation to shadowjar task

* remove old bintray creds

* Replace thin terminology with main

* invert exclusion of simple logger

* expose listenable future  as part of the library api

* document jitpack build path
2020-08-21 20:33:52 -04:00
Luke Gehorsam d3370a2c8f just retain protobuf-java dependency for now 2020-08-17 10:07:58 -04:00
Luke Gehorsam 1eba9430d9 use gradle's dependency substitution feature to replace peotobuf-java with protobuf lite 2020-08-17 09:59:30 -04:00
Luke Gehorsam fe18af2e3d fix createSocket() overload 2020-08-17 09:32:11 -04:00
Luke Gehorsam 3793d17bb3 restore common protos but specifically exclude protobuf-java 2020-08-17 09:25:36 -04:00
Luke 2fa7356b0e Remove protobuf-java transitive dependency and add configurable ping to socket (#37)
* extract common protos from protobuf-java rather than including it as a transitive dependency in the common-protos package

* pass socket ping to pingInterval

* pass in timeout and ping as static defaults

* update changelog

* retain old interface and simply add a new method to interface that accepts ping
2020-08-13 18:29:14 -04:00
Luke 01364ccf68 merge service files when creating shadow jar (#39) 2020-08-13 17:26:49 -04:00
Luke 88bcef0d15 Make GSON parse UTC properly from Nakama (#36)
* add custon Date deserializer to GSON

* don't use two different date formats

* write test verifying proper createTime() for notifs

* oops, use math.abs

* reword DateTime -> Date because this is Java not .NET

* add license header and summary to gsondateserializer
2020-08-07 09:54:23 -04:00
LukeandLuke Gehorsam b8786c50a6 Update to Gradle 6.5.1 (#35)
* update copyright to 2020

* bundle all protos with the repo and simplify build.gradle

* commit new generated source

* update to gradle 5.0

* upgrade to gradle 6.0

* upgrade to gradle 6.5.1

* suppress warnings from generate code in eclipse

* Support for logs in tests

* add basic test for listing tournaments

* replace instances of DateTime with getEpochSecond() in tournament tests

* add end time to tournament objects that don't have reset schedules

* oops, don't set end time multiple times on some objects

* don't rely on leaky tournamenet list size for end time tests

* fix assertion on tournament record expiry

* remove 'no end' from tourney descriptions that do in fact end

* remove undefined getNextReset result from tourney test with no reset schedule

* update test on creation of future tournaments

* Add support for banning users to the Java SDK

* update changelog re: tourney test suite

* Allow .proto files to be imported without needing to flatten import statements

* add newline to EOF in download-protos

* remove unused build code

* exclude actual .proto files from .jar

* exclude grpc gateway meta protos from codegen

* update shadowjar dependency and document it

* add relocation support to shadowjar

Co-authored-by: Luke Gehorsam <[email protected]>
2020-08-05 12:16:04 -04:00
Mo Firouz e69126532d Set new development version. 2020-01-23 09:43:04 +00:00
Mo Firouz a06d1c62f5 Nakama-Java 2.0.4 release. 2020-01-23 09:42:24 +00:00
Mo Firouz 46ba09b80b Update to use latest gRPC dependencies. 2020-01-23 09:39:47 +00:00
Mo Firouz e125f80a13 Set new development version. 2019-10-25 15:41:28 +02:00
Mo Firouz d771de35c1 Nakama-Java 2.0.3 release. 2019-10-25 15:38:44 +02:00
Mo Firouz 15456d4e8c Add support for more ways to create a socket. 2019-10-25 15:36:18 +02:00
Mo Firouz 2222f178a6 Fix typo in UserPresence variable naming. 2019-10-16 17:17:03 +02:00
Mo Firouz e46d122d2d Set new development version. 2019-10-14 12:16:51 +02:00
Mo Firouz dc96afe168 Nakama-Java 2.0.2 release. 2019-10-14 12:15:07 +02:00
Mo Firouz 0b839aaea1 Add support for changes in Nakama 2.7.0 and custom Events API. #26 2019-10-14 11:43:57 +02:00
Mo Firouz 3814e6e63a Set new development version. 2019-06-19 12:13:42 +01:00
Mo Firouz d1744b1718 Nakama-Java 2.0.1 release. 2019-06-19 12:13:18 +01:00
Mo Firouz 89f991b3fb Add support for listing expired leaderboard/tournament records. Fix tests. 2019-06-11 16:27:21 +01:00
Chris Molozian 4b0922cfd0 Add gradle wrapper for 4.10.3 builds. 2019-04-24 23:22:03 +01:00
Mo Firouz 7a001c21dc Add missing generated java grpc. 2019-04-24 23:11:53 +01:00
Mo Firouz 8b21f78867 Set new development version. 2019-03-28 23:03:36 +00:00
Mo Firouz cb1340d4e6 Nakama-Java 2.0.0 release. 2019-03-28 22:55:13 +00:00
Mo Firouz 2b47a12a8e Update README to hide mentions of central repository 2019-03-28 22:31:12 +00:00
Mo Firouz fc88aba004 Add basic group create, update, list test 2019-03-13 23:24:27 +00:00
Mo Firouz f7eacd10bd Update to use updated server proto 2019-02-08 16:40:04 +00:00
Nitzan Zada ea616f9c93 matched api.proto with server's v2.3.2 2019-02-08 15:33:48 +00:00
Tregub Tatiana 610f177395 listUsersStorageObjects returns only 1 object 2018-12-07 13:51:04 +00:00
Tregub Tatiana 92ca9f61bc remove failed test 2018-12-07 13:51:04 +00:00
Tregub Tatiana 37c731878d fix arguments order 2018-12-07 13:51:04 +00:00
Tregub Tatiana 8a7172d8ac test fail 2018-12-07 13:51:04 +00:00
Tregub Tatiana d4d632aa71 fix arguments ordering 2018-12-07 10:59:59 +00:00
Mo Firouz 991d78b21d Ensure storage write objects are correctly added. 2018-11-16 10:17:27 +00:00
Sergey Zalozhnikov 8c49666f58 Enable access to enums from code outside of the package 2018-11-15 15:11:43 +00:00
Mo Firouz ed8a11e7de Base64 match data. Don't set collation ID on match data 2018-11-07 09:54:07 +00:00
Sergey Zalozhnikov 4dad9c08ff Update to use okio-1.14.0 to fix ClassNotFoundException for Maven projects on socket connection. 2018-11-07 09:53:25 +00:00
Sergey Zalozhnikov 2c209a8848 Enable access to join channels from code outside of the package 2018-11-01 10:37:15 +10:00
Mo Firouz 1d2f2132a6 Disable client-initiated pings 2018-10-21 05:37:58 +10:00
Mo Firouz a3026badf1 Execute listener on a new thread to avoid blocking network calls. 2018-10-17 23:58:40 +08:00
Mo Firouz ad4cc6c61a Enhance matchmaker tests 2018-10-16 16:35:26 +08:00
Mo Firouz a063bb6f56 Add MatchmakerTest 2018-10-16 15:13:55 +08:00
Mo Firouz cd4ea151c4 Rename OnMatchmakeMatched to OnMatchmakerMatched 2018-10-16 09:33:38 +08:00
Mo Firouz 64a5bdc732 Fix timestamp typo 2018-10-11 11:47:10 +01:00
Mo Firouz 642d61bdef Add support for tournaments. (#10) 2018-10-11 07:53:36 +01:00
Mo Firouz b1e80ad51f Check for NPE when decoding match data 2018-09-20 14:24:54 +01:00
Mo Firouz e1d754c52e Fix match serialization 2018-09-19 14:38:15 +01:00
Mo Firouz fc5f8d2adc Allow null value when updating status. 2018-09-05 11:26:45 +01:00
Mo Firouz 983c4e9fa2 Rename socket methods to better names 2018-09-04 20:27:36 +01:00
Mo Firouz e55764710b Streamline creating a new websocket connection 2018-09-04 13:25:56 +01:00
Mo Firouz d29a58f0cc Update build settings to ensure use of lite runtime 2018-09-04 08:45:41 +01:00
Mo Firouz 4867fca44a Add javadocs. 2018-09-03 08:53:01 +01:00
Mo Firouz 323bd5f502 Update readme with more info. 2018-09-02 15:00:51 +01:00
Mo Firouz 9aa46b8312 Improve tests. 2018-09-01 18:04:25 +01:00
Mo Firouz 4fb96c7182 Improve gRPC and websocket data exchange. 2018-08-31 17:30:14 +01:00
Chris Molozian b15777f196 Set new development version. 2017-12-07 22:38:40 +00:00
274 changed files with 12885 additions and 11091 deletions

No files matched your search

+8 -4
View File
@@ -1,5 +1,7 @@
# Created by https://www.gitignore.io/api/git,java,macos,linux,gradle,eclipse,windows,sublimetext,intellij+all,intellij+iml
**/build
### Custom ###
.BINTRAY
@@ -282,14 +284,13 @@ $RECYCLE.BIN/
*.lnk
### Gradle ###
.gradle
/build/
**/.gradle
# Ignore Gradle GUI config
gradle-app.setting
**/gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
**/gradle-wrapper.jar
# Cache of project
.gradletasknamecache
@@ -298,3 +299,6 @@ gradle-app.setting
# gradle/wrapper/gradle-wrapper.properties
# End of https://www.gitignore.io/api/git,java,macos,linux,gradle,eclipse,windows,sublimetext,intellij+all,intellij+iml
# Maven
**/target
-3
View File
@@ -1,3 +0,0 @@
[submodule "server"]
path = server
url = [email protected]:heroiclabs/nakama.git
+55
View File
@@ -4,6 +4,60 @@ 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]
## [2.1.1] - 2021-02-17
### Changed
- Allowed null values of `collationId` to be passed to the `DefaultError` object.
## [2.1.0] - 2020-01-25
### Added
- Added configurable ping frame intervals to Web Socket.
- Ability to demote group users.
- Ability to authenticate link and unlink Facebook Instant Game and Apple users
- Example Android, Gradle and Maven projects.
- Shadow Jar support.
- Ability to customize the web socket message receive thread executor.
### Changed
- We now use JitPack as our new build repository. Please see the README.md
for instructions on how to integrate our package with your build system.
- Removed transitive dependency on Protobuf-Java.
- Moved all external .proto dependencies into this repository.
- Upgraded from Gradle 4 to Gradle 6.
- Upgraded third party dependencies to newer versions.
### Fixed
- Fixed incorrect time being parsed from timestamps.
- Fixed bugs in Tournaments test suite.
- Fixed UTC parsing.
## [2.0.4] - 2020-01-23
### Added
- Updated gRPC, GSON and Lombok dependencies.
## [2.0.3] - 2019-10-25
### Added
- More ways to create a socket connection.
### Fixed
- Correctly decode UserPresence from payload.
## [2.0.2] - 2019-10-14
### Added
- Add support for session vars.
- Add support for sending metadata when joining a match with an ID.
- Add pagination support for friends and groups.
## [2.0.1] - 2019-06-19
### Added
- Add support for listing expired leaderboard/tournament records.
## [2.0.0] - 2019-03-29
### Added
- Support for Nakama 2.
## [0.5.1] - 2017-12-07
### Fixed
- Build storage update messages with valid operations.
@@ -52,3 +106,4 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
## [0.1.0] - 2017-08-13
### Added
- Initial public release.
+157 -27
View File
@@ -3,38 +3,79 @@ Nakama Java
> Android optimized Java client for Nakama server.
Nakama is an [open-source](https://github.com/heroiclabs/nakama) distributed server for social and realtime games and apps. For more information have a look at the [documentation](https://heroiclabs.com/docs/).
[Nakama](https://github.com/heroiclabs/nakama) is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much [more](https://heroiclabs.com).
This client implements the protocol and all features available in the server. It is compatible with Java 1.7+ and Android 2.3+. The [Javadocs](https://heroiclabs.github.io/nakama-java/current/) for the client are maintained on GitHub Pages.
This client implements the full API and socket options with the server. It's written in C# with minimal dependencies to support Unity, Xamarin, Godot, XNA, and other engines and frameworks.
If you encounter any issues with the server you can generate diagnostics for us with the [doctor](https://heroiclabs.com/docs/install-server-cli/#doctor) subcommand. Send these to support@heroiclabs.com or [open an issue](https://github.com/heroiclabs/nakama/issues). If you experience any issues with the client, it can be useful to [enable trace](https://heroiclabs.com/docs/android-java-client-guide/#logs-and-errors) to produce detailed logs and [open an issue](https://github.com/heroiclabs/nakama-java/issues).
Full documentation is online - https://heroiclabs.com/docs
## Usage
## Getting Started
The client can be downloaded from [GitHub releases](https://github.com/heroiclabs/nakama-java/releases). You can download "nakama-java-$version.jar" or "nakama-java-$version-all.jar" which includes a shadowed copy of all dependencies.
You'll need to setup the server and database before you can connect with the client. The simplest way is to use Docker but have a look at the [server documentation](https://github.com/heroiclabs/nakama#getting-started) for other options.
If you use a build tool like Gradle you can skip the download and fetch it from the central repository.
1. Install and run the servers. Follow these [instructions](https://heroiclabs.com/docs/install-docker-quickstart).
2. The Java SDK can be imported with either Grade or Maven through [Jitpack](https://jitpack.io/).
### Gradle
```groovy
repositories {
maven {
url 'https://dl.bintray.com/heroiclabs/default/'
url 'https://jitpack.io'
}
}
dependencies {
compile(group: 'com.heroiclabs.nakama', name: 'client', version: '+')
compile('org.slf4j:slf4j-api:1.7.25') {
force = true // don't upgrade to "1.8.0-alpha2"
}
implementation 'com.github.heroiclabs.nakama-java:nakama-java:<commit>'
// or, depend on the fat Jar which bundles all of the Nakama Java dependencies into a single Jar.
// implementation 'com.github.heroiclabs.nakama-java:nakama-java-all:<commit>'
}
```
We have a guide which covers how to use the client with lots of code examples:
### Maven
https://heroiclabs.com/docs/android-java-client-guide/
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
To create a client which can connect to the Nakama server with the default settings.
...
<dependencies>
<dependency>
<groupId>com.github.heroiclabs.nakama-java</groupId>
<artifactId>nakama-java</artifactId>
<version>_commit_</version>
<type>jar</type>
</dependency>
</dependencies>
```
Or, if you would like to depend on a fat JAR with Maven:
```xml
<dependencies>
<dependency>
<groupId>com.github.heroiclabs.nakama-java</groupId>
<artifactId>nakama-java-all</artifactId>
<version>_commit_</version>
<type>jar</type>
</dependency>
</dependencies>
```
Alternatively, you can download the client from the [releases page](https://github.com/heroiclabs/nakama-java/releases) and import it into your project. You can also [build from source](#source-builds).
You can view full integration examples in the examples folder.
3. Use the connection credentials to build a client object.
```java
import com.heroiclabs.nakama.Client;
@@ -43,15 +84,82 @@ public class NakamaSessionManager {
private final Client client;
public NakamaSessionManager() {
client = DefaultClient.builder("defaultkey")
.host("127.0.0.1")
.port(7350)
.ssl(false)
.build();
client = new DefaultClient("defaultkey", "127.0.0.1", 7349, false);
}
}
```
## Usage
The client object has many methods to execute various features in the server or open realtime socket connections with the server.
### Authenticate
There's a variety of ways to [authenticate](https://heroiclabs.com/docs/authentication) with the server. Authentication can create a user if they don't already exist with those credentials. It's also easy to authenticate with a social profile from Google Play Games, Facebook, Game Center, etc.
```java
String email = "[email protected]";
String password = "batsignal";
Session session = client.authenticateEmail(email, password).get();
System.out.println(session);
```
### Sessions
When authenticated the server responds with an auth token (JWT) which contains useful properties and gets deserialized into a `Session` object.
```java
System.out.println(session.getAuthToken()); // raw JWT token
System.out.println(session.getUserId());
System.out.println(session.getUsername());
System.out.println("Session has expired: " + session.isExpired());
System.out.println("Session expires at: " + session.getExpireTime());
```
It is recommended to store the auth token from the session and check at startup if it has expired. If the token has expired you must reauthenticate. The expiry time of the token can be changed as a setting in the server.
```java
String authtoken = "restored from somewhere";
Session session = DefaultSession.restore(authtoken);
if (session.isExpired()) {
System.out.println("Session has expired. Must reauthenticate!");
}
```
### Requests
The client includes lots of builtin APIs for various features of the game server. These can be accessed with the async methods. It can also call custom logic as RPC functions on the server. These can also be executed with a socket object.
All requests are sent with a session object which authorizes the client.
```java
Account account = client.getAccount(session);
System.out.println(account.getUser().getId());
System.out.println(account.getUser().getUsername());
System.out.println(account.getWallet());
```
### Socket
The client can create one or more sockets with the server. Each socket can have it's own event listeners registered for responses received from the server.
```java
String host = "localhost";
int port = 7350; // different port to the main API port
boolean ssl = false;
SocketClient socket = client.createSocket(host, port, ssl);
ClientListener listener = new AbstractClientListener() {
@Override
public void onDisconnect(final Throwable t) {
System.out.println("Socket disconnected");
}
};
socket.connect(session, listener).get();
System.out.println("Socket connected successfully.");
```
By default, all socket messages are processed in a single thread. Advanced users who want to pass a multithreaded `ExecutorService` to the `client.createSocket` method should be aware that incoming messages will not necessarily be processed in order by that socket.
### For Android
Android uses a permissions system which determines which platform services the application will request to use and ask permission for from the user. The client uses the network to communicate with the server so you must add the "INTERNET" permission.
@@ -64,14 +172,36 @@ Android uses a permissions system which determines which platform services the a
To build the codebase you will need to install these dependencies:
* Java Runtime Environment 1.7+
* Java Development Kit 1.7+
* Gradle build tool
* Java Runtime Environment 1.8+
* Java Development Kit 1.8+
The Gradle project is setup to download and manage the Google Protocol buffers compiler toolchain automatically and generate Protobuf Lite definitions required by the source code.
Invoke the Gradle Wrapper with `./gradlew build` and Gradle will install your dependencies over
the network for you prior to building. It will then make a build and run the full test suite.
```
$> gradle build
```
To test a specific test, run `./gradlew test --tests <ClassName.methodName>`
Run "gradle tasks" for a list of available build tasks.
You can also run `./gradlew tasks` for a list of available build tasks.
To create a fat JAR with self-contained dependencies, run:
`./gradlew shadow`
All JAR artifacts are output to `build/libs`. The fat JAR will have an artifact id of 'nakama-java-all`.
If you'd like to test a Jitpack publish task locally prior to pushing, run:
`./gradlew publishToMavenLocal`
### Protobuf Sourcing
If you need to re-download all .proto dependenies, run `./download-protos` from the root of this repository.
### Jitpack
Jitpack makes builds of each commit on its own servers. You can view the results of each build and the corresponding artifacts at the following url:
https://jitpack.io/com/github/heroiclabs/nakama-java/<_commit_>/build.log
### License
This project is licensed under the [Apache-2 License](https://github.com/heroiclabs/nakama-dotnet/blob/master/LICENSE).
+13 -26
View File
@@ -1,6 +1,7 @@
## Release Instructions
The current release infrastructure is built into the project's [build.gradle](https://github.com/heroiclabs/nakama-java/blob/master/build.gradle). You'll need both the JDK 1.7+ and `gradle` installed to generate release packages which can be uploaded to GitHub and deployed to `"jcenter"`.
The current release infrastructure is built into the project's [build.gradle](https://github.com/heroiclabs/nakama-java/blob/master/build.gradle). You'll need both the
JDK 1.8+ and `gradle` installed to generate release packages which can be uploaded to GitHub and deployed to `"jcenter"`.
### New releases
@@ -18,13 +19,14 @@ The development team use these steps to build and upload a release.
1. Update the `CHANGELOG.md`.
Make sure to add the relevant "Added", "Changed", "Deprecated", "Removed", "Fixed", and "Security" sections as suggested by [keep a changelog](http://keepachangelog.com).
Make sure to add the relevant "Added", "Changed", "Deprecated", "Removed", "Fixed", and "Security" sections as suggested by [keep a
changelog](http://keepachangelog.com).
2. Update version in `build.gradle` and commit. i.e. `version = '0.1.0'` should become `version = '0.2.0'`.
2. Update version in `build.gradle` and commit. For example: `version = '2.0.0'` should become `version = '2.1.0'`.
```
git add build.gradle CHANGELOG.md
git commit -m "Nakama Java 0.2.0 release."
git commit -m "Nakama Java 2.0.0 release."
```
3. Tag the release.
@@ -32,34 +34,19 @@ The development team use these steps to build and upload a release.
__Note__ In source control good semver suggests a `"v"` prefix on a version. It helps group release tags.
```
git tag -a v0.2.0 -m "v0.2.0"
git push origin v0.2.0
git tag -a v2.0.0 -m "v2.0.0"
git push origin v2.0.0
```
4. You can upload the release onto <a href="https://bintray.com/bintray/jcenter" target="\_blank">jcenter</a>. You must set the values in `"gradle.properties"` to your Bintray credentials.
4. Login and create a [new draft release](https://github.com/heroiclabs/nakama-java/releases/new) on GitHub. Repeat the changelog in the release description. Then publish
the release.
```
gradle -PvcsTag="v0.2.0" bintrayUpload
```
5. Login and create a [new draft release](https://github.com/heroiclabs/nakama-java/releases/new) on GitHub. Repeat the changelog in the release description. Then publish the release.
6. Add the previous version of the docs to the `"preserve"` closure in the build script. Deploy the latest Javadoc to GitHub Pages.
```
preserve {
include '0.1.0/**'
}
```
```
gradle gitPublishPush
```
7. Add new `## [Unreleased]` section to start of `CHANGELOG.md`. Increment version in `build.gradle` and commit. i.e. `version = '0.2.0'` should now become `version = '0.3.0'`.
5. Add new `## [Unreleased]` section to start of `CHANGELOG.md`. Increment version in `build.gradle` and commit. i.e. `version = '2.0.0'` should now become `version =
'2.1.0'`.
```
git add build.gradle CHANGELOG.md
git commit -m "Set new development version."
git push origin master
```
+179 -132
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Heroic Labs
* Copyright 2021 Heroic Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,22 +14,155 @@
* limitations under the License.
*/
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.1'
id 'com.google.protobuf' version '0.8.2'
id 'com.jfrog.bintray' version '1.7.3'
id 'org.ajoberstar.git-publish' version '0.3.0'
id 'java'
id 'idea'
id 'maven-publish'
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import org.gradle.plugins.ide.eclipse.model.SourceFolder
// dependencies required by the gradle build script itself
buildscript {
repositories {
// where to resolve the dependencies
maven {
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
}
}
group = 'com.heroiclabs.nakama'
version = '0.5.1'
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'com.google.protobuf' version '0.8.12'
//for distTar which is called when importing this SDK w/ JitPack
id 'distribution'
id 'eclipse'
id 'maven-publish'
id 'idea'
id 'java'
id 'java-library'
}
group = 'com.github.heroiclabs'
version = '2.1.1'
def description = 'Android optimized Java client for Nakama server.'
sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
// where to pull dependencies from
maven {
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
mavenLocal()
mavenCentral()
}
dependencies {
// syntax sugaring for data models
annotationProcessor 'org.projectlombok:lombok:1.18.12'
implementation "org.projectlombok:lombok:1.18.12"
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.protobuf:protobuf-javalite:3.13.0'
implementation ('io.grpc:grpc-okhttp:1.31.1') {
exclude group: 'com.squareup.okio', module:'okio'
}
implementation 'com.squareup.okio:okio:2.7.0'
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
implementation 'io.grpc:grpc-protobuf-lite:1.31.1'
implementation 'io.grpc:grpc-stub:1.31.1'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
implementation ('com.google.api.grpc:googleapis-common-protos:0.0.3') {
exclude group: 'io.grpc', module:'grpc-protobuf'
}
implementation 'org.slf4j:slf4j-api:1.7.30'
api 'com.google.guava:guava:29.0-android' // listenable future is part of the SDK public API
testCompile 'junit:junit:4.12'
}
sourceSets {
main {
java {
srcDirs "src/main/java"
}
proto {
exclude 'protoc-gen-swagger/**/*.proto'
}
}
}
idea {
module {
sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/grpc");
sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java");
}
}
/* Disable warnings from generated source code. */
eclipse {
classpath {
file {
whenMerged {
entries += new SourceFolder("build/generated/source/proto/main/grpc", null)
entries += new SourceFolder("build/generated/source/proto/main/java", null)
def grpcSource = entries.find {
it.path == "build/generated/source/proto/main/grpc"
}
grpcSource.entryAttributes["ignore_optional_problems"] = 'true'
def javaLiteSource = entries.find {
it.path == "build/generated/source/proto/main/java"
}
javaLiteSource.entryAttributes["ignore_optional_problems"] = 'true'
}
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.13.0'
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.31.1"
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
task.plugins {
grpc { option "lite" }
}
}
}
}
jar {
manifest {
attributes 'Implementation-Title': 'Nakama client',
'Implementation-Version': "$project.version"
}
exclude '/**/*.proto'
}
def pomConfig = {
licenses {
@@ -61,143 +194,57 @@ def pomConfig = {
}
}
bintray {
user = bintrayUser
key = bintrayKey
publications = ['mavenJava']
pkg {
repo = 'default'
name = 'nakama-client'
desc = description
userOrg = 'heroiclabs'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/heroiclabs/nakama-java.git'
publicDownloadNumbers = true
version {
name = "$project.version"
released = new Date()
vcsTag = project.findProperty('vcsTag')
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.18'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.google.protobuf:protobuf-lite:3.0.1'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.stumbleupon:async:1.4.1'
compile ('org.slf4j:slf4j-api:1.7.25') {
force = true // don't upgrade to "1.8.0-alpha2"
}
testCompile 'junit:junit:4.12'
testCompile 'ch.qos.logback:logback-classic:1.2.3'
}
gitPublish {
repoUri = '[email protected]:heroiclabs/nakama-java.git'
branch = 'gh-pages'
contents {
from(javadoc) {
into "$project.version"
}
from(javadoc) {
into 'current'
}
}
preserve {
include '0.1.0/**'
include '0.1.1/**'
include '0.1.2/**'
include '0.2.0/**'
include '0.3.0/**'
include '0.4.0/**'
include '0.5.0/**'
}
commitMessage = "Published javadoc '$project.version' via Gradle ${GradleVersion.current().version}."
}
idea {
module {
sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java");
}
}
jar {
manifest {
attributes 'Implementation-Title': 'Nakama client',
'Implementation-Version': "$project.version"
}
}
protobuf {
generateProtoTasks {
all().each { task ->
task.builtins {
remove java // Don't generate a copy with "protobuf-java".
}
task.plugins {
javalite { // Must activate "javalite" plugin.
}
}
}
}
plugins {
javalite {
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
}
protoc {
artifact = 'com.google.protobuf:protoc:3.3.0'
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifactId 'nakama-java'
}
artifact sourcesJar {
classifier 'sources'
}
artifact javadocJar {
classifier 'javadoc'
}
shadow(MavenPublication) {
project.shadow.component(it)
artifactId 'nakama-java-all'
groupId "$project.group"
artifactId 'client'
version "$project.version"
pom.withXml {
def root = asNode()
root.appendNode('description', description)
root.appendNode('name', 'Nakama client')
root.appendNode('url', 'https://heroiclabs.com/docs/android-java-client-guide/')
root.children().last() + pomConfig
}
// override default classifier of 'all'
it.artifacts[0].classifier = ''
}
}
}
repositories {
mavenCentral()
}
tasks.withType(AbstractPublishToMaven).all {
publication.artifact sourcesJar {
classifier 'sources'
}
publication.groupId "$project.group"
publication.version "$project.version"
publication.pom.withXml {
def root = asNode()
root.appendNode('description', description)
root.appendNode('name', 'Nakama client')
root.appendNode('url', 'https://heroiclabs.com/docs/android-java-client-guide/')
root.children().last() + pomConfig
}
}
shadowJar {
mergeServiceFiles()
}
sourceSets {
main {
proto {
srcDir "$projectDir/server/server"
}
}
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "nakama" // prefix all classpath entries with `nakama`
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
task javadocJar(type: Jar) {
from javadoc
test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# Copyright 2020 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.
# This command is a utility for downloading all .proto files required
# for making full source builds.
GRPC_GATEWAY_COMMIT=5c1639cccb7d6abc747643ed07321b0052b809d5
NAKAMA_COMMON_COMMIT=b013ccdfa0be37f97c716a477409dfe935b111f7
NAKAMA_COMMIT=ec12afadd940cd779f5b1acadc0faf33ed9fa94c
DOMAIN=https://raw.githubusercontent.com
OPENAPI_URL=${DOMAIN}/grpc-ecosystem/grpc-gateway/${GRPC_GATEWAY_COMMIT}/protoc-gen-openapiv2/options/openapiv2.proto
ANNOTATION_URL=${DOMAIN}/grpc-ecosystem/grpc-gateway/${GRPC_GATEWAY_COMMIT}/protoc-gen-openapiv2/options/annotations.proto
API_URL=${DOMAIN}/heroiclabs/nakama-common/${NAKAMA_COMMON_COMMIT}/api/api.proto
REALTIME_URL=${DOMAIN}/heroiclabs/nakama-common/${NAKAMA_COMMON_COMMIT}/rtapi/realtime.proto
APIGRPC_URL=${DOMAIN}/heroiclabs/nakama/${NAKAMA_COMMIT}/apigrpc/apigrpc.proto
ROOT_DIR=src/main/proto
NAKAMA_COMMON_DIR=github.com/heroiclabs/nakama-common/api
SWAGGER_GEN_DIR=protoc-gen-openapiv2/options
curl $OPENAPI_URL -o ${ROOT_DIR}/${SWAGGER_GEN_DIR}/openapiv2.proto
curl $ANNOTATION_URL -o ${ROOT_DIR}/${SWAGGER_GEN_DIR}/annotations.proto
curl $API_URL -o ${ROOT_DIR}/${NAKAMA_COMMON_DIR}/api.proto
curl $REALTIME_URL -o ${ROOT_DIR}/${NAKAMA_COMMON_DIR}/realtime.proto
curl $APIGRPC_URL -o src/main/proto/apigrpc.proto
+65
View File
@@ -0,0 +1,65 @@
/*
* Copyright 2020 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.
*/
apply plugin: 'com.android.application'
repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral()
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.example.androidnakama"
minSdkVersion 30
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
configurations {
implementation.exclude module:'proto-google-common-protos'
implementation.exclude module:'protolite-well-known-types'
implementation.exclude module:'protobuf-lite'
implementation.exclude module:'protobuf-java'
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.heroiclabs.nakama-java:nakama-java:dde7330adfa1867881dc6c6c6e27c1176512c916'
// fat JAR
// implementation 'com.github.heroiclabs.nakama-java:nakama-java-all:dde7330adfa1867881dc6c6c6e27c1176512c916'
}
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,42 @@
/*
* Copyright 2020 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.example.testandroid;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.androidnakama", appContext.getPackageName());
}
}
@@ -0,0 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testandroid">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" />
</manifest>
@@ -0,0 +1,56 @@
/*
* Copyright 2020 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.
*/
import java.util.concurrent.*;
import com.google.common.util.concurrent.*;
import com.heroiclabs.nakama.*;
// fat jar
// import nakama.com.google.common.util.concurrent.*;
public class Main {
public static void main(String[] args) {
DefaultClient client = new DefaultClient("defaultkey", "127.0.0.1", 7349, false);
final ExecutorService executor = Executors.newSingleThreadExecutor();
try {
String email = "[email protected]";
String password = "batsignal";
Futures.addCallback(client.authenticateEmail(email, password), new FutureCallback<Session>() {
@Override
public void onSuccess(final Session result) {
System.out.println("got session: " + result.getAuthToken());
executor.shutdown();
}
@Override
public void onFailure(final Throwable throwable) {
System.out.println(throwable.getMessage());
executor.shutdown();
}
}, executor);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
}
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">nakama-java-test-android</string>
</resources>
@@ -0,0 +1,10 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -14,17 +14,20 @@
* limitations under the License.
*/
package com.heroiclabs.nakama;
package com.example.testandroid;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* A message which returns a response from the server.
* Example local unit test, which will execute on the development machine (host).
*
* @param <T> The type of the message response.
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public interface CollatedMessage<T> {
/**
* @param collationId The collation ID to assign to the serialized message instance.
* @return The serialized format of the message.
*/
byte[] asBytes(String collationId);
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -14,21 +14,27 @@
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultFriendsBlockMessage implements FriendsBlockMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
@@ -0,0 +1,19 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
@@ -0,0 +1,6 @@
#Wed Sep 30 08:51:05 EDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
+172
View File
@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
+84
View File
@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+2
View File
@@ -0,0 +1,2 @@
include ':app'
rootProject.name = "nakama-java-test-android"
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright 2020 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.
*/
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
*/
plugins {
id 'application'
id 'java'
}
repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral() // resolve Guava
}
dependencies {
implementation 'com.github.heroiclabs.nakama-java:nakama-java:dde7330adfa1867881dc6c6c6e27c1176512c916'
// fat Jar
// implementation 'com.github.heroiclabs.nakama-java:nakama-java-all:dde7330adfa1867881dc6c6c6e27c1176512c916'
}
application {
mainClass = 'Main'
}
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+185
View File
@@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
+89
View File
@@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+9
View File
@@ -0,0 +1,9 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.6/userguide/multi_project_builds.html
*/
@@ -0,0 +1,56 @@
/*
* Copyright 2020 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.
*/
import java.util.concurrent.*;
// fat jar
// import nakama.com.google.common.util.concurrent.*;
import com.google.common.util.concurrent.*;
import com.heroiclabs.nakama.*;
public class Main {
public static void main(String[] args) {
DefaultClient client = new DefaultClient("defaultkey", "127.0.0.1", 7349, false);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
String email = "[email protected]";
String password = "batsignal";
Futures.addCallback(client.authenticateEmail(email, password), new FutureCallback<Session>() {
@Override
public void onSuccess(final Session result) {
System.out.println("got session: " + result.getAuthToken());
executor.shutdown();
}
@Override
public void onFailure(final Throwable throwable) {
System.out.println(throwable.getMessage());
executor.shutdown();
}
}, executor);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
}
+125
View File
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2020 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.heroiclabs</groupId>
<artifactId>nakama-java-test-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<name>nakama-java-test-maven</name>
<url>https://github.com/heroiclabs/nakama-java</url>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.heroiclabs.nakama-java</groupId>
<artifactId>nakama-java</artifactId>
<version>dde7330adfa1867881dc6c6c6e27c1176512c916</version>
<type>jar</type>
</dependency>
<!-- fat jar
<dependency>
<groupId>com.github.heroiclabs.nakama-java</groupId>
<artifactId>nakama-java-all</artifactId>
<version>dde7330adfa1867881dc6c6c6e27c1176512c916</version>
<type>jar</type>
</dependency> -->
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>Main</mainClass>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -0,0 +1,55 @@
/*
* Copyright 2020 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.
*/
import java.util.concurrent.*;
import com.google.common.util.concurrent.*;
// fat jar
// import nakama.com.google.common.util.concurrent.*;
import com.heroiclabs.nakama.*;
public class Main {
public static void main(String[] args) {
DefaultClient client = new DefaultClient("defaultkey", "127.0.0.1", 7349, false);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
String email = "[email protected]";
String password = "batsignal";
Futures.addCallback(client.authenticateEmail(email, password), new FutureCallback<Session>() {
@Override
public void onSuccess(final Session result) {
System.out.println("got session: " + result.getAuthToken());
executor.shutdown();
}
@Override
public void onFailure(final Throwable throwable) {
System.out.println(throwable.getMessage());
executor.shutdown();
}
}, executor);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
}
@@ -0,0 +1,36 @@
/*
* Copyright 2020 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;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.heroiclabs.nakama.*;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
-3
View File
@@ -1,3 +0,0 @@
# Bintray credentials
bintrayUser=
bintrayKey=
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+183
View File
@@ -0,0 +1,183 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
Vendored
+100
View File
@@ -0,0 +1,100 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Submodule server deleted from ca88ea9ce6.
@@ -0,0 +1,102 @@
/*
* Copyright 2020 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 com.heroiclabs.nakama.api.ChannelMessage;
import com.heroiclabs.nakama.api.NotificationList;
/**
* A listener for receiving {@code Client} events.
*/
public abstract class AbstractSocketListener implements SocketListener {
/**
* Called when the client socket disconnects.
*
* Throwable t is set if an error caused the disconnect.
*/
@Override public void onDisconnect(final Throwable t) {}
/**
* Called when the client receives an error.
*
* @param error The {@code Error} received.
*/
@Override public void onError(final Error error) {}
/**
* Called when a new topic message has been received.
*
* @param message The {@code ChannelMessage} received.
*/
@Override public void onChannelMessage(final ChannelMessage message) {}
/**
* Called when a new topic presence update has been received.
*
* @param presence The {@code ChannelPresenceEvent} received.
*/
@Override public void onChannelPresence(final ChannelPresenceEvent presence) {}
/**
* Called when a matchmaking has found a match.
*
* @param matched The {@code MatchmakerMatched} received.
*/
@Override public void onMatchmakerMatched(final MatchmakerMatched matched) {}
/**
* Called when a new match data is received.
*
* @param matchData The {@code MatchData} received.
*/
@Override public void onMatchData(final MatchData matchData) {}
/**
* Called when a new match presence update is received.
*
* @param matchPresence The {@code MatchPresenceEvent} received.
*/
@Override public void onMatchPresence(final MatchPresenceEvent matchPresence) {}
/**
* Called when the client receives new notifications.
*
* @param notifications The list of {@code Notification} received.
*/
@Override public void onNotifications(final NotificationList notifications) {}
/**
* Called when the client receives status presence updates.
*
* @param presence Updated {@code StatusPresenceEvent} presence.
*/
@Override public void onStatusPresence(final StatusPresenceEvent presence) {}
/**
* Called when the client receives stream presence updates.
*
* @param presence Updated {@code StreamPresenceEvent} presence.
*/
@Override public void onStreamPresence(final StreamPresenceEvent presence) {}
/**
* Called when the client receives stream data.
*
* @param data Stream {@code StreamData} data received.
*/
@Override public void onStreamData(final StreamData data) {}
}
@@ -1,91 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NonNull;
public interface AuthenticateMessage extends CollatedMessage<Session> {
@AllArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static AuthenticateMessage custom(final @NonNull String id) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setCustom(id);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage device(final @NonNull String id) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setDevice(id);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage email(final @NonNull String email, final @NonNull String password) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setEmail(com.heroiclabs.nakama.Api.AuthenticateRequest.Email.newBuilder()
.setEmail(email)
.setPassword(password)
.build());
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage facebook(final @NonNull String oauthToken) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setFacebook(oauthToken);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage gameCenter(final @NonNull String playerId, final @NonNull String bundleId,
final long timestamp, final @NonNull String salt,
final @NonNull String signature, final @NonNull String publicKeyUrl) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setGameCenter(com.heroiclabs.nakama.Api.AuthenticateRequest.GameCenter.newBuilder()
.setPlayerId(playerId)
.setBundleId(bundleId)
.setTimestamp(timestamp)
.setSalt(salt)
.setSignature(signature)
.setPublicKeyUrl(publicKeyUrl)
.build());
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage google(final @NonNull String oauthToken) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setGoogle(oauthToken);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage steam(final @NonNull String sessionToken) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setSteam(sessionToken);
return new DefaultAuthenticateMessage(payload);
}
}
}
@@ -0,0 +1,66 @@
/*
* Copyright 2020 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;
@Getter
@EqualsAndHashCode
@ToString
@NoArgsConstructor(access = AccessLevel.PACKAGE)
/**
* A chat channel on the server.
*/
public class Channel {
/**
* The server-assigned channel ID.
*/
private String id;
/**
* The presences visible on the chat channel.
*/
private List<UserPresence> presences;
/**
* The presence of the current user. i.e. Your self.
*/
private UserPresence self;
/**
* The name of the chat room, or an empty string if this message was not sent through a chat room.
*/
private String roomName;
/**
* The ID of the group, or an empty string if this message was not sent through a group channel.
*/
private String groupId;
/**
* The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdOne;
/**
* The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdTwo;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -19,9 +19,12 @@ package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchmakeCheckFilter implements MatchmakeCheckFilter {
private final boolean value;
/**
* Send a channel join message to the server.
*/
class ChannelJoinMessage {
private final String target;
private final int type;
private boolean hidden;
private boolean persistence;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -16,9 +16,12 @@
package com.heroiclabs.nakama;
public interface MatchmakeCheckFilter extends MatchmakeFilter {
/**
* @return Filter value
*/
boolean isValue();
import lombok.Data;
@Data
/**
* A leave message to a chat channel.
*/
class ChannelLeaveMessage {
private final String channelId;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -18,16 +18,27 @@ package com.heroiclabs.nakama;
import lombok.*;
import java.util.List;
import java.util.Date;
@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());
}
/**
* A message sent on a channel.
*
*/
// This message type is only used for GSON, and not exposed to the Client interface.
class ChannelMessage {
private String channelId;
private String messageId;
private int code;
private String senderId;
private String username;
private String content;
private Date createTime;
private Date updateTime;
private boolean persistent;
private String roomName;
private String groupId;
private String userIdOne;
private String userIdTwo;
}
@@ -0,0 +1,85 @@
/*
* Copyright 2020 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.Date;
@Getter
@EqualsAndHashCode
@ToString
@NoArgsConstructor(access = AccessLevel.PACKAGE)
/**
* An acknowledgement from the server when a chat message is delivered to a channel.
*/
public class ChannelMessageAck {
/**
* A unique ID for the chat message.
*/
private String messageId;
/**
* The server-assigned channel ID.
*/
private String channelId;
/**
* A user-defined code for the chat message.
*/
private int code;
/**
* The username of the sender of the message.
*/
private String username;
/**
* True if the chat message has been stored in history.
*/
private boolean persistent;
/**
* The UNIX time when the message was created.
*/
private Date createTime;
/**
* The UNIX time when the message was updated.
*/
private Date updateTime;
/**
* The name of the chat room, or an empty string if this message was not sent through a chat room.
*/
private String roomName;
/**
* The ID of the group, or an empty string if this message was not sent through a group channel.
*/
private String groupId;
/**
* The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdOne;
/**
* The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdTwo;
}
@@ -0,0 +1,65 @@
/*
* Copyright 2020 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;
@Getter
@EqualsAndHashCode
@ToString
@NoArgsConstructor(access = AccessLevel.PACKAGE)
/**
* A batch of join and leave presences on a chat channel.
*/
public class ChannelPresenceEvent {
/**
* The unique identifier of the chat channel.
*/
private String channelId;
/**
* The unique identifier of the chat channel.
*/
private List<UserPresence> joins;
/**
* Presences of users who left the channel.
*/
private List<UserPresence> leaves;
/**
* The name of the chat room, or an empty string if this message was not sent through a chat room.
*/
private String roomName;
/**
* The ID of the group, or an empty string if this message was not sent through a group channel.
*/
private String groupId;
/**
* The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdOne;
/**
* The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdTwo;
}
@@ -0,0 +1,28 @@
/*
* Copyright 2020 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;
@Data
/**
* A remove message for a chat channel.
*/
class ChannelRemoveMessage {
private final String channelId;
private final String messageId;
}
@@ -0,0 +1,28 @@
/*
* Copyright 2020 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;
@Data
/**
* Send a chat message to a channel on the server.
*/
class ChannelSendMessage {
private final String channelId;
private final String content;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -16,24 +16,31 @@
package com.heroiclabs.nakama;
import java.util.Map;
/**
* Properties associated with each matched user
* The available channel types on the server.
*/
public interface MatchmakeUserProperty {
public enum ChannelType {
/**
* @return Matchmake user ID
* A chat room which can be created dynamically with a name.
*/
String getUserId();
ROOM(0),
/**
* @return Matchmake user properties
* A private chat between two users.
*/
Map<String, Object> getProperties();
DIRECT_MESSAGE(1),
/**
* @return Matchmake user filters
* A chat within a group on the server.
*/
Map<String, MatchmakeFilter> getFilters();
GROUP(2);
private final int value;
ChannelType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
@@ -0,0 +1,29 @@
/*
* Copyright 2020 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;
@Data
/**
* Update a chat message which has been sent to a channel.
*/
class ChannelUpdateMessage {
private final String channelId;
private final String messageId;
private final String content;
}
File diff suppressed because it is too large. Load diff
@@ -1,71 +0,0 @@
/*
* 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;
/**
* A listener for receiving {@code Client} events.
*/
public interface ClientListener {
/**
* Called when the client socket disconnects.
*/
void onDisconnect();
/**
* Called when a new topic message has been received.
*
* @param message The {@code TopicMessage} received.
*/
void onTopicMessage(TopicMessage message);
/**
* Called when a new topic presence update has been received.
*
* @param presence The {@code TopicPresence} received.
*/
void onTopicPresence(TopicPresence presence);
/**
* Called when a matchmaking has found a match.
*
* @param matched The {@code MatchmakeMatched} received.
*/
void onMatchmakeMatched(MatchmakeMatched matched);
/**
* Called when a new match data is received.
*
* @param matchData The {@code MatchData} received.
*/
void onMatchData(MatchData matchData);
/**
* Called when a new match presence update is received.
*
* @param matchPresence The {@code MatchPresence} received.
*/
void onMatchPresence(MatchPresence matchPresence);
/**
* Called when the client receives new notifications.
*
* @param notifications The list of {@code Notification} received.
*/
void onNotifications(List<Notification> notifications);
}
@@ -1,32 +0,0 @@
/*
* 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;
/**
* A cursor is a pointer to the start of the next {@code ResultSet<T>}.
*/
public interface Cursor {
/**
* @return The encoded pointer which represents a position in the database records.
*/
String getValue();
/**
* @return Encode the cursor so it can be cached.
*/
String serialize();
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultAuthenticateMessage implements AuthenticateMessage {
private final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
File diff suppressed because it is too large. Load diff
@@ -1,42 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DefaultCursor implements Cursor {
private final String value;
public String serialize() {
return value;
}
/**
* @param serializedCursor Restore a cursor which has been stored with {@code serialize()}.
* @return A new cursor which was stored.
*/
public static Cursor restore(final String serializedCursor) {
return new DefaultCursor(serializedCursor);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2017 The Nakama Authors
* Copyright 2020 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.
@@ -18,36 +18,21 @@ package com.heroiclabs.nakama;
import lombok.*;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(includeFieldNames = true)
@Getter
@ToString
class DefaultError extends Error {
private final ErrorCode code;
private final String collationId;
DefaultError(final @NonNull String message, final @NonNull ErrorCode code) {
DefaultError(@NonNull final String message) {
super(message);
this.code = code;
this.collationId = null;
}
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);
DefaultError(final String collationId, @NonNull final WebSocketError error) {
super(error.getMessage());
this.code = ErrorCode.fromInt(error.getCode());
this.collationId = collationId;
}
}
@@ -1,62 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DefaultFriend implements Friend {
private final String avatarUrl;
private final long createdAt;
private final String fullname;
private final String handle;
private final String id;
private final String lang;
private final long lastOnlineAt;
private final String location;
private final String metadata;
private final String timezone;
private final long updatedAt;
private final FriendType state;
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(metadata, clazz);
}
static Friend fromProto(final @NonNull com.heroiclabs.nakama.Api.Friend friend) {
return new DefaultFriend(friend.getUser().getAvatarUrl(), friend.getUser().getCreatedAt(),
friend.getUser().getFullname(), friend.getUser().getHandle(), friend.getUser().getId(),
friend.getUser().getLang(), friend.getUser().getLastOnlineAt(), friend.getUser().getLocation(),
friend.getUser().getMetadata(), friend.getUser().getTimezone(), friend.getUser().getUpdatedAt(),
Friend.FriendType.fromLong(friend.getState()));
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultFriendsAddMessage implements FriendsAddMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultFriendsListMessage implements FriendsListMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultFriendsRemoveMessage implements FriendsRemoveMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,54 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DefaultGroup implements Group {
private final String id;
@Getter(AccessLevel.PRIVATE)
private final boolean priv;
private final String creatorId;
private final String name;
private final String description;
private final String avatarUrl;
private final String lang;
private final long utcOffsetMs;
private final String metadata;
private final long count;
private final long createdAt;
private final long updatedAt;
public boolean isPrivate() {
return priv;
}
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(metadata, clazz);
}
static Group fromProto(final @NonNull com.heroiclabs.nakama.Api.Group group) {
return new DefaultGroup(group.getId(), group.getPrivate(), group.getCreatorId(), group.getName(),
group.getDescription(), group.getAvatarUrl(), group.getLang(), group.getUtcOffsetMs(),
group.getMetadata(), group.getCount(), group.getCreatedAt(), group.getUpdatedAt());
}
}
@@ -1,59 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class DefaultGroupSelf implements GroupSelf {
private final String id;
@Getter(AccessLevel.PRIVATE)
private final boolean priv;
private final String creatorId;
private final String name;
private final String description;
private final String avatarUrl;
private final String lang;
private final long utcOffsetMs;
private final String metadata;
private final long count;
private final long createdAt;
private final long updatedAt;
private final Group.MembershipType state;
public boolean isPrivate() {
return priv;
}
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(metadata, clazz);
}
static GroupSelf fromProto(final @NonNull com.heroiclabs.nakama.Api.TGroupsSelf.GroupSelf groupSelf) {
return new DefaultGroupSelf(groupSelf.getGroup().getId(), groupSelf.getGroup().getPrivate(),
groupSelf.getGroup().getCreatorId(), groupSelf.getGroup().getName(),
groupSelf.getGroup().getDescription(), groupSelf.getGroup().getAvatarUrl(),
groupSelf.getGroup().getLang(), groupSelf.getGroup().getUtcOffsetMs(),
groupSelf.getGroup().getMetadata(), groupSelf.getGroup().getCount(),
groupSelf.getGroup().getCreatedAt(), groupSelf.getGroup().getUpdatedAt(),
Group.MembershipType.fromLong(groupSelf.getState()));
}
}
@@ -1,63 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupUser implements GroupUser {
private final String avatarUrl;
private final long createdAt;
private final String fullname;
private final String handle;
private final String id;
private final String lang;
private final long lastOnlineAt;
private final String location;
private final String metadata;
private final String timezone;
private final long updatedAt;
private final Group.MembershipType state;
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(metadata, clazz);
}
static GroupUser fromProto(final @NonNull com.heroiclabs.nakama.Api.GroupUser groupUser) {
return new DefaultGroupUser(groupUser.getUser().getAvatarUrl(), groupUser.getUser().getCreatedAt(),
groupUser.getUser().getFullname(), groupUser.getUser().getHandle(), groupUser.getUser().getId(),
groupUser.getUser().getLang(), groupUser.getUser().getLastOnlineAt(),
groupUser.getUser().getLocation(), groupUser.getUser().getMetadata(),
groupUser.getUser().getTimezone(), groupUser.getUser().getUpdatedAt(),
Group.MembershipType.fromLong(groupUser.getState()));
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupUsersAddMessage implements GroupUsersAddMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupUsersKickMessage implements GroupUsersKickMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupUsersListMessage implements GroupUsersListMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupUsersPromoteMessage implements GroupUsersPromoteMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsCreateMessage implements GroupsCreateMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsFetchMessage implements GroupsFetchMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsJoinMessage implements GroupsJoinMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsLeaveMessage implements GroupsLeaveMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsListMessage implements GroupsListMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsRemoveMessage implements GroupsRemoveMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsSelfListMessage implements GroupsSelfListMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultGroupsUpdateMessage implements GroupsUpdateMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,51 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboard implements Leaderboard {
private final String id;
private final boolean authoritative;
private final SortOrder sort;
private final long count;
private final String resetSchedule;
private final String metadata;
private final String nextId;
private final String prevId;
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(metadata, clazz);
}
static Leaderboard fromProto(final @NonNull com.heroiclabs.nakama.Api.Leaderboard leaderboard) {
return new DefaultLeaderboard(
leaderboard.getId(),
leaderboard.getAuthoritative(),
Leaderboard.SortOrder.fromLong(leaderboard.getSort()),
leaderboard.getCount(),
leaderboard.getResetSchedule(),
leaderboard.getMetadata(),
leaderboard.getNextId(),
leaderboard.getPrevId()
);
}
}
@@ -1,61 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboardRecord implements LeaderboardRecord {
private final String leaderboardId;
private final String ownerId;
private final String handle;
private final String lang;
private final String location;
private final String timezone;
private final long rank;
private final long score;
private final long numScore;
private final String metadata;
private final long rankedAt;
private final long updatedAt;
private final long expiresAt;
static LeaderboardRecord fromProto(final @NonNull com.heroiclabs.nakama.Api.LeaderboardRecord record) {
return new DefaultLeaderboardRecord(
record.getLeaderboardId(),
record.getOwnerId(),
record.getHandle(),
record.getLang(),
record.getLocation(),
record.getTimezone(),
record.getRank(),
record.getScore(),
record.getNumScore(),
record.getMetadata(),
record.getRankedAt(),
record.getUpdatedAt(),
record.getExpiresAt()
);
}
public <T> T getMetadata(final Class<T> clazz) {
return DefaultClient.GSON.fromJson(metadata, clazz);
}
}
@@ -1,32 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboardRecordWriteMessage implements LeaderboardRecordWriteMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,32 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboardRecordsFetchMessage implements LeaderboardRecordsFetchMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,32 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboardRecordsListMessage implements LeaderboardRecordsListMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,32 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLeaderboardsListMessage implements LeaderboardsListMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,33 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultLogoutMessage implements LogoutMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes() {
return payload.clone().build().toByteArray();
}
}
@@ -1,45 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatch implements Match {
private final String id;
private final List<UserPresence> presence;
private final UserPresence self;
static Match fromProto(final @NonNull com.heroiclabs.nakama.Api.TMatch match) {
return DefaultMatch.fromProto(match.getMatch());
}
static Match fromProto(final @NonNull com.heroiclabs.nakama.Api.Match match) {
List<UserPresence> userPresences = new ArrayList<UserPresence>();
for (com.heroiclabs.nakama.Api.UserPresence u : match.getPresencesList()) {
userPresences.add(DefaultUserPresence.fromProto(u));
}
return new DefaultMatch(match.getMatchId(), userPresences, DefaultUserPresence.fromProto(match.getSelf()));
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchCreateMessage implements MatchCreateMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
@Data
@ToString(includeFieldNames = true)
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchData implements MatchData {
private final String id;
private final byte[] data;
private final long opCode;
private final UserPresence presence;
static MatchData fromProto(final @NonNull com.heroiclabs.nakama.Api.MatchData matchData) {
return new DefaultMatchData(matchData.getMatchId(), matchData.getData().toByteArray(), matchData.getOpCode(), DefaultUserPresence.fromProto(matchData.getPresence()));
}
}
@@ -1,33 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultMatchDataSendMessage implements MatchDataSendMessage {
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
public byte[] asBytes() {
return payload.clone().build().toByteArray();
}
}
Loaded 100 of 274 files, more files were not shown because too many files have changed in this diff. Show more