Compare commits

..
108 Commits
Author SHA1 Message Date
Luke Gehorsam cacb383dd7 set exception on connect future if socket receives failure or close while connecting 2021-03-18 20:58:20 -04:00
Luke Gehorsam ba95f1af66 rename connect future in web socket client 2021-03-18 20:53:22 -04:00
Luke Gehorsam 9e577bf82b rename cidFuture in websocketclient 2021-03-18 20:52:59 -04:00
Luke Gehorsam 4cc4cd495f add test for socket connect callbacks 2021-03-18 20:51:19 -04:00
Luke Gehorsam 49d64ee299 update changelog for v2.1.2 2021-03-16 16:32:50 -04:00
Luke Gehorsam 30db17a0ce update nakama-java dependency in examples 2021-03-16 16:30:29 -04:00
Luke Gehorsam 76b4af4d14 add proper compilation step for google common protos and manually downlaod descriptor.proto 2021-03-16 14:13:05 -04:00
Luke Gehorsam aa9c651bad exclude protobuf-java from all configurations 2021-03-16 10:39:31 -04:00
Luke Gehorsam 8a17d367e8 exclude grpc-protobuf from all configurations 2021-03-16 10:24:58 -04:00
Luke Gehorsam bad7ba5ab5 convert java main to mainactivity in android example 2021-03-16 08:45:24 -04:00
Luke Gehorsam 4a7ad24fe8 add firebase to our android example 2021-03-09 12:09:12 -05:00
Luke Gehorsam 60cdc891e3 update build version in build.gradle 2021-02-17 10:01:30 -05:00
Luke Gehorsam b93b814550 update changelog, releaseinst 2021-02-17 09:44:53 -05:00
Lokesh Jangid 8090c059e9 DefaultError: allow null collationId in constructor 2021-02-17 10:28:45 +00:00
Luke Gehorsam a83e4626cf tweak readme 2021-01-25 20:59:22 -05:00
Luke 8669697d95 Add Facebook Instant Game authentication and Apple authentication (#49)
* update nakama protos

* update grpc gateway proto files

* implement auth., link, unlink apple

* add facebook instant game authentication

* add link and unlink facebook instant game

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

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

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

* remove redundant globs

* use more idiomatic android package name for example

* add license headers to java and groovy files

* use correct ListenableFuture pattern in example project code

* use separate artifactId instead of separate classifier for shadowJar

* update readme with new fatjar artifact id

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

* fix gitignore newlines

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

* process web socket messages using a single thread

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

* add multithreading socket note to java sdk

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

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

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

* ignore all built code

* try shadow task

* remove git-publish and bintray for now

* upgrade lombok from 1.18.10 to 1.18.12

* upgrade grpc, protobuf

* upgrade okhttp

* update slf4j to 1.7.40 and don't force it

* remove manual pulling in of common protos from protobufjava

* include slf4j-simple as a test

* use thin and fat terminology for jar ids

* configure all tasks of type AbstractPublishToMaven

* update readme

* fix xml indentation

* add parent tags to maven examples

* move logger implementation to shadowjar task

* remove old bintray creds

* Replace thin terminology with main

* invert exclusion of simple logger

* expose listenable future  as part of the library api

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

* pass socket ping to pingInterval

* pass in timeout and ping as static defaults

* update changelog

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

* don't use two different date formats

* write test verifying proper createTime() for notifs

* oops, use math.abs

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

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

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

* commit new generated source

* update to gradle 5.0

* upgrade to gradle 6.0

* upgrade to gradle 6.5.1

* suppress warnings from generate code in eclipse

* Support for logs in tests

* add basic test for listing tournaments

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

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

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

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

* fix assertion on tournament record expiry

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

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

* update test on creation of future tournaments

* Add support for banning users to the Java SDK

* update changelog re: tourney test suite

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

* add newline to EOF in download-protos

* remove unused build code

* exclude actual .proto files from .jar

* exclude grpc gateway meta protos from codegen

* update shadowjar dependency and document it

* add relocation support to shadowjar

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

No files matched your search

+8 -4
View File
@@ -1,5 +1,7 @@
# Created by https://www.gitignore.io/api/git,java,macos,linux,gradle,eclipse,windows,sublimetext,intellij+all,intellij+iml
**/build
### Custom ###
.BINTRAY
@@ -282,14 +284,13 @@ $RECYCLE.BIN/
*.lnk
### Gradle ###
.gradle
/build/
**/.gradle
# Ignore Gradle GUI config
gradle-app.setting
**/gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
**/gradle-wrapper.jar
# Cache of project
.gradletasknamecache
@@ -298,3 +299,6 @@ gradle-app.setting
# gradle/wrapper/gradle-wrapper.properties
# End of https://www.gitignore.io/api/git,java,macos,linux,gradle,eclipse,windows,sublimetext,intellij+all,intellij+iml
# Maven
**/target
-3
View File
@@ -1,3 +0,0 @@
[submodule "server"]
path = server
url = [email protected]:heroiclabs/nakama.git
+103 -1
View File
@@ -6,10 +6,112 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
## [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
- Correctly expose builder functions to external packages.
## [0.1.0] - 2017-08-13
### Added
- Initial public release.
+157 -24
View File
@@ -3,35 +3,79 @@ Nakama Java
> Android optimized Java client for Nakama server.
Nakama is an [open-source](https://github.com/heroiclabs/nakama) distributed server for social and realtime games and apps. For more information have a look at the [documentation](https://heroiclabs.com/docs/).
[Nakama](https://github.com/heroiclabs/nakama) is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much [more](https://heroiclabs.com).
This client implements the protocol and all features available in the server. It is compatible with Java 1.7+ and Android 2.3+. The [Javadocs](https://heroiclabs.github.io/nakama-java/current/) for the client are maintained on GitHub Pages.
This client implements the full API and socket options with the server. It's written in C# with minimal dependencies to support Unity, Xamarin, Godot, XNA, and other engines and frameworks.
If you encounter any issues with the server you can generate diagnostics for us with the [doctor](https://heroiclabs.com/docs/install-server-cli/#doctor) subcommand. Send these to support@heroiclabs.com or [open an issue](https://github.com/heroiclabs/nakama/issues). If you experience any issues with the client, it can be useful to [enable trace](https://heroiclabs.com/docs/android-java-client-guide/#logs-and-errors) to produce detailed logs and [open an issue](https://github.com/heroiclabs/nakama-java/issues).
Full documentation is online - https://heroiclabs.com/docs
## Usage
## Getting Started
The client can be downloaded from [GitHub releases](https://github.com/heroiclabs/nakama-java/releases). You can download "nakama-java-$version.jar" or "nakama-java-$version-all.jar" which includes a shadowed copy of all dependencies.
You'll need to setup the server and database before you can connect with the client. The simplest way is to use Docker but have a look at the [server documentation](https://github.com/heroiclabs/nakama#getting-started) for other options.
If you use a build tool like Gradle you can skip the download and fetch it from the central repository.
1. Install and run the servers. Follow these [instructions](https://heroiclabs.com/docs/install-docker-quickstart).
2. The Java SDK can be imported with either Grade or Maven through [Jitpack](https://jitpack.io/).
### Gradle
```groovy
repositories {
maven {
url 'https://dl.bintray.com/heroiclabs/default/'
url 'https://jitpack.io'
}
}
dependencies {
compile(group: 'com.heroiclabs.nakama', name: 'client', version: '+')
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;
@@ -40,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.
@@ -61,14 +172,36 @@ Android uses a permissions system which determines which platform services the a
To build the codebase you will need to install these dependencies:
* Java Runtime Environment 1.7+
* Java Development Kit 1.7+
* Gradle build tool
* Java Runtime Environment 1.8+
* Java Development Kit 1.8+
The Gradle project is setup to download and manage the Google Protocol buffers compiler toolchain automatically and generate Protobuf Lite definitions required by the source code.
Invoke the Gradle Wrapper with `./gradlew build` and Gradle will install your dependencies over
the network for you prior to building. It will then make a build and run the full test suite.
```
$> gradle build
```
To test a specific test, run `./gradlew test --tests <ClassName.methodName>`
Run "gradle tasks" for a list of available build tasks.
You can also run `./gradlew tasks` for a list of available build tasks.
To create a fat JAR with self-contained dependencies, run:
`./gradlew shadow`
All JAR artifacts are output to `build/libs`. The fat JAR will have an artifact id of 'nakama-java-all`.
If you'd like to test a Jitpack publish task locally prior to pushing, run:
`./gradlew publishToMavenLocal`
### Protobuf Sourcing
If you need to re-download all .proto dependenies, run `./download-protos` from the root of this repository.
### Jitpack
Jitpack makes builds of each commit on its own servers. You can view the results of each build and the corresponding artifacts at the following url:
https://jitpack.io/com/github/heroiclabs/nakama-java/<_commit_>/build.log
### License
This project is licensed under the [Apache-2 License](https://github.com/heroiclabs/nakama-dotnet/blob/master/LICENSE).
+13 -26
View File
@@ -1,6 +1,7 @@
## Release Instructions
The current release infrastructure is built into the project's [build.gradle](https://github.com/heroiclabs/nakama-java/blob/master/build.gradle). You'll need both the JDK 1.7+ and `gradle` installed to generate release packages which can be uploaded to GitHub and deployed to `"jcenter"`.
The current release infrastructure is built into the project's [build.gradle](https://github.com/heroiclabs/nakama-java/blob/master/build.gradle). You'll need both the
JDK 1.8+ and `gradle` installed to generate release packages which can be uploaded to GitHub and deployed to `"jcenter"`.
### New releases
@@ -18,13 +19,14 @@ The development team use these steps to build and upload a release.
1. Update the `CHANGELOG.md`.
Make sure to add the relevant "Added", "Changed", "Deprecated", "Removed", "Fixed", and "Security" sections as suggested by [keep a changelog](http://keepachangelog.com).
Make sure to add the relevant "Added", "Changed", "Deprecated", "Removed", "Fixed", and "Security" sections as suggested by [keep a
changelog](http://keepachangelog.com).
2. Update version in `build.gradle` and commit. i.e. `version = '0.1.0'` should become `version = '0.2.0'`.
2. Update version in `build.gradle` and commit. For example: `version = '2.0.0'` should become `version = '2.1.0'`.
```
git add build.gradle CHANGELOG.md
git commit -m "Nakama Java 0.2.0 release."
git commit -m "Nakama Java 2.0.0 release."
```
3. Tag the release.
@@ -32,34 +34,19 @@ The development team use these steps to build and upload a release.
__Note__ In source control good semver suggests a `"v"` prefix on a version. It helps group release tags.
```
git tag -a v0.2.0 -m "v0.2.0"
git push origin v0.2.0
git tag -a v2.0.0 -m "v2.0.0"
git push origin v2.0.0
```
4. You can upload the release onto <a href="https://bintray.com/bintray/jcenter" target="\_blank">jcenter</a>. You must set the values in `"gradle.properties"` to your Bintray credentials.
4. Login and create a [new draft release](https://github.com/heroiclabs/nakama-java/releases/new) on GitHub. Repeat the changelog in the release description. Then publish
the release.
```
gradle -PvcsTag="v0.2.0" bintrayUpload
```
5. Login and create a [new draft release](https://github.com/heroiclabs/nakama-java/releases/new) on GitHub. Repeat the changelog in the release description. Then publish the release.
6. Add the previous version of the docs to the `"preserve"` closure in the build script. Deploy the latest Javadoc to GitHub Pages.
```
preserve {
include '0.1.0/**'
}
```
```
gradle gitPublishPush
```
7. Add new `## [Unreleased]` section to start of `CHANGELOG.md`. Increment version in `build.gradle` and commit. i.e. `version = '0.2.0'` should now become `version = '0.3.0'`.
5. Add new `## [Unreleased]` section to start of `CHANGELOG.md`. Increment version in `build.gradle` and commit. i.e. `version = '2.0.0'` should now become `version =
'2.1.0'`.
```
git add build.gradle CHANGELOG.md
git commit -m "Set new development version."
git push origin master
```
+185 -123
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Heroic Labs
* Copyright 2021 Heroic Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,22 +14,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.1'
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'com.google.protobuf' version '0.8.12'
//for distTar which is called when importing this SDK w/ JitPack
id 'distribution'
id 'eclipse'
id 'maven-publish'
id 'idea'
id 'java'
id 'java-library'
}
group = 'com.github.heroiclabs'
version = '2.1.1'
def description = 'Android optimized Java client for Nakama server.'
sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
// where to pull dependencies from
maven {
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
mavenLocal()
mavenCentral()
}
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'
}
+45
View File
@@ -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
+84
View File
@@ -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}"
}
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,42 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.testandroid;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.androidnakama", appContext.getPackageName());
}
}
@@ -0,0 +1,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>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">nakama-java-test-android</string>
</resources>
@@ -0,0 +1,10 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
@@ -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
+172
View File
@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
+84
View File
@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+2
View File
@@ -0,0 +1,2 @@
include ':app'
rootProject.name = "nakama-java-test-android"
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
*/
plugins {
id 'application'
id 'java'
}
repositories {
maven {
url 'https://jitpack.io'
}
mavenCentral() // resolve Guava
}
dependencies {
implementation 'com.github.heroiclabs.nakama-java:nakama-java: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
+185
View File
@@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
+89
View File
@@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+9
View File
@@ -0,0 +1,9 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/6.6/userguide/multi_project_builds.html
*/
@@ -0,0 +1,56 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.concurrent.*;
// fat jar
// import nakama.com.google.common.util.concurrent.*;
import com.google.common.util.concurrent.*;
import com.heroiclabs.nakama.*;
public class Main {
public static void main(String[] args) {
DefaultClient client = new DefaultClient("defaultkey", "127.0.0.1", 7349, false);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
String email = "[email protected]";
String password = "batsignal";
Futures.addCallback(client.authenticateEmail(email, password), new FutureCallback<Session>() {
@Override
public void onSuccess(final Session result) {
System.out.println("got session: " + result.getAuthToken());
executor.shutdown();
}
@Override
public void onFailure(final Throwable throwable) {
System.out.println(throwable.getMessage());
executor.shutdown();
}
}, executor);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
}
+125
View File
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2020 The Nakama Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.heroiclabs</groupId>
<artifactId>nakama-java-test-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<name>nakama-java-test-maven</name>
<url>https://github.com/heroiclabs/nakama-java</url>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.heroiclabs.nakama-java</groupId>
<artifactId>nakama-java</artifactId>
<version>dde7330adfa1867881dc6c6c6e27c1176512c916</version>
<type>jar</type>
</dependency>
<!-- fat jar
<dependency>
<groupId>com.github.heroiclabs.nakama-java</groupId>
<artifactId>nakama-java-all</artifactId>
<version>dde7330adfa1867881dc6c6c6e27c1176512c916</version>
<type>jar</type>
</dependency> -->
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>Main</mainClass>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -0,0 +1,55 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.concurrent.*;
import com.google.common.util.concurrent.*;
// fat jar
// import nakama.com.google.common.util.concurrent.*;
import com.heroiclabs.nakama.*;
public class Main {
public static void main(String[] args) {
DefaultClient client = new DefaultClient("defaultkey", "127.0.0.1", 7349, false);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
String email = "[email protected]";
String password = "batsignal";
Futures.addCallback(client.authenticateEmail(email, password), new FutureCallback<Session>() {
@Override
public void onSuccess(final Session result) {
System.out.println("got session: " + result.getAuthToken());
executor.shutdown();
}
@Override
public void onFailure(final Throwable throwable) {
System.out.println(throwable.getMessage());
executor.shutdown();
}
}, executor);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
}
}
@@ -0,0 +1,36 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.heroiclabs.nakama.*;
/**
* Unit test for simple App.
*/
public class AppTest
{
/**
* Rigorous Test :-)
*/
@Test
public void shouldAnswerWithTrue()
{
assertTrue( true );
}
}
-3
View File
@@ -1,3 +0,0 @@
# Bintray credentials
bintrayUser=
bintrayKey=
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+183
View File
@@ -0,0 +1,183 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
Vendored
+100
View File
@@ -0,0 +1,100 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Submodule server deleted from 15dc7ba786.
@@ -0,0 +1,102 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import com.heroiclabs.nakama.api.ChannelMessage;
import com.heroiclabs.nakama.api.NotificationList;
/**
* A listener for receiving {@code Client} events.
*/
public abstract class AbstractSocketListener implements SocketListener {
/**
* Called when the client socket disconnects.
*
* Throwable t is set if an error caused the disconnect.
*/
@Override public void onDisconnect(final Throwable t) {}
/**
* Called when the client receives an error.
*
* @param error The {@code Error} received.
*/
@Override public void onError(final Error error) {}
/**
* Called when a new topic message has been received.
*
* @param message The {@code ChannelMessage} received.
*/
@Override public void onChannelMessage(final ChannelMessage message) {}
/**
* Called when a new topic presence update has been received.
*
* @param presence The {@code ChannelPresenceEvent} received.
*/
@Override public void onChannelPresence(final ChannelPresenceEvent presence) {}
/**
* Called when a matchmaking has found a match.
*
* @param matched The {@code MatchmakerMatched} received.
*/
@Override public void onMatchmakerMatched(final MatchmakerMatched matched) {}
/**
* Called when a new match data is received.
*
* @param matchData The {@code MatchData} received.
*/
@Override public void onMatchData(final MatchData matchData) {}
/**
* Called when a new match presence update is received.
*
* @param matchPresence The {@code MatchPresenceEvent} received.
*/
@Override public void onMatchPresence(final MatchPresenceEvent matchPresence) {}
/**
* Called when the client receives new notifications.
*
* @param notifications The list of {@code Notification} received.
*/
@Override public void onNotifications(final NotificationList notifications) {}
/**
* Called when the client receives status presence updates.
*
* @param presence Updated {@code StatusPresenceEvent} presence.
*/
@Override public void onStatusPresence(final StatusPresenceEvent presence) {}
/**
* Called when the client receives stream presence updates.
*
* @param presence Updated {@code StreamPresenceEvent} presence.
*/
@Override public void onStreamPresence(final StreamPresenceEvent presence) {}
/**
* Called when the client receives stream data.
*
* @param data Stream {@code StreamData} data received.
*/
@Override public void onStreamData(final StreamData data) {}
}
@@ -1,91 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.NonNull;
public interface AuthenticateMessage extends CollatedMessage<Session> {
@AllArgsConstructor(access = AccessLevel.PRIVATE)
class Builder {
public static AuthenticateMessage custom(final @NonNull String id) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setCustom(id);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage device(final @NonNull String id) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setDevice(id);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage email(final @NonNull String email, final @NonNull String password) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setEmail(com.heroiclabs.nakama.Api.AuthenticateRequest.Email.newBuilder()
.setEmail(email)
.setPassword(password)
.build());
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage facebook(final @NonNull String oauthToken) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setFacebook(oauthToken);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage gameCenter(final @NonNull String playerId, final @NonNull String bundleId,
final long timestamp, final @NonNull String salt,
final @NonNull String signature, final @NonNull String publicKeyUrl) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setGameCenter(com.heroiclabs.nakama.Api.AuthenticateRequest.GameCenter.newBuilder()
.setPlayerId(playerId)
.setBundleId(bundleId)
.setTimestamp(timestamp)
.setSalt(salt)
.setSignature(signature)
.setPublicKeyUrl(publicKeyUrl)
.build());
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage google(final @NonNull String oauthToken) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setGoogle(oauthToken);
return new DefaultAuthenticateMessage(payload);
}
public static AuthenticateMessage steam(final @NonNull String sessionToken) {
final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload =
com.heroiclabs.nakama.Api.AuthenticateRequest.newBuilder()
.setSteam(sessionToken);
return new DefaultAuthenticateMessage(payload);
}
}
}
@@ -0,0 +1,66 @@
/*
* Copyright 2020 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.*;
import java.util.List;
@Getter
@EqualsAndHashCode
@ToString
@NoArgsConstructor(access = AccessLevel.PACKAGE)
/**
* A chat channel on the server.
*/
public class Channel {
/**
* The server-assigned channel ID.
*/
private String id;
/**
* The presences visible on the chat channel.
*/
private List<UserPresence> presences;
/**
* The presence of the current user. i.e. Your self.
*/
private UserPresence self;
/**
* The name of the chat room, or an empty string if this message was not sent through a chat room.
*/
private String roomName;
/**
* The ID of the group, or an empty string if this message was not sent through a group channel.
*/
private String groupId;
/**
* The ID of the first DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdOne;
/**
* The ID of the second DM user, or an empty string if this message was not sent through a DM chat.
*/
private String userIdTwo;
}
@@ -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;
}
File diff suppressed because it is too large. Load diff
@@ -1,34 +0,0 @@
/*
* Copyright 2017 The Nakama Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.heroiclabs.nakama;
import lombok.AccessLevel;
import lombok.Data;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
class DefaultAuthenticateMessage implements AuthenticateMessage {
private final com.heroiclabs.nakama.Api.AuthenticateRequest.Builder payload;
public byte[] asBytes(final @NonNull String collationId) {
return payload.clone().setCollationId(collationId).build().toByteArray();
}
}
File diff suppressed because it is too large. Load diff
@@ -1,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();
}
}
+23 -42
View File
@@ -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,10 +28,17 @@ 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.
*/
@@ -46,19 +49,10 @@ public abstract class Error extends Exception {
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;
@@ -73,30 +67,12 @@ public abstract class Error extends Exception {
case 3:
return BAD_INPUT;
case 4:
return AUTH_ERROR;
case 5:
return USER_NOT_FOUND;
case 6:
return USER_REGISTER_INUSE;
case 7:
return USER_LINK_INUSE;
case 8:
return USER_LINK_PROVIDER_UNAVAILABLE;
case 9:
return USER_UNLINK_DISALLOWED;
case 10:
return USER_HANDLE_INUSE;
case 11:
return GROUP_NAME_INUSE;
case 12:
return GROUP_LAST_ADMIN;
case 13:
return STORAGE_REJECTED;
case 14:
return MATCH_NOT_FOUND;
case 15:
case 5:
return MATCH_JOIN_REJECTED;
case 6:
return RUNTIME_FUNCTION_NOT_FOUND;
case 16:
case 7:
return RUNTIME_FUNCTION_EXCEPTION;
default:
return UNKNOWN;
@@ -108,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 {
public 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;
}
Loaded 100 of 169 files, more files were not shown because too many files have changed in this diff. Show more