Search in sources :

Example 1 with ClientMessageWrapper

use of com.robo4j.socket.http.units.ClientMessageWrapper in project robo4j by Robo4J.

the class ImageDecoratorUnit method onMessage.

// TODO: 12/10/17 (miro) : review header, try to simplify
@Override
public void onMessage(ImageDTO image) {
    final String imageBase64 = JsonUtil.toBase64String(image.getContent());
    final CameraMessage cameraMessage = new CameraMessage(image.getEncoding(), String.valueOf(imageNumber.incrementAndGet()), imageBase64);
    final ClientMessageWrapper resultMessage = new ClientMessageWrapper(HttpPathUtils.toPath(SystemPath.UNITS.getPath(), httpTarget), CameraMessage.class, cameraMessage);
    System.out.println(getClass().getSimpleName() + " image target: " + target + " resultMessage: " + resultMessage.getPath());
    getContext().getReference(target).sendMessage(resultMessage);
}
Also used : CameraMessage(com.robo4j.socket.http.codec.CameraMessage) ClientMessageWrapper(com.robo4j.socket.http.units.ClientMessageWrapper)

Example 2 with ClientMessageWrapper

use of com.robo4j.socket.http.units.ClientMessageWrapper in project robo4j by Robo4J.

the class CameraImageProducerDesTestUnit method createImage.

protected void createImage(int imageNumber) {
    final byte[] image = StreamUtils.inputStreamToByteArray(Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName));
    final CameraMessage cameraMessage = new CameraMessage(IMAGE_ENCODING, String.valueOf(imageNumber), JsonUtil.toBase64String(image));
    final ClientMessageWrapper resultMessage = new ClientMessageWrapper(HttpPathUtils.toPath(SystemPath.UNITS.getPath(), httpTarget), CameraMessage.class, cameraMessage);
    getContext().getReference(target).sendMessage(resultMessage);
    generatedImagesLatch.countDown();
    progress.set(false);
}
Also used : CameraMessage(com.robo4j.socket.http.codec.CameraMessage) ClientMessageWrapper(com.robo4j.socket.http.units.ClientMessageWrapper)

Aggregations

CameraMessage (com.robo4j.socket.http.codec.CameraMessage)2 ClientMessageWrapper (com.robo4j.socket.http.units.ClientMessageWrapper)2