fun AgentMessage.toOutboundMessage(record: ConnectionRecord): Single<OutboundMessage>
Returns an OutboundMessage constructed from an AgentMessage and a given ConnectionRecord. The outbound message might not be constructable, based on the state of the record. In that case, an error is returned.
record
- is a ConnectionRecord to get the keys and endpoint from.
Return
Single of an OutboundMessage.
fun AgentMessage.toOutboundMessage(agent: Agent, serviceDecorator: ServiceDecorator): Single<OutboundMessage>
Returns an OutboundMessage constructed from an AgentMessage and a given ServiceDecorator. In this case, the message can always be constructed as the decorator contains all the needed data. We generate a new key pair for this message so that the receiver can send a response (it needs to be encrypted with our public/verification key).
agent
- is an Agent that will store the generated key.
serviceDecorator
- is a ServiceDecorator to get the keys and endpoint from.
Return
Single of an OutboundMessage.
fun OutboundMessageContext.toOutboundMessage(agent: Agent, connectionService: ConnectionService): Single<OutboundMessage>
Returns an OutboundMessage constructed from an OutboundMessageContext. Based on the connection context, above functions are called.
agent
- is the agent to create the OutboundMessage for.
connectionService
- for getting a connection record (if needed, based on the context).
Return
Single of an OutboundMessage.