Interface Listener

All Known Subinterfaces:
OnAction, OnCall, OnChatMessagesSync, OnChats, OnContactBlocked, OnContactPictureChanged, OnContactPresence, OnContacts, OnDisconnected, OnFeatures, OnGroupPictureChange, OnHistorySyncProgress, OnLinkedDevices, OnLoggedIn, OnMessageDeleted, OnMessageReply, OnMessageStatus, OnMetadata, OnNewContact, OnNewMessage, OnNewsletters, OnNewStatus, OnNodeReceived, OnNodeSent, OnPrivacySettingChanged, OnProfilePictureChanged, OnRegistrationCode, OnSetting, OnSocketEvent, OnStatus, OnUserAboutChanged, OnUserLocaleChanged, OnUserNameChanged, OnWhatsappAboutChanged, OnWhatsappAction, OnWhatsappCall, OnWhatsappChatMessagesSync, OnWhatsappChats, OnWhatsappContactBlocked, OnWhatsappContactPictureChanged, OnWhatsappContactPresence, OnWhatsappContacts, OnWhatsappDisconnected, OnWhatsappFeatures, OnWhatsappGroupPictureChange, OnWhatsappHistorySyncProgress, OnWhatsappLinkedDevices, OnWhatsappLocaleChanged, OnWhatsappLoggedIn, OnWhatsappMediaStatus, OnWhatsappMessageDeleted, OnWhatsappMessageReply, OnWhatsappMessageStatus, OnWhatsappMetadata, OnWhatsappNameChanged, OnWhatsappNewMessage, OnWhatsappNewsletters, OnWhatsappNewStatus, OnWhatsappNodeReceived, OnWhatsappNodeSent, OnWhatsappPrivacySettingChanged, OnWhatsappProfilePictureChanged, OnWhatsappRegistrationCode, OnWhatsappSetting, OnWhatsappSocketEvent

public interface Listener
This interface can be used to listen for events fired when new information is sent by WhatsappWeb's socket. A listener can be registered manually using Whatsapp.addListener(Listener). Otherwise, it can be registered by annotating it with the RegisterListener annotation. To disable the latter, check out Store.autodetectListeners().
  • Method Details

    • onNodeSent

      default void onNodeSent(Whatsapp whatsapp, Node outgoing)
      Called when the socket sends a node to Whatsapp
      Parameters:
      whatsapp - an instance to the calling api
      outgoing - the non-null node that was just sent
    • onNodeSent

      default void onNodeSent(Node outgoing)
      Called when the socket sends a node to Whatsapp
      Parameters:
      outgoing - the non-null node that was just sent
    • onNodeReceived

      default void onNodeReceived(Whatsapp whatsapp, Node incoming)
      Called when the socket receives a node from Whatsapp
      Parameters:
      whatsapp - an instance to the calling api
      incoming - the non-null node that was just received
    • onNodeReceived

      default void onNodeReceived(Node incoming)
      Called when the socket receives a node from Whatsapp
      Parameters:
      incoming - the non-null node that was just received
    • onLoggedIn

      default void onLoggedIn(Whatsapp whatsapp)
      Called when the socket successfully establishes a connection and logs in into an account. When this event is called, any data, including chats and contact, is not guaranteed to be already in memory. Instead, onChats(Whatsapp, Collection) ()} and onContacts(Whatsapp, Collection) ()} should be used.
      Parameters:
      whatsapp - an instance to the calling api
    • onLoggedIn

      default void onLoggedIn()
      Called when the socket successfully establishes a connection and logs in into an account. When this event is called, any data, including chats and contact, is not guaranteed to be already in memory. Instead, onChats(Collection) and onContacts(Collection) should be used.
    • onMetadata

      default void onMetadata(Whatsapp whatsapp, Map<String,String> metadata)
      Called when an updated list of properties is received. This method is called both when a connection is established with WhatsappWeb and when new props are available. In the latter case though, this object should be considered as partial and is guaranteed to contain only updated entries.
      Parameters:
      whatsapp - an instance to the calling api
      metadata - the updated list of properties
    • onMetadata

      default void onMetadata(Map<String,String> metadata)
      Called when an updated list of properties is received. This method is called both when a connection is established with WhatsappWeb and when new props are available. In the latter case though, this object should be considered as partial and is guaranteed to contain only updated entries.
      Parameters:
      metadata - the updated list of properties
    • onDisconnected

      default void onDisconnected(Whatsapp whatsapp, DisconnectReason reason)
      Called when the socket successfully disconnects from WhatsappWeb's Socket
      Parameters:
      whatsapp - an instance to the calling api
      reason - the errorReason why the session was disconnected
    • onDisconnected

      default void onDisconnected(DisconnectReason reason)
      Called when the socket successfully disconnects from WhatsappWeb's Socket
      Parameters:
      reason - the errorReason why the session was disconnected
    • onAction

      default void onAction(Whatsapp whatsapp, Action action, MessageIndexInfo messageIndexInfo)
      Called when the socket receives a sync from Whatsapp.
      Parameters:
      whatsapp - an instance to the calling api
      action - the sync that was executed
      messageIndexInfo - the data about this action
    • onAction

      default void onAction(Action action, MessageIndexInfo messageIndexInfo)
      Called when the socket receives a sync from Whatsapp.
      Parameters:
      action - the sync that was executed
      messageIndexInfo - the data about this action
    • onSetting

      default void onSetting(Whatsapp whatsapp, Setting setting)
      Called when the socket receives a setting change from Whatsapp.
      Parameters:
      whatsapp - an instance to the calling api
      setting - the setting that was toggled
    • onSetting

      default void onSetting(Setting setting)
      Called when the socket receives a setting change from Whatsapp.
      Parameters:
      setting - the setting that was toggled
    • onFeatures

      default void onFeatures(Whatsapp whatsapp, List<String> features)
      Called when the socket receives new features from Whatsapp.
      Parameters:
      whatsapp - an instance to the calling api
      features - the non-null features that were sent
    • onFeatures

      default void onFeatures(List<String> features)
      Called when the socket receives new features from Whatsapp.
      Parameters:
      features - the non-null features that were sent
    • onContacts

      default void onContacts(Whatsapp whatsapp, Collection<Contact> contacts)
      Called when the socket receives all the contacts from WhatsappWeb's Socket
      Parameters:
      whatsapp - an instance to the calling api
      contacts - the contacts
    • onContacts

      default void onContacts(Collection<Contact> contacts)
      Called when the socket receives all the contacts from WhatsappWeb's Socket
      Parameters:
      contacts - the contacts
    • onContactPresence

      default void onContactPresence(Whatsapp whatsapp, Chat chat, Jid jid, ContactStatus status)
      Called when the socket receives an update regarding the presence of a contact
      Parameters:
      whatsapp - an instance to the calling api
      chat - the chat that this update regards
      jid - the contact that this update regards
      status - the new status of the contact
    • onContactPresence

      default void onContactPresence(Chat chat, Jid jid, ContactStatus status)
      Called when the socket receives an update regarding the presence of a contact
      Parameters:
      chat - the chat that this update regards
      jid - the contact that this update regards
      status - the new status of the contact
    • onChats

      default void onChats(Whatsapp whatsapp, Collection<Chat> chats)
      Called when the socket receives all the chats from WhatsappWeb's Socket. When this event is fired, it is guaranteed that all metadata excluding messages will be present. If you also need the messages to be loaded, please refer to onChatMessagesSync(Chat, boolean). Particularly old chats may come later through onChatMessagesSync(Chat, boolean)
      Parameters:
      whatsapp - an instance to the calling api
      chats - the chats
    • onChats

      default void onChats(Collection<Chat> chats)
      Called when the socket receives all the chats from WhatsappWeb's Socket. When this event is fired, it is guaranteed that all metadata excluding messages will be present. To access this data use Store.chats(). If you also need the messages to be loaded, please refer to onChatMessagesSync(Chat, boolean). Particularly old chats may come later through onChatMessagesSync(Chat, boolean).
      Parameters:
      chats - the chats
    • onNewsletters

      default void onNewsletters(Whatsapp whatsapp, Collection<Newsletter> newsletters)
      Called when the socket receives all the newsletters from WhatsappWeb's Socket
      Parameters:
      whatsapp - an instance to the calling api
      newsletters - the newsletters
    • onNewsletters

      default void onNewsletters(Collection<Newsletter> newsletters)
      Called when the socket receives all the newsletters from WhatsappWeb's Socket
      Parameters:
      newsletters - the newsletters
    • onChatMessagesSync

      default void onChatMessagesSync(Whatsapp whatsapp, Chat chat, boolean last)
      Called when the socket receives the messages for a chat. This method is only called when the QR is first scanned and history is being synced. From all subsequent runs, the messages will already in the chat on startup.
      Parameters:
      whatsapp - an instance to the calling api
      chat - the chat
      last - whether the messages in this chat are complete or there are more coming
    • onChatMessagesSync

      default void onChatMessagesSync(Chat chat, boolean last)
      Called when the socket receives the message for a chat This method is only called when the QR is first scanned and history is being synced. From all subsequent runs, the messages will already in the chat on startup.
      Parameters:
      chat - the chat
      last - whether the messages in this chat are complete or there are more coming
    • onHistorySyncProgress

      default void onHistorySyncProgress(int percentage, boolean recent)
      Called when the socket receives the sync percentage for the full or recent chunk of messages. This method is only called when the QR is first scanned and history is being synced.
      Parameters:
      percentage - the percentage synced up to now
      recent - whether the sync is about the recent messages or older messages
    • onHistorySyncProgress

      default void onHistorySyncProgress(Whatsapp whatsapp, int percentage, boolean recent)
      Called when the socket receives the sync percentage for the full or recent chunk of messages. This method is only called when the QR is first scanned and history is being synced.
      Parameters:
      whatsapp - an instance to the calling api
      percentage - the percentage synced up to now
      recent - whether the sync is about the recent messages or older messages
    • onNewMessage

      default void onNewMessage(Whatsapp whatsapp, MessageInfo info)
      Called when a new message is received in a chat
      Parameters:
      whatsapp - an instance to the calling api
      info - the message that was sent
    • onNewMessage

      default void onNewMessage(MessageInfo info)
      Called when a new message is received in a chat
      Parameters:
      info - the message that was sent
    • onMessageDeleted

      default void onMessageDeleted(Whatsapp whatsapp, ChatMessageInfo info, boolean everyone)
      Called when a message is deleted
      Parameters:
      whatsapp - an instance to the calling api
      info - the message that was deleted
      everyone - whether this message was deleted by you only for yourself or whether the message was permanently removed
    • onMessageDeleted

      default void onMessageDeleted(ChatMessageInfo info, boolean everyone)
      Called when a message is deleted
      Parameters:
      info - the message that was deleted
      everyone - whether this message was deleted by you only for yourself or whether the message was permanently removed
    • onMessageStatus

      default void onMessageStatus(Whatsapp whatsapp, MessageInfo info)
      Called when the status of a message changes inside a chat
      Parameters:
      whatsapp - an instance to the calling api
      info - the message whose status changed
    • onMessageStatus

      default void onMessageStatus(MessageInfo info)
      Called when the status of a message changes inside a chat
      Parameters:
      info - the message whose status changed
    • onStatus

      default void onStatus(Whatsapp whatsapp, Collection<ChatMessageInfo> status)
      Called when the socket receives all the status updated from WhatsappWeb's Socket.
      Parameters:
      whatsapp - an instance to the calling api
      status - the status
    • onStatus

      default void onStatus(Collection<ChatMessageInfo> status)
      Called when the socket receives all the status updated from WhatsappWeb's Socket.
      Parameters:
      status - the status
    • onNewStatus

      default void onNewStatus(Whatsapp whatsapp, ChatMessageInfo status)
      Called when the socket receives a new status from WhatsappWeb's Socket
      Parameters:
      whatsapp - an instance to the calling api
      status - the new status message
    • onNewStatus

      default void onNewStatus(ChatMessageInfo status)
      Called when the socket receives a new status from WhatsappWeb's Socket
      Parameters:
      status - the new status message
    • onSocketEvent

      default void onSocketEvent(Whatsapp whatsapp, SocketEvent event)
      Called when an event regarding the underlying is fired
      Parameters:
      whatsapp - an instance to the calling api
      event - the event
    • onSocketEvent

      default void onSocketEvent(SocketEvent event)
      Called when an event regarding the underlying is fired
      Parameters:
      event - the event
    • onMessageReply

      default void onMessageReply(ChatMessageInfo response, QuotedMessageInfo quoted)
      Called when a message answers a previous message
      Parameters:
      response - the response
      quoted - the quoted message
    • onMessageReply

      default void onMessageReply(Whatsapp whatsapp, ChatMessageInfo response, QuotedMessageInfo quoted)
      Called when a message answers a previous message
      Parameters:
      whatsapp - an instance to the calling api
      response - the response
      quoted - the quoted message
    • onProfilePictureChanged

      default void onProfilePictureChanged(Contact contact)
      Called when a contact's profile picture changes
      Parameters:
      contact - the contact whose pic changed
    • onProfilePictureChanged

      default void onProfilePictureChanged(Whatsapp whatsapp, Contact contact)
      Called when a contact's profile picture changes
      Parameters:
      whatsapp - an instance to the calling api
      contact - the contact whose pic changed
    • onGroupPictureChanged

      default void onGroupPictureChanged(Chat group)
      Called when a group's picture changes
      Parameters:
      group - the group whose pic changed
    • onGroupPictureChanged

      default void onGroupPictureChanged(Whatsapp whatsapp, Chat group)
      Called when a group's picture changes
      Parameters:
      whatsapp - an instance to the calling api
      group - the group whose pic changed
    • onNameChanged

      default void onNameChanged(String oldName, String newName)
      Called when the companion's name changes
      Parameters:
      oldName - the non-null old name
      newName - the non-null new name
    • onNameChanged

      default void onNameChanged(Whatsapp whatsapp, String oldName, String newName)
      Called when the companion's name changes
      Parameters:
      whatsapp - an instance to the calling api
      oldName - the non-null old name
      newName - the non-null new name
    • onAboutChanged

      default void onAboutChanged(String oldAbout, String newAbout)
      Called when the companion's about changes
      Parameters:
      oldAbout - the non-null old about
      newAbout - the non-null new about
    • onAboutChanged

      default void onAboutChanged(Whatsapp whatsapp, String oldAbout, String newAbout)
      Called when the companion's about changes
      Parameters:
      whatsapp - an instance to the calling api
      oldAbout - the non-null old about
      newAbout - the non-null new about
    • onProfilePictureChanged

      default void onProfilePictureChanged(URI oldPicture, URI newPicture)
      Called when the companion's picture changes
      Parameters:
      oldPicture - the non-null old picture
      newPicture - the non-null new picture
    • onProfilePictureChanged

      default void onProfilePictureChanged(Whatsapp whatsapp, URI oldPicture, URI newPicture)
      Called when the companion's picture changes
      Parameters:
      whatsapp - an instance to the calling api
      oldPicture - the non-null old picture
      newPicture - the non-null new picture
    • onLocaleChanged

      default void onLocaleChanged(CountryLocale oldLocale, CountryLocale newLocale)
      Called when the companion's locale changes
      Parameters:
      oldLocale - the non-null old locale
      newLocale - the non-null new picture
    • onLocaleChanged

      default void onLocaleChanged(Whatsapp whatsapp, CountryLocale oldLocale, CountryLocale newLocale)
      Called when the companion's locale changes
      Parameters:
      whatsapp - an instance to the calling api
      oldLocale - the non-null old locale
      newLocale - the non-null new picture
    • onContactBlocked

      default void onContactBlocked(Contact contact)
      Called when a contact is blocked or unblocked
      Parameters:
      contact - the non-null contact
    • onContactBlocked

      default void onContactBlocked(Whatsapp whatsapp, Contact contact)
      Called when a contact is blocked or unblocked
      Parameters:
      whatsapp - an instance to the calling api
      contact - the non-null contact
    • onNewContact

      default void onNewContact(Whatsapp whatsapp, Contact contact)
      Called when the socket receives a new contact
      Parameters:
      whatsapp - an instance to the calling api
      contact - the new contact
    • onNewContact

      default void onNewContact(Contact contact)
      Called when the socket receives a new contact
      Parameters:
      contact - the new contact
    • onPrivacySettingChanged

      default void onPrivacySettingChanged(Whatsapp whatsapp, PrivacySettingEntry oldPrivacyEntry, PrivacySettingEntry newPrivacyEntry)
      Called when a privacy setting is modified
      Parameters:
      whatsapp - an instance to the calling api
      oldPrivacyEntry - the old entry
      newPrivacyEntry - the new entry
    • onPrivacySettingChanged

      default void onPrivacySettingChanged(PrivacySettingEntry oldPrivacyEntry, PrivacySettingEntry newPrivacyEntry)
      Called when a privacy setting is modified
      Parameters:
      oldPrivacyEntry - the old entry
      newPrivacyEntry - the new entry
    • onLinkedDevices

      default void onLinkedDevices(Whatsapp whatsapp, Collection<Jid> devices)
      Called when the list of companion devices is updated
      Parameters:
      whatsapp - an instance to the calling api
      devices - the non-null devices
    • onLinkedDevices

      default void onLinkedDevices(Collection<Jid> devices)
      Called when the list of companion devices is updated
      Parameters:
      devices - the non-null devices
    • onRegistrationCode

      default void onRegistrationCode(long code)
      Called when an OTP is requested from a new device Only works on the mobile API
      Parameters:
      code - the registration code
    • onRegistrationCode

      default void onRegistrationCode(Whatsapp whatsapp, long code)
      Called when an OTP is requested from a new device Only works on the mobile API
      Parameters:
      whatsapp - an instance to the calling api
      code - the registration code
    • onCall

      default void onCall(Call call)
      Called when a phone call arrives
      Parameters:
      call - the non-null phone call
    • onCall

      default void onCall(Whatsapp whatsapp, Call call)
      Called when a phone call arrives
      Parameters:
      whatsapp - an instance to the calling api
      call - the non-null phone call