sendSubmitVPLaterResponseMessage function

Future<void> sendSubmitVPLaterResponseMessage(
  1. String mnemonic,
  2. String did,
  3. InfraDIDCommAgent agent,
  4. SubmitVPLaterMessage submitVPLaterMessage,
  5. String vpLaterCallbackEndpoint,
)

Implementation

Future<void> sendSubmitVPLaterResponseMessage(
  String mnemonic,
  String did,
  InfraDIDCommAgent agent,
  SubmitVPLaterMessage submitVPLaterMessage,
  String vpLaterCallbackEndpoint,
) async {
  int currentTime = DateTime.now().millisecondsSinceEpoch ~/ 1000;
  var uuid = Uuid();
  var id = uuid.v4();
  SubmitVPLaterResponseMessage submitVPLaterResponseMessage =
      SubmitVPLaterResponseMessage(
    id: id,
    from: did,
    to: [submitVPLaterMessage.from],
    createdTime: currentTime,
    expiresTime: currentTime + 30000,
    ack: [submitVPLaterMessage.id],
    callbackUrl: vpLaterCallbackEndpoint,
  );

  String? receiverSocketId = agent.peerInfo["socketId"];
  String receiverDID = submitVPLaterMessage.from;

  String jwe = await makeJWEFromMessage(
    mnemonic,
    receiverDID,
    agent,
    submitVPLaterResponseMessage.toJson(),
  );

  agent.socket.emit("message", {"to": receiverSocketId, "m": jwe});
  print("SubmitVPLaterResponseMessage sent to $receiverSocketId");
}