yisbug / whatsapp-nodejs

This is a library based on whatsapp androd latest version, you can use it build your own app.
36 stars 12 forks source link

function create_session unable to create session for multiple devices #10

Open NXSINO opened 1 year ago

NXSINO commented 1 year ago

When the recipient login on multiple devices, onContactReceipt will receive a message of type retry after sending the message, which requires us to send the message to another device. create_session is encrypted in d10.js, how to deal with multiple devices now message resend

yisbug commented 1 year ago

When the recipient login on multiple devices, onContactReceipt will receive a message of type retry after sending the message, which requires us to send the message to another device. create_session is encrypted in d10.js, how to deal with multiple devices now message resend

In the case of multiple device logins, the recipient address will be separated by : , such as 123123123.0: deviceNo@s.whatsapp.net In addition, and the message content needs to be stored each time the message is sent. There is no plan to support this situation at present. You can implement the relevant code yourself.

The function create_session in d10.js is like this:

  async create_session(address, prekeybundle, autotrust = false) {
    const session_builder = new SessionBuilder(this.store, address);
    try {
      await session_builder.processPreKey(prekeybundle);
    } catch (ex) {
      console.error('create_session error', address, ex);
      if (autotrust) this.trust_identity(ex.getName(), ex.getIdentityKey());
    }
  }