Skip to content

Commit

Permalink
Added explanation for use of custom class arrays. Bumped to version 1…
Browse files Browse the repository at this point in the history
….5.5.
  • Loading branch information
marcluque committed Apr 14, 2018
1 parent 04ddbc6 commit d64c2d9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ like a [simple chat application](https://github.com/DataSecs/Hydra/wiki/Building
<dependency>
<groupId>de.datasecs</groupId>
<artifactId>hydra-all</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hydra</artifactId>
<groupId>de.datasecs</groupId>
<version>1.5.4</version>
<version>1.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -16,14 +16,14 @@
<dependency>
<groupId>de.datasecs</groupId>
<artifactId>hydra-client</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
</dependency>

<!-- Hydra server -->
<dependency>
<groupId>de.datasecs</groupId>
<artifactId>hydra-server</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hydra</artifactId>
<groupId>de.datasecs</groupId>
<version>1.5.4</version>
<version>1.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>de.datasecs</groupId>
<artifactId>hydra-shared</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hydra</artifactId>
<groupId>de.datasecs</groupId>
<version>1.5.4</version>
<version>1.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>de.datasecs</groupId>
<artifactId>hydra-all</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onDisconnected(Session session) {
testStringList.add("Test");

CustomClassExtended customClassExtended = new CustomClassExtended("testStringExtended", UUID.randomUUID(), 5L, Integer.class);
CustomClass customClass = new CustomClass("testString", 1, new String[]{"Hydra", "de/datasecs/hydra/example/client/serialization"}, testStringList, "this is a random object", customClassExtended);
CustomClass customClass = new CustomClass("testString", 1, new String[]{"Hydra", "serialization"}, testStringList, "this is a random object", customClassExtended);

// Sends the instance of a custom class, that is create and filled with data above
session.send(new ExampleSerializationPacket(customClass));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import de.datasecs.hydra.shared.protocol.packets.Packet;
import de.datasecs.hydra.shared.protocol.packets.PacketId;

import java.util.Arrays;

/**
* Created with love by DataSecs on 12.02.18
*/
Expand All @@ -11,6 +13,8 @@ public class ExampleSerializationPacket extends Packet {

private CustomClass customClass;

private CustomClass[] customClasses;

public ExampleSerializationPacket() {}

public ExampleSerializationPacket(CustomClass customClass) {
Expand All @@ -20,6 +24,7 @@ public ExampleSerializationPacket(CustomClass customClass) {
@Override
public void read() {
customClass = readCustomObject();
customClasses = readCustomClassArray();
}

@Override
Expand All @@ -30,15 +35,18 @@ public void write() {
* be serialized are inside. Therefore it's necessary to put all related classes that are supposed to be serialized
* together in a package. This is the only (big) drawback.
*/
//writeCustomObject(customClass, "de.datasecs.hydra.example.shared.serialization");
writeCustomObject(customClass, "de.datasecs.hydra.example.shared.serialization");

// This method allows the user to send an array of custom classes. This method also needs the 'pathOfCustomClassAtReceiver'
writeCustomClassArray(new CustomClass[]{customClass, customClass}, "de.datasecs.hydra.example.shared.serialization");
}

// Auto-generated toString method by IntelliJ for example purposes
@Override
public String toString() {
return "ExampleSerializationPacket{" +
"customClass=" + customClass +
"customClasses=" + Arrays.toString(customClasses) +
'}';
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>de.datasecs</groupId>
<artifactId>hydra</artifactId>
<packaging>pom</packaging>
<version>1.5.4</version>
<version>1.5.5</version>

<modules>
<module>all</module>
Expand Down
4 changes: 2 additions & 2 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hydra</artifactId>
<groupId>de.datasecs</groupId>
<version>1.5.4</version>
<version>1.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>de.datasecs</groupId>
<artifactId>hydra-shared</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>hydra</artifactId>
<groupId>de.datasecs</groupId>
<version>1.5.4</version>
<version>1.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit d64c2d9

Please sign in to comment.