libArcus is a lightweight, easy to use library to send and receive messages between two programs based on the Protocol Buffers library by Google. It was originally developed by Ultimaker and is primarily used to communicate with their CuraEngine. This is a port of the original library to the programming language Java. The API is almost identical to make working with both libraries more easy.
// Create a new instanceArcusSocketsocket = newArcusSocket();
// Add a listenersocket.addListener(...);
// Register a message typesocket.registerMessageType(MyType.getDefaultInstanceForType());
// Start listening on the specified portsocket.listen(...);
// Send a messagesocket.sendMessage(...);
// Retrieve a received messageMessagemessage = socket.takeNextMessage();
// Check of message typeif (message != null && messageinstanceofMyType) {
doStuff((MyType) message);
}
// Close the connectionsocket.close();libArcus-Java has been published on Maven Central and you can add it to your pom.xml as a dependency.
<dependency>
<groupId>de.ocarthon</groupId>
<artifactId>libArcus</artifactId>
<version>1.0.2</version>
</dependency>More detailed information on how the library works and how to use it can be found in the Documentation