Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cacb383dd7 | ||
|
|
ba95f1af66 | ||
|
|
9e577bf82b | ||
|
|
4cc4cd495f | ||
|
|
49d64ee299 | ||
|
|
30db17a0ce | ||
|
|
76b4af4d14 | ||
|
|
aa9c651bad | ||
|
|
8a17d367e8 | ||
|
|
bad7ba5ab5 | ||
|
|
4a7ad24fe8 | ||
|
|
60cdc891e3 | ||
|
|
b93b814550 | ||
|
|
8090c059e9 | ||
|
|
a83e4626cf | ||
|
|
8669697d95 | ||
|
|
308d5cf6a7 | ||
|
|
7ad14bee4a | ||
|
|
e7c0d9d05e | ||
|
|
98c59ca363 | ||
|
|
08cc768111 | ||
|
|
30a24ff7ab | ||
|
|
724d882ef4 | ||
|
|
26fc0acad3 | ||
|
|
85f1080964 | ||
|
|
3dde5b3baf | ||
|
|
6c95cc5b55 | ||
|
|
ce4caaa886 | ||
|
|
d3370a2c8f | ||
|
|
1eba9430d9 | ||
|
|
fe18af2e3d | ||
|
|
3793d17bb3 | ||
|
|
2fa7356b0e | ||
|
|
01364ccf68 | ||
|
|
88bcef0d15 | ||
|
|
b8786c50a6 | ||
|
|
e69126532d | ||
|
|
a06d1c62f5 | ||
|
|
46ba09b80b | ||
|
|
e125f80a13 | ||
|
|
d771de35c1 | ||
|
|
15456d4e8c | ||
|
|
2222f178a6 | ||
|
|
e46d122d2d | ||
|
|
dc96afe168 | ||
|
|
0b839aaea1 | ||
|
|
3814e6e63a | ||
|
|
d1744b1718 | ||
|
|
89f991b3fb | ||
|
|
4b0922cfd0 | ||
|
|
7a001c21dc | ||
|
|
8b21f78867 | ||
|
|
cb1340d4e6 | ||
|
|
2b47a12a8e | ||
|
|
fc88aba004 | ||
|
|
f7eacd10bd | ||
|
|
ea616f9c93 | ||
|
|
610f177395 | ||
|
|
92ca9f61bc | ||
|
|
37c731878d | ||
|
|
8a7172d8ac | ||
|
|
d4d632aa71 | ||
|
|
991d78b21d | ||
|
|
8c49666f58 | ||
|
|
ed8a11e7de | ||
|
|
4dad9c08ff | ||
|
|
2c209a8848 | ||
|
|
1d2f2132a6 | ||
|
|
a3026badf1 | ||
|
|
ad4cc6c61a | ||
|
|
a063bb6f56 | ||
|
|
cd4ea151c4 | ||
|
|
64a5bdc732 | ||
|
|
642d61bdef | ||
|
|
b1e80ad51f | ||
|
|
e1d754c52e | ||
|
|
fc5f8d2adc | ||
|
|
983c4e9fa2 | ||
|
|
e55764710b | ||
|
|
d29a58f0cc | ||
|
|
4867fca44a | ||
|
|
323bd5f502 | ||
|
|
9aa46b8312 | ||
|
|
4fb96c7182 | ||
|
|
b15777f196 | ||
|
|
747c31aee3 | ||
|
|
54faa2d1f8 | ||
|
|
55b69d693d | ||
|
|
113d21a1e1 | ||
|
|
95a8571b4c | ||
|
|
b8de50d4e0 | ||
|
|
11d758e48c | ||
|
|
6e8e08519b | ||
|
|
0e3e237656 | ||
|
|
8cd7bd7e71 | ||
|
|
d9c2ffe343 | ||
|
|
5f044e2cf7 | ||
|
|
55119792d9 | ||
|
|
38362c56ef | ||
|
|
4f43a4acb9 | ||
|
|
6fc77a2b23 | ||
|
|
5922d7e655 | ||
|
|
5f54b0a385 | ||
|
|
e9838c710b | ||
|
|
225edc9db8 | ||
|
|
f36998356c | ||
|
|
dcd0a7ee4e | ||
|
|
99a822c13a | ||
|
|
eeec680c65 | ||
|
|
40f0e7166b | ||
|
|
66df48c258 | ||
|
|
7225ef4674 | ||
|
|
e3a3c49af4 |
No files matched your search
@@ -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
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "server"]
|
||||
path = server
|
||||
url = [email protected]:heroiclabs/nakama.git
|
||||
@@ -4,6 +4,114 @@ 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.3] - 2021-3-16
|
||||
### Fixed
|
||||
- Dispatch error callback when socket connect fails.
|
||||
|
||||
## [2.1.2] - 2021-3-16
|
||||
### Fixed
|
||||
- Properly enable protobuf-javalite for Android builds.
|
||||
|
||||
## [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.
|
||||
|
||||
## [0.5.0] - 2017-11-21
|
||||
### Added
|
||||
- Support for In-App Notifications feature.
|
||||
- Support for Friends feature.
|
||||
- Support for Groups feature.
|
||||
|
||||
### Changed
|
||||
- Leaderboard sort order is now exposed as an enum rather than a number.
|
||||
|
||||
### Fixed
|
||||
- Use correct name for inconsistently defined topic leave message builder method.
|
||||
|
||||
## [0.4.0] - 2017-11-07
|
||||
### Changed
|
||||
- Expose a simpler interface for identifier fields.
|
||||
|
||||
## [0.3.0] - 2017-10-17
|
||||
### Added
|
||||
- Advanced Matchmaking with custom filters and user properties.
|
||||
|
||||
### Fixed
|
||||
- Improved errors to contain the underlying error reason.
|
||||
|
||||
## [0.2.0] - 2017-09-24
|
||||
### Added
|
||||
- Leaderboard messages.
|
||||
- Matchmaking messages.
|
||||
- Match messsages.
|
||||
- Match presence updates.
|
||||
- Topic messages.
|
||||
- Topic presence updates.
|
||||
|
||||
## [0.1.2] - 2017-09-02
|
||||
### Fixed
|
||||
- Pin transitive SLF4J dependency on 1.7.* stable release.
|
||||
- Use "okio.ByteString" rather than "java.util.Base64" for base64 support.
|
||||
|
||||
## [0.1.1] - 2017-08-14
|
||||
### Fixed
|
||||
- Correctly expose builder functions to external packages.
|
||||
|
||||
## [0.1.0] - 2017-08-13
|
||||
### Added
|
||||
- Initial public release.
|
||||
|
||||
@@ -3,29 +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
|
||||
dependencies {
|
||||
compile(group: 'com.heroiclabs.nakama', name: 'client', version: '+')
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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;
|
||||
@@ -34,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.
|
||||
@@ -55,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).
|
||||
@@ -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
|
||||
```
|
||||
|
||||
@@ -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,161 @@
|
||||
* 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/"
|
||||
}
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
|
||||
}
|
||||
}
|
||||
|
||||
group = 'com.heroiclabs.nakama'
|
||||
version = '0.1.0'
|
||||
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()
|
||||
}
|
||||
|
||||
configurations {
|
||||
all {
|
||||
exclude group: 'io.grpc', module:'grpc-protobuf'
|
||||
exclude group: "com.google.protobuf", module: "protobuf-java"
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
protobuf 'com.google.api.grpc:proto-google-common-protos:2.1.0'
|
||||
|
||||
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,134 +200,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.1'
|
||||
compile 'com.google.protobuf:protobuf-lite:3.0.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.8.1'
|
||||
compile 'com.stumbleupon:async:1.4.1'
|
||||
compile 'org.slf4j:slf4j-api:1.7.25'
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
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/**'
|
||||
}
|
||||
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'
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/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
|
||||
PROTOBUF_COMMIT=dfab275eca9481b5de31122db6fc91b31db3382a
|
||||
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
|
||||
|
||||
### java proto-lite does not contain descriptor.proto
|
||||
DESCRIPTOR_URL=${DOMAIN}/protocolbuffers/protobuf/${PROTOBUF_COMMIT}/src/google/protobuf/descriptor.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 ${ROOT_DIR}/apigrpc.proto
|
||||
curl $DESCRIPTOR_URL -o ${ROOT_DIR}/google/protobuf/descriptor.proto
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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 29
|
||||
buildToolsVersion "29.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.androidnakama"
|
||||
minSdkVersion 29
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ext{
|
||||
versionFirebaseCrashlytics = "17.3.0"
|
||||
versionFirebaseBom = "26.2.0"
|
||||
versionNakama = "76b4af4d149f715eed491052f3fa9963e0b0d781"
|
||||
versionProtobuf = "3.13.0"
|
||||
versionPlayAuth = "19.0.0"
|
||||
}
|
||||
|
||||
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:${versionNakama}"
|
||||
|
||||
// fat JAR
|
||||
// implementation 'com.github.heroiclabs.nakama-java:nakama-java-all:dde7330adfa1867881dc6c6c6e27c1176512c916'
|
||||
|
||||
// Import the BoM for the Firebase platform
|
||||
implementation platform("com.google.firebase:firebase-bom:26.2.0")
|
||||
|
||||
// Firebase
|
||||
// Import the BoM for the Firebase platform
|
||||
implementation platform("com.google.firebase:firebase-bom:${versionFirebaseBom}")
|
||||
|
||||
// Declare the dependencies for the Remote Config and Analytics libraries
|
||||
// When using the BoM, you don't specify versions in Firebase library dependencies
|
||||
implementation 'com.google.firebase:firebase-config-ktx'
|
||||
implementation 'com.google.firebase:firebase-analytics-ktx'
|
||||
implementation 'com.google.firebase:firebase-crashlytics'
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ndk'
|
||||
implementation 'com.google.firebase:firebase-messaging'
|
||||
implementation 'com.google.firebase:firebase-auth'
|
||||
implementation "com.google.android.gms:play-services-auth:${versionPlayAuth}"
|
||||
}
|
||||
@@ -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,20 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.nakama_java_test_android">
|
||||
|
||||
<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" >
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -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.example.nakama_java_test_android;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import com.google.common.util.concurrent.*;
|
||||
import com.heroiclabs.nakama.*;
|
||||
import android.app.*;
|
||||
import android.os.Bundle;
|
||||
import android.util.*;
|
||||
|
||||
// fat jar
|
||||
// import nakama.com.google.common.util.concurrent.*;
|
||||
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final DefaultClient client = new DefaultClient("defaultkey", "10.0.2.2", 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) {
|
||||
Log.i("auth","got session: " + result.getAuthToken());
|
||||
client.createSocket();
|
||||
executor.shutdown();
|
||||
}
|
||||
@Override
|
||||
public void onFailure(final Throwable throwable) {
|
||||
Log.e("auth", 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>
|
||||
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
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>
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
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 DefaultRpcMessage implements RpcMessage {
|
||||
|
||||
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.1.2'
|
||||
|
||||
// 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 @@
|
||||
#Mon Mar 15 08:33:52 EDT 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||
@@ -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" "$@"
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
include ':app'
|
||||
rootProject.name = "nakama-java-test-android"
|
||||
@@ -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:76b4af4d149f715eed491052f3fa9963e0b0d781'
|
||||
// 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
|
||||
@@ -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" "$@"
|
||||
@@ -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
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Bintray credentials
|
||||
bintrayUser=
|
||||
bintrayKey=
|
||||
@@ -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
|
||||
@@ -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" "$@"
|
||||
@@ -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
|
||||
@@ -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 {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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
|
||||
/**
|
||||
* 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,12 +16,12 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
/**
|
||||
* A listener for receiving {@code Client} events.
|
||||
* A leave message to a chat channel.
|
||||
*/
|
||||
public interface ClientListener {
|
||||
/**
|
||||
* Called when the client socket disconnects.
|
||||
*/
|
||||
void onDisconnect();
|
||||
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,20 +18,27 @@ package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultRecordId implements RecordId {
|
||||
|
||||
private final String bucket;
|
||||
|
||||
private final String collection;
|
||||
|
||||
private final String key;
|
||||
|
||||
private final byte[] version;
|
||||
|
||||
static RecordId fromProto(final @NonNull com.heroiclabs.nakama.Api.TStorageKeys.StorageKey key) {
|
||||
return new DefaultRecordId(key.getBucket(), key.getCollection(), key.getRecord(), key.getVersion().toByteArray());
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
@@ -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,12 +16,13 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
/**
|
||||
* A message which requires no acknowledgement by the server.
|
||||
* A remove message for a chat channel.
|
||||
*/
|
||||
public interface Message {
|
||||
/**
|
||||
* @return The serialized format of the message.
|
||||
*/
|
||||
byte[] asBytes();
|
||||
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;
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
/**
|
||||
* The available channel types on the server.
|
||||
*/
|
||||
public enum ChannelType {
|
||||
/**
|
||||
* A chat room which can be created dynamically with a name.
|
||||
*/
|
||||
ROOM(0),
|
||||
|
||||
/**
|
||||
* A private chat between two users.
|
||||
*/
|
||||
DIRECT_MESSAGE(1),
|
||||
|
||||
/**
|
||||
* A chat within a group on the server.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultCursor implements Cursor {
|
||||
|
||||
private final byte[] value;
|
||||
|
||||
public String serialize() {
|
||||
return Base64.getEncoder().encodeToString(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) {
|
||||
final byte[] cursor = Base64.getDecoder().decode(serializedCursor);
|
||||
return new DefaultCursor(cursor);
|
||||
}
|
||||
}
|
||||
@@ -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,21 +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.code = ErrorCode.UNKNOWN;
|
||||
this.collationId = null;
|
||||
}
|
||||
|
||||
DefaultError(final @NonNull String message, final int code) {
|
||||
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,39 +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 DefaultRpcResult implements RpcResult {
|
||||
|
||||
private final String id;
|
||||
|
||||
private final byte[] payload;
|
||||
|
||||
@Override
|
||||
public <T> T getPayload(Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(payload), clazz);
|
||||
}
|
||||
|
||||
static RpcResult fromProto(final @NonNull com.heroiclabs.nakama.Api.TRpc rpc) {
|
||||
return new DefaultRpcResult(rpc.getId(), rpc.getPayload().toByteArray());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +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.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultSelf implements Self {
|
||||
|
||||
private final String avatarUrl;
|
||||
|
||||
private final long createdAt;
|
||||
|
||||
private final String fullname;
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
private final long lastOnlineAt;
|
||||
|
||||
private final String location;
|
||||
|
||||
private final byte[] metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
private final String customId;
|
||||
|
||||
private final List<String> deviceIds;
|
||||
|
||||
private final String email;
|
||||
|
||||
private final String facebookId;
|
||||
|
||||
private final String gameCenterId;
|
||||
|
||||
private final String googleId;
|
||||
|
||||
private final String steamId;
|
||||
|
||||
private final boolean verified;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
}
|
||||
|
||||
static Self fromProto(final @NonNull com.heroiclabs.nakama.Api.Self self) {
|
||||
return new DefaultSelf(self.getUser().getAvatarUrl(), self.getUser().getCreatedAt(),
|
||||
self.getUser().getFullname(), self.getUser().getHandle(), self.getUser().getId().toByteArray(),
|
||||
self.getUser().getLang(), self.getUser().getLastOnlineAt(), self.getUser().getLocation(),
|
||||
self.getUser().getMetadata().toByteArray(), self.getUser().getTimezone(), self.getUser().getUpdatedAt(),
|
||||
self.getCustomId(), self.getDeviceIdsList(), self.getEmail(), self.getFacebookId(),
|
||||
self.getGamecenterId(), self.getGoogleId(), self.getSteamId(), self.getVerified());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 DefaultSelfFetchMessage implements SelfFetchMessage {
|
||||
|
||||
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)
|
||||
public class DefaultSelfLinkMessage implements SelfLinkMessage {
|
||||
|
||||
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)
|
||||
public class DefaultSelfUnlinkMessage implements SelfUnlinkMessage {
|
||||
|
||||
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 DefaultSelfUpdateMessage implements SelfUpdateMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.
|
||||
@@ -15,58 +15,75 @@
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.*;
|
||||
import okio.ByteString;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Base64;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class DefaultSession implements Session {
|
||||
private final long createTime;
|
||||
private final long expireTime;
|
||||
private final boolean created;
|
||||
private final String username;
|
||||
private final String userId;
|
||||
private final String authToken;
|
||||
private final Map<String, String> vars;
|
||||
|
||||
private final long createdAt;
|
||||
|
||||
private final long expiresAt;
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
|
||||
private final String token;
|
||||
|
||||
private DefaultSession(final String token) {
|
||||
DefaultSession(final String token, final boolean created) {
|
||||
final String[] decoded = token.split("\\.");
|
||||
if (decoded.length != 3) {
|
||||
throw new IllegalArgumentException("Not a valid token.");
|
||||
}
|
||||
final String decodedJson = new String(Base64.getDecoder().decode(decoded[1]));
|
||||
final String decodedJson = ByteString.decodeBase64(decoded[1]).string(Charset.defaultCharset());
|
||||
Type type = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> jsonMap = DefaultClient.GSON.fromJson(decodedJson, type);
|
||||
|
||||
createdAt = System.currentTimeMillis();
|
||||
expiresAt = Math.round(((Double) jsonMap.get("exp")) * 1000L);
|
||||
handle = jsonMap.get("han").toString();
|
||||
Gson gson = new Gson();
|
||||
Map<String, Object> jsonMap = gson.fromJson(decodedJson, type);
|
||||
|
||||
final UUID uid = UUID.fromString(jsonMap.get("uid").toString());
|
||||
final ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
|
||||
bb.putLong(uid.getMostSignificantBits());
|
||||
bb.putLong(uid.getLeastSignificantBits());
|
||||
id = bb.array();
|
||||
this.createTime = System.currentTimeMillis();
|
||||
this.expireTime = Math.round(((Double) jsonMap.get("exp")) * 1000L);
|
||||
this.username = jsonMap.get("usn").toString();
|
||||
this.userId = jsonMap.get("uid").toString();
|
||||
this.vars = new HashMap();
|
||||
if (jsonMap.get("vrs") != null) {
|
||||
var v = jsonMap.get("vrs");
|
||||
if (v instanceof Map) {
|
||||
var vm = (Map) v;
|
||||
for (Object key : vm.keySet()) {
|
||||
this.vars.put(key.toString(), vm.get(key).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.token = token;
|
||||
this.created = created;
|
||||
this.authToken = token;
|
||||
}
|
||||
|
||||
public boolean isExpired(final long currentTimeMillis) {
|
||||
return (expiresAt - currentTimeMillis) < 0L;
|
||||
@Override
|
||||
public boolean IsExpired() {
|
||||
return isExpired(new Date());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired(Date dateTime) {
|
||||
return (expireTime - dateTime.getTime()) < 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a session from an authentication token.
|
||||
* @param token The authentication token from a <c>Session</c>.
|
||||
* @return A session restored from the authentication token.
|
||||
*/
|
||||
public static Session restore(final String token) {
|
||||
return new DefaultSession(token);
|
||||
return new DefaultSession(token, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 DefaultStorageFetchMessage implements StorageFetchMessage {
|
||||
|
||||
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 DefaultStorageListMessage implements StorageListMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
class DefaultStorageRecord implements StorageRecord {
|
||||
|
||||
private final String bucket;
|
||||
|
||||
private final long createdAt;
|
||||
|
||||
private final String collection;
|
||||
|
||||
private final long expiresAt;
|
||||
|
||||
private final String key;
|
||||
|
||||
private final PermissionRead permissionRead;
|
||||
|
||||
private final PermissionWrite permissionWrite;
|
||||
|
||||
private final byte[] value;
|
||||
|
||||
private final byte[] version;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
private final byte[] userId;
|
||||
|
||||
@Override
|
||||
public <T> T getValue(Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(value), clazz);
|
||||
}
|
||||
|
||||
static StorageRecord fromProto(final @NonNull com.heroiclabs.nakama.Api.TStorageData.StorageData data) {
|
||||
return new DefaultStorageRecord(data.getBucket(), data.getCreatedAt(), data.getCollection(),
|
||||
data.getExpiresAt(), data.getRecord(), PermissionRead.fromInt(data.getPermissionRead()),
|
||||
PermissionWrite.fromInt(data.getPermissionWrite()), data.getValue().toByteArray(),
|
||||
data.getVersion().toByteArray(), data.getUpdatedAt(), data.getUserId().toByteArray());
|
||||
}
|
||||
}
|
||||
@@ -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 DefaultStorageRemoveMessage implements StorageRemoveMessage {
|
||||
|
||||
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 DefaultStorageUpdateMessage implements StorageUpdateMessage {
|
||||
|
||||
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 DefaultStorageWriteMessage implements StorageWriteMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
class DefaultUser implements User {
|
||||
|
||||
private final String avatarUrl;
|
||||
|
||||
private final long createdAt;
|
||||
|
||||
private final String fullname;
|
||||
|
||||
private final String handle;
|
||||
|
||||
private final byte[] id;
|
||||
|
||||
private final String lang;
|
||||
|
||||
private final long lastOnlineAt;
|
||||
|
||||
private final String location;
|
||||
|
||||
private final byte[] metadata;
|
||||
|
||||
private final String timezone;
|
||||
|
||||
private final long updatedAt;
|
||||
|
||||
public <T> T getMetadata(final Class<T> clazz) {
|
||||
return DefaultClient.GSON.fromJson(new String(metadata), clazz);
|
||||
}
|
||||
|
||||
static User fromProto(final @NonNull com.heroiclabs.nakama.Api.User user) {
|
||||
return new DefaultUser(user.getAvatarUrl(), user.getCreatedAt(),
|
||||
user.getFullname(), user.getHandle(), user.getId().toByteArray(),
|
||||
user.getLang(), user.getLastOnlineAt(), user.getLocation(),
|
||||
user.getMetadata().toByteArray(), user.getTimezone(), user.getUpdatedAt());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 DefaultUsersFetchMessage implements UsersFetchMessage {
|
||||
|
||||
private final com.heroiclabs.nakama.Api.Envelope.Builder payload;
|
||||
|
||||
public byte[] asBytes(final @NonNull String collationId) {
|
||||
return payload.clone().setCollationId(collationId).build().toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.
|
||||
@@ -20,10 +20,6 @@ import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An error caused from an operation with the server.
|
||||
*/
|
||||
@@ -32,47 +28,55 @@ public abstract class Error extends Exception {
|
||||
/**
|
||||
* @param message The error message to construct with.
|
||||
*/
|
||||
public Error(final @NonNull String message) {
|
||||
Error(final @NonNull String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The error message to construct with.
|
||||
*/
|
||||
Error(final @NonNull String message, final @NonNull Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error code for the problem.
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
enum ErrorCode {
|
||||
public enum ErrorCode {
|
||||
UNKNOWN(0),
|
||||
RUNTIME_EXCEPTION(1),
|
||||
UNRECOGNISED_PAYLOAD(2),
|
||||
MISSING_PAYLOAD(3),
|
||||
BAD_INPUT(4),
|
||||
AUTH_ERROR(5),
|
||||
USER_NOT_FOUND(6),
|
||||
USER_REGISTER_INUSE(7),
|
||||
USER_LINK_INUSE(8),
|
||||
USER_LINK_PROVIDER_UNAVAILABLE(9),
|
||||
USER_UNLINK_DISALLOWED(10),
|
||||
USER_HANDLE_INUSE(11),
|
||||
GROUP_NAME_INUSE(12),
|
||||
GROUP_LAST_ADMIN(13),
|
||||
STORAGE_REJECTED(14),
|
||||
MATCH_NOT_FOUND(15),
|
||||
RUNTIME_FUNCTION_NOT_FOUND(16),
|
||||
RUNTIME_FUNCTION_EXCEPTION(17);
|
||||
MATCH_NOT_FOUND(5),
|
||||
MATCH_JOIN_REJECTED(6),
|
||||
RUNTIME_FUNCTION_NOT_FOUND(7),
|
||||
RUNTIME_FUNCTION_EXCEPTION(8);
|
||||
|
||||
private final int code;
|
||||
|
||||
// Static helpers to transform wire protocol int codes into their enum equivalents.
|
||||
private static final Map<Integer, ErrorCode> codeMappings;
|
||||
static {
|
||||
Map<Integer, ErrorCode> codes = new HashMap<>();
|
||||
for (ErrorCode code : ErrorCode.values()) {
|
||||
codes.put(code.code, code);
|
||||
}
|
||||
codeMappings = Collections.unmodifiableMap(codes);
|
||||
}
|
||||
static ErrorCode fromInt(final int code) {
|
||||
return codeMappings.getOrDefault(code + 1, ErrorCode.UNKNOWN);
|
||||
switch (code) {
|
||||
case 0:
|
||||
return RUNTIME_EXCEPTION;
|
||||
case 1:
|
||||
return UNRECOGNISED_PAYLOAD;
|
||||
case 2:
|
||||
return MISSING_PAYLOAD;
|
||||
case 3:
|
||||
return BAD_INPUT;
|
||||
case 4:
|
||||
return MATCH_NOT_FOUND;
|
||||
case 5:
|
||||
return MATCH_JOIN_REJECTED;
|
||||
case 6:
|
||||
return RUNTIME_FUNCTION_NOT_FOUND;
|
||||
case 7:
|
||||
return RUNTIME_FUNCTION_EXCEPTION;
|
||||
default:
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +84,9 @@ public abstract class Error extends Exception {
|
||||
* @return The code for the error.
|
||||
*/
|
||||
public abstract ErrorCode getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The collation ID associated with this error. Could be null.
|
||||
*/
|
||||
public abstract String getCollationId();
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2020 Heroic Labs
|
||||
*
|
||||
* 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.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
/*
|
||||
* A custom Date serializer to indicate to GSON that it is receiving UTC timestamps.
|
||||
*/
|
||||
public class GsonDateDeserializer implements JsonDeserializer<Date> {
|
||||
|
||||
@Override
|
||||
public Date deserialize(JsonElement element, Type arg1, JsonDeserializationContext arg2) throws JsonParseException {
|
||||
String date = element.getAsString();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("y-M-d'T'H:m:s'Z'");
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
try {
|
||||
return formatter.parse(date);
|
||||
}
|
||||
catch (ParseException e) {
|
||||
throw new JsonParseException("Could not deserialize Date.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +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;
|
||||
|
||||
public interface LogoutMessage extends Message {
|
||||
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
class Builder {
|
||||
|
||||
static LogoutMessage build() {
|
||||
final com.heroiclabs.nakama.Api.Envelope.Builder payload =
|
||||
com.heroiclabs.nakama.Api.Envelope.newBuilder()
|
||||
.setLogout(com.heroiclabs.nakama.Api.Logout.newBuilder());
|
||||
return new DefaultLogoutMessage(payload);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
/**
|
||||
* A multiplayer match.
|
||||
*/
|
||||
public class Match {
|
||||
/**
|
||||
* True if this match has an authoritative handler on the server.
|
||||
*/
|
||||
private boolean authoritative;
|
||||
/**
|
||||
* The unique match identifier.
|
||||
*/
|
||||
private String matchId;
|
||||
/**
|
||||
* A label for the match which can be filtered on.
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* The presences already in the match.
|
||||
*/
|
||||
private List<UserPresence> presences;
|
||||
/**
|
||||
* The number of users currently in the match.
|
||||
*/
|
||||
private int size;
|
||||
/**
|
||||
* The current user in this match. i.e. Yourself.
|
||||
*/
|
||||
private UserPresence self;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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 create message for a match on the server.
|
||||
*/
|
||||
class MatchCreateMessage {
|
||||
}
|
||||
@@ -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 com.google.common.io.BaseEncoding;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
/**
|
||||
* Some game state update in a match.
|
||||
*/
|
||||
public class MatchData {
|
||||
/**
|
||||
* The unique match identifier.
|
||||
*/
|
||||
private String matchId;
|
||||
|
||||
/**
|
||||
* The operation code for the state change.
|
||||
* This value can be used to mark the type of the contents of the state.
|
||||
*/
|
||||
private long opCode;
|
||||
|
||||
/**
|
||||
* the base-64 contents of the state change.
|
||||
*/
|
||||
private String data;
|
||||
|
||||
/**
|
||||
* Information on the user who sent the state change.
|
||||
*/
|
||||
private UserPresence presence;
|
||||
|
||||
/**
|
||||
* Returns match data
|
||||
* @return match data
|
||||
*/
|
||||
public byte[] getData() {
|
||||
if (this.data == null) {
|
||||
return null;
|
||||
}
|
||||
return BaseEncoding.base64().decode(this.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* True if this data was delivered reliably, false otherwise.
|
||||
*/
|
||||
private boolean reliable;
|
||||
}
|
||||
@@ -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,18 +16,16 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
/**
|
||||
* A join message for a match on the server.
|
||||
*/
|
||||
class MatchJoinMessage {
|
||||
private String matchId;
|
||||
private String token;
|
||||
private Map<String, String> metadata;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 leave message for a match on the server.
|
||||
*/
|
||||
class MatchLeaveMessage {
|
||||
private final String matchId;
|
||||
}
|
||||
@@ -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,26 +16,30 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString(includeFieldNames = true)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
class DefaultResultSet<T> implements ResultSet<T> {
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
/**
|
||||
* A batch of join and leave presences for a match.
|
||||
*/
|
||||
public class MatchPresenceEvent {
|
||||
/**
|
||||
* The unique match identifier.
|
||||
*/
|
||||
private String matchId;
|
||||
|
||||
private final Cursor cursor;
|
||||
|
||||
private final List<T> results;
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return results.iterator();
|
||||
}
|
||||
/**
|
||||
* Presences of users who joined the match.
|
||||
*/
|
||||
private List<UserPresence> joins;
|
||||
|
||||
/**
|
||||
* Presences of users who left the match.
|
||||
*/
|
||||
private List<UserPresence> leaves;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
/**
|
||||
* Send new state to a match on the server.
|
||||
*/
|
||||
class MatchSendMessage {
|
||||
private final String matchId;
|
||||
private final long opCode;
|
||||
private final byte[] data;
|
||||
private List<UserPresence> presences;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
/**
|
||||
* Add the user to the matchmaker pool with properties.
|
||||
*/
|
||||
class MatchmakerAddMessage {
|
||||
private int MinCount;
|
||||
private int MaxCount;
|
||||
private String Query;
|
||||
private Map<String, Double> NumericProperties;
|
||||
private Map<String, String> StringProperties;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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)
|
||||
|
||||
/**
|
||||
* The result of a successful matchmaker operation sent to the server.
|
||||
*/
|
||||
public class MatchmakerMatched {
|
||||
/**
|
||||
* The id used to join the match.
|
||||
* A match ID used to join the match.
|
||||
*/
|
||||
private String matchId;
|
||||
/**
|
||||
* The ticket sent by the server when the user requested to matchmake for other players.
|
||||
*/
|
||||
private String ticket;
|
||||
/**
|
||||
* The token used to join a match.
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* The other users matched with this user and the parameters they sent.
|
||||
*/
|
||||
private List<MatchmakerUser> users;
|
||||
/**
|
||||
* The current user who matched with opponents.
|
||||
*/
|
||||
private MatchmakerUser self;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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
|
||||
/**
|
||||
* Remove the user from the matchmaker pool by ticket.
|
||||
*/
|
||||
class MatchmakerRemoveMessage {
|
||||
private final String ticket;
|
||||
}
|
||||
@@ -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,17 +16,18 @@
|
||||
|
||||
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.
|
||||
*/
|
||||
byte[] getValue();
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
/**
|
||||
* The matchmaker ticket received from the server.
|
||||
*/
|
||||
public class MatchmakerTicket {
|
||||
/**
|
||||
* @return Encode the cursor so it can be cached.
|
||||
* The ticket generated by the matchmaker.
|
||||
*/
|
||||
String serialize();
|
||||
private String ticket;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.Map;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
/**
|
||||
* The user with the parameters they sent to the server when asking for opponents.
|
||||
*/
|
||||
public class MatchmakerUser {
|
||||
/**
|
||||
* The numeric properties which this user asked to matchmake with.
|
||||
*/
|
||||
private Map<String, Double> numericProperties;
|
||||
/**
|
||||
* The presence of the user.
|
||||
*/
|
||||
private UserPresence presence;
|
||||
/**
|
||||
* The string properties which this user asked to matchmake with.
|
||||
*/
|
||||
private Map<String, String> stringProperties;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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)
|
||||
/**
|
||||
* A notification object.
|
||||
*/
|
||||
// This message type is only used for GSON, and not exposed to the Client interface.
|
||||
class Notification {
|
||||
private String id;
|
||||
private String subject;
|
||||
private String content;
|
||||
private int code;
|
||||
private String senderId;
|
||||
private Date createTime;
|
||||
private boolean persistent;
|
||||
}
|
||||
@@ -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,21 +16,19 @@
|
||||
|
||||
package com.heroiclabs.nakama;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
/**
|
||||
* A set of objects which has been fetched from the server.
|
||||
*
|
||||
* @param <T> The type of the objects fetched.
|
||||
* List of notifications with cursor.
|
||||
*/
|
||||
public interface ResultSet<T> extends Iterable<T> {
|
||||
/**
|
||||
* @return The cursor used to fetch the next {@code ResultSet<T>}.
|
||||
*/
|
||||
Cursor getCursor();
|
||||
|
||||
/**
|
||||
* @return The underlying list of objects.
|
||||
*/
|
||||
List<T> getResults();
|
||||
// This message type is only used for GSON, and not exposed to the Client interface.
|
||||
class NotificationList {
|
||||
private List<Notification> notifications;
|
||||
private String cacheableCursor;
|
||||
}
|
||||