Class ReturnWrapperImpl
- java.lang.Object
-
- org.opentrafficsim.sim0mq.publisher.ReturnWrapperImpl
-
- All Implemented Interfaces:
ReturnWrapper
public class ReturnWrapperImpl extends Object implements ReturnWrapper
Container for all data needed to reply (once, or multiple times) to a Sim0MQ request.Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Constructor Summary
Constructors Constructor Description ReturnWrapperImpl(org.zeromq.ZContext zContext, Object[] decodedReceivedMessage, Map<Long,org.zeromq.ZMQ.Socket> socketMap)Construct a new ReturnWrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencodeReplyAndTransmit(Boolean ackNack, Object[] payload)Encode a String reply and transmit it while patching the message type id field by adding a vertical bar and a suffix.booleanequals(Object obj)inthashCode()voidsendToMaster(byte[] data)Central portal to send a message to the master.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opentrafficsim.sim0mq.publisher.ReturnWrapper
ack, encodeReplyAndTransmit, encodeReplyAndTransmit, encodeReplyAndTransmit, nack
-
-
-
-
Constructor Detail
-
ReturnWrapperImpl
public ReturnWrapperImpl(org.zeromq.ZContext zContext, Object[] decodedReceivedMessage, Map<Long,org.zeromq.ZMQ.Socket> socketMap)Construct a new ReturnWrapper.- Parameters:
zContext- ZContext; the ZContext needed to create sockets for returned messagesdecodedReceivedMessage- Object[]; decoded Sim0MQ messagesocketMap- Map<Long, Socket>; cache of created sockets for returned messages
-
-
Method Detail
-
sendToMaster
public void sendToMaster(byte[] data)
Central portal to send a message to the master.- Parameters:
data- byte[]; the data to send
-
encodeReplyAndTransmit
public void encodeReplyAndTransmit(Boolean ackNack, Object[] payload) throws Sim0MQException, SerializationException
Encode a String reply and transmit it while patching the message type id field by adding a vertical bar and a suffix.- Specified by:
encodeReplyAndTransmitin interfaceReturnWrapper- Parameters:
ackNack- Boolean; if null, the payload is transmitted as is; if true, a boolean true is prepended to the payload; if false, a boolean false is prepended to the payloadpayload- Object []; payload of the reply message- Throws:
Sim0MQException- not sure if that can happenSerializationException- when an object in payload cannot be serialized
-
-