This Runtime extends Java Runtime, adding functionality for Game Server to communicate with Controller Service.
- Override GameServerController class
public class YourServerController extends GameServerController
{
public YourServerController(String socket)
{
super(socket);
}
@Override
protected String getStatus()
{
return "ok";
}
}
See this for getStatus()
method reference.
- Instantiate it in your Game Server instance
ServerController = new YourServerController(sockets);
- Once you Game Server instance initialized, call Initialized Request:
ServerController.inited(settings, new GameServerController.InitedHandler()
{
@Override
public void result(boolean success)
{
if (!success)
{
System.exit(-1);
}
}
});
- Once a Player connected, call
ServerController.joined
and one a Player left, callServerController.left
.
On Linux and Mac OS X, you would need to install ZeroMQ library to your system for the whole package to work.
Linux (Debian stretch):
apt install -y libzmq5-dev
Mac Os X:
brew install zmq
- Add the JitPack repository to your
build.gradle
file
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
- Add the dependency:
dependencies {
compile 'com.github.anthill-platform:anthill-runtime-java-server:0.1.8'
}
- Add the JitPack repository to your
pom.xml
file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
- Add the dependency:
<dependency>
<groupId>com.github.anthill-platform</groupId>
<artifactId>anthill-runtime-java-server</artifactId>
<version>0.1.8</version>
</dependency>