Skip to content

Commit

Permalink
A few minor improvements including an update of the dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
crykn committed Mar 28, 2018
1 parent 051d7de commit d1b9b5b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 22 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This fork was specifically made for [ProjectGG](https://github.com/eskalon/Proje
* A TypeListener for easier message handling (see the example below; also fixes [#130](https://github.com/EsotericSoftware/kryonet/issues/130))
* Listener is now an interface ([#39](https://github.com/EsotericSoftware/kryonet/issues/39))
* Kryo 4.0.1 is used for the serialization ([#77](https://github.com/EsotericSoftware/kryonet/issues/77); also fixes [#123](https://github.com/EsotericSoftware/kryonet/issues/123))
* Fixes for the Android 5 and iOS crashes ([#106](https://github.com/EsotericSoftware/kryonet/issues/106))
* Includes a fix for the common Android 5 crash ([#106](https://github.com/EsotericSoftware/kryonet/issues/106))
* The LAN Host Discovery is now available to Non-Kryo-Serializations ([#127](https://github.com/EsotericSoftware/kryonet/issues/127))
* A few other changes to serializations (see the respective paragraph below)
* Kryonet now uses a [gradle](https://gradle.org/) build setup
Expand All @@ -35,8 +35,9 @@ server.addListener(typeListener);

## Changes to (Custom) Serializations

* The serialization objects are created by [factories](https://github.com/crykn/kryonet/blob/master/src/main/java/com/esotericsoftware/kryonet/serialization/SerializationFactory.java)
* The server now uses a serialization instance _per_ TCP connection (and still only one serialization instance for the UDP connections). This allows the server to keep responding while another message is serialized (see [#137](https://github.com/EsotericSoftware/kryonet/issues/137)).
* The serialization objects are now created by [factories](https://github.com/crykn/kryonet/blob/master/src/main/java/com/esotericsoftware/kryonet/serialization/SerializationFactory.java): `SerializationFactory#newInstance(Connection)`
* The in-built serializations still behave exactly the same (i.e. one serialization instance is used for the server)
* Custom serializations on the other hand can now decide to only get used _once per TCP connection_ (all UDP connections still use one instance). This allows the server to keep responding while a message for another connection is still being serialized (see [#137](https://github.com/EsotericSoftware/kryonet/issues/137)).

## Download

Expand All @@ -52,6 +53,6 @@ allprojects {
}
dependencies {
compile 'com.github.crykn:kryonet:2.22.1'
compile 'com.github.crykn:kryonet:2.22.2'
}
```
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
apply plugin: "java"

version '2.22.1'
version '2.22.2'

sourceCompatibility = 1.9
targetCompatibility = 1.9

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}

dependencies {
compile "com.esotericsoftware:jsonbeans:0.7"
compile "com.esotericsoftware:kryo:4.0.1"
compile 'com.github.esotericsoftware:jsonbeans:0.9'
compile "com.esotericsoftware:kryo:4.0.2"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@

public class JsonSerializationFactory implements SerializationFactory {

private final Serialization INSTANCE;

@Override
public Serialization newInstance(Connection connection) {
return new JsonSerialization();
return INSTANCE;
}

public JsonSerializationFactory() {
this.INSTANCE = new JsonSerialization();
}

public class JsonSerialization implements Serialization {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@
import com.esotericsoftware.kryonet.FrameworkMessage.Ping;
import com.esotericsoftware.kryonet.FrameworkMessage.RegisterTCP;
import com.esotericsoftware.kryonet.FrameworkMessage.RegisterUDP;
import com.esotericsoftware.kryonet.serialization.JsonSerializationFactory.JsonSerialization;

public class KryoSerializationFactory implements SerializationFactory {

private Kryo kryo;

private final KryoSerialization INSTANCE;

@Override
public Serialization newInstance(Connection connection) {
return INSTANCE;
}

public KryoSerializationFactory() {
this(new Kryo());

Expand All @@ -30,28 +38,19 @@ public KryoSerializationFactory(Kryo kryo) {
this.kryo.register(KeepAlive.class);
this.kryo.register(DiscoverHost.class);
this.kryo.register(Ping.class);

this.INSTANCE = new KryoSerialization(kryo);
}

public Kryo getKryo() {
return kryo;
}

@Override
public Serialization newInstance(Connection connection) {
return new KryoSerialization(connection, kryo);
}

public class KryoSerialization implements Serialization {
private final Kryo kryo;
private final ByteBufferInput input;
private final ByteBufferOutput output;

public KryoSerialization(Connection connection, Kryo kryo) {
this(kryo);

kryo.getContext().put("connection", connection);
}

public KryoSerialization(Kryo kryo) {
this.kryo = kryo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void run () {
fail = true;
}
};
timer.schedule(failTask, 11000);
timer.schedule(failTask, 13000);
while (true) {
for (Iterator iter = threads.iterator(); iter.hasNext();) {
Thread thread = (Thread)iter.next();
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/com/esotericsoftware/kryonet/rmi/RmiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public class RmiTest extends KryoNetTestCase {
* other features.
*/
public void testRMI() throws IOException {
Log.set(Log.LEVEL_DEBUG);

Server server = new Server();
Kryo serverKryo = server.getKryo();
register(serverKryo);
Expand Down

0 comments on commit d1b9b5b

Please sign in to comment.