- 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 Summary
Modifier and TypeMethodDescriptiondefault voidonAboutChanged(Whatsapp whatsapp, String oldAbout, String newAbout) Called when the companion's about changesdefault voidonAboutChanged(String oldAbout, String newAbout) Called when the companion's about changesdefault voidonAction(Whatsapp whatsapp, Action action, MessageIndexInfo messageIndexInfo) Called when the socket receives a sync from Whatsapp.default voidonAction(Action action, MessageIndexInfo messageIndexInfo) Called when the socket receives a sync from Whatsapp.default voidCalled when a phone call arrivesdefault voidCalled when a phone call arrivesdefault voidonChatMessagesSync(Whatsapp whatsapp, Chat chat, boolean last) Called when the socket receives the messages for a chat.default voidonChatMessagesSync(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.default voidonChats(Whatsapp whatsapp, Collection<Chat> chats) Called when the socket receives all the chats from WhatsappWeb's Socket.default voidonChats(Collection<Chat> chats) Called when the socket receives all the chats from WhatsappWeb's Socket.default voidonContactBlocked(Whatsapp whatsapp, Contact contact) Called when a contact is blocked or unblockeddefault voidonContactBlocked(Contact contact) Called when a contact is blocked or unblockeddefault voidonContactPresence(Whatsapp whatsapp, Chat chat, Jid jid, ContactStatus status) Called when the socket receives an update regarding the presence of a contactdefault voidonContactPresence(Chat chat, Jid jid, ContactStatus status) Called when the socket receives an update regarding the presence of a contactdefault voidonContacts(Whatsapp whatsapp, Collection<Contact> contacts) Called when the socket receives all the contacts from WhatsappWeb's Socketdefault voidonContacts(Collection<Contact> contacts) Called when the socket receives all the contacts from WhatsappWeb's Socketdefault voidonDisconnected(DisconnectReason reason) Called when the socket successfully disconnects from WhatsappWeb's Socketdefault voidonDisconnected(Whatsapp whatsapp, DisconnectReason reason) Called when the socket successfully disconnects from WhatsappWeb's Socketdefault voidonFeatures(Whatsapp whatsapp, List<String> features) Called when the socket receives new features from Whatsapp.default voidonFeatures(List<String> features) Called when the socket receives new features from Whatsapp.default voidonGroupPictureChanged(Whatsapp whatsapp, Chat group) Called when a group's picture changesdefault voidonGroupPictureChanged(Chat group) Called when a group's picture changesdefault voidonHistorySyncProgress(int percentage, boolean recent) Called when the socket receives the sync percentage for the full or recent chunk of messages.default voidonHistorySyncProgress(Whatsapp whatsapp, int percentage, boolean recent) Called when the socket receives the sync percentage for the full or recent chunk of messages.default voidonLinkedDevices(Whatsapp whatsapp, Collection<Jid> devices) Called when the list of companion devices is updateddefault voidonLinkedDevices(Collection<Jid> devices) Called when the list of companion devices is updateddefault voidonLocaleChanged(Whatsapp whatsapp, CountryLocale oldLocale, CountryLocale newLocale) Called when the companion's locale changesdefault voidonLocaleChanged(CountryLocale oldLocale, CountryLocale newLocale) Called when the companion's locale changesdefault voidCalled when the socket successfully establishes a connection and logs in into an account.default voidonLoggedIn(Whatsapp whatsapp) Called when the socket successfully establishes a connection and logs in into an account.default voidonMessageDeleted(Whatsapp whatsapp, ChatMessageInfo info, boolean everyone) Called when a message is deleteddefault voidonMessageDeleted(ChatMessageInfo info, boolean everyone) Called when a message is deleteddefault voidonMessageReply(Whatsapp whatsapp, ChatMessageInfo response, QuotedMessageInfo quoted) Called when a message answers a previous messagedefault voidonMessageReply(ChatMessageInfo response, QuotedMessageInfo quoted) Called when a message answers a previous messagedefault voidonMessageStatus(Whatsapp whatsapp, MessageInfo info) Called when the status of a message changes inside a chatdefault voidonMessageStatus(MessageInfo info) Called when the status of a message changes inside a chatdefault voidonMetadata(Whatsapp whatsapp, Map<String, String> metadata) Called when an updated list of properties is received.default voidonMetadata(Map<String, String> metadata) Called when an updated list of properties is received.default voidonNameChanged(Whatsapp whatsapp, String oldName, String newName) Called when the companion's name changesdefault voidonNameChanged(String oldName, String newName) Called when the companion's name changesdefault voidonNewContact(Whatsapp whatsapp, Contact contact) Called when the socket receives a new contactdefault voidonNewContact(Contact contact) Called when the socket receives a new contactdefault voidonNewMessage(Whatsapp whatsapp, MessageInfo info) Called when a new message is received in a chatdefault voidonNewMessage(MessageInfo info) Called when a new message is received in a chatdefault voidonNewsletters(Whatsapp whatsapp, Collection<Newsletter> newsletters) Called when the socket receives all the newsletters from WhatsappWeb's Socketdefault voidonNewsletters(Collection<Newsletter> newsletters) Called when the socket receives all the newsletters from WhatsappWeb's Socketdefault voidonNewStatus(Whatsapp whatsapp, ChatMessageInfo status) Called when the socket receives a new status from WhatsappWeb's Socketdefault voidonNewStatus(ChatMessageInfo status) Called when the socket receives a new status from WhatsappWeb's Socketdefault voidonNodeReceived(Whatsapp whatsapp, Node incoming) Called when the socket receives a node from Whatsappdefault voidonNodeReceived(Node incoming) Called when the socket receives a node from Whatsappdefault voidonNodeSent(Whatsapp whatsapp, Node outgoing) Called when the socket sends a node to Whatsappdefault voidonNodeSent(Node outgoing) Called when the socket sends a node to Whatsappdefault voidonPrivacySettingChanged(Whatsapp whatsapp, PrivacySettingEntry oldPrivacyEntry, PrivacySettingEntry newPrivacyEntry) Called when a privacy setting is modifieddefault voidonPrivacySettingChanged(PrivacySettingEntry oldPrivacyEntry, PrivacySettingEntry newPrivacyEntry) Called when a privacy setting is modifieddefault voidonProfilePictureChanged(Whatsapp whatsapp, Contact contact) Called when a contact's profile picture changesdefault voidonProfilePictureChanged(Whatsapp whatsapp, URI oldPicture, URI newPicture) Called when the companion's picture changesdefault voidonProfilePictureChanged(Contact contact) Called when a contact's profile picture changesdefault voidonProfilePictureChanged(URI oldPicture, URI newPicture) Called when the companion's picture changesdefault voidonRegistrationCode(long code) Called when an OTP is requested from a new device Only works on the mobile APIdefault voidonRegistrationCode(Whatsapp whatsapp, long code) Called when an OTP is requested from a new device Only works on the mobile APIdefault voidCalled when the socket receives a setting change from Whatsapp.default voidCalled when the socket receives a setting change from Whatsapp.default voidonSocketEvent(SocketEvent event) Called when an event regarding the underlying is fireddefault voidonSocketEvent(Whatsapp whatsapp, SocketEvent event) Called when an event regarding the underlying is fireddefault voidonStatus(Whatsapp whatsapp, Collection<ChatMessageInfo> status) Called when the socket receives all the status updated from WhatsappWeb's Socket.default voidonStatus(Collection<ChatMessageInfo> status) Called when the socket receives all the status updated from WhatsappWeb's Socket.
-
Method Details
-
onNodeSent
Called when the socket sends a node to Whatsapp- Parameters:
whatsapp- an instance to the calling apioutgoing- the non-null node that was just sent
-
onNodeSent
Called when the socket sends a node to Whatsapp- Parameters:
outgoing- the non-null node that was just sent
-
onNodeReceived
Called when the socket receives a node from Whatsapp- Parameters:
whatsapp- an instance to the calling apiincoming- the non-null node that was just received
-
onNodeReceived
Called when the socket receives a node from Whatsapp- Parameters:
incoming- the non-null node that was just received
-
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(Whatsapp, Collection)()} andonContacts(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)andonContacts(Collection)should be used. -
onMetadata
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 apimetadata- the updated list of properties
-
onMetadata
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
Called when the socket successfully disconnects from WhatsappWeb's Socket- Parameters:
whatsapp- an instance to the calling apireason- the errorReason why the session was disconnected
-
onDisconnected
Called when the socket successfully disconnects from WhatsappWeb's Socket- Parameters:
reason- the errorReason why the session was disconnected
-
onAction
Called when the socket receives a sync from Whatsapp.- Parameters:
whatsapp- an instance to the calling apiaction- the sync that was executedmessageIndexInfo- the data about this action
-
onAction
Called when the socket receives a sync from Whatsapp.- Parameters:
action- the sync that was executedmessageIndexInfo- the data about this action
-
onSetting
Called when the socket receives a setting change from Whatsapp.- Parameters:
whatsapp- an instance to the calling apisetting- the setting that was toggled
-
onSetting
Called when the socket receives a setting change from Whatsapp.- Parameters:
setting- the setting that was toggled
-
onFeatures
Called when the socket receives new features from Whatsapp.- Parameters:
whatsapp- an instance to the calling apifeatures- the non-null features that were sent
-
onFeatures
Called when the socket receives new features from Whatsapp.- Parameters:
features- the non-null features that were sent
-
onContacts
Called when the socket receives all the contacts from WhatsappWeb's Socket- Parameters:
whatsapp- an instance to the calling apicontacts- the contacts
-
onContacts
Called when the socket receives all the contacts from WhatsappWeb's Socket- Parameters:
contacts- the contacts
-
onContactPresence
Called when the socket receives an update regarding the presence of a contact- Parameters:
whatsapp- an instance to the calling apichat- the chat that this update regardsjid- the contact that this update regardsstatus- the new status of the contact
-
onContactPresence
Called when the socket receives an update regarding the presence of a contact- Parameters:
chat- the chat that this update regardsjid- the contact that this update regardsstatus- the new status of the contact
-
onChats
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 toonChatMessagesSync(Chat, boolean). Particularly old chats may come later throughonChatMessagesSync(Chat, boolean)- Parameters:
whatsapp- an instance to the calling apichats- the chats
-
onChats
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 useStore.chats(). If you also need the messages to be loaded, please refer toonChatMessagesSync(Chat, boolean). Particularly old chats may come later throughonChatMessagesSync(Chat, boolean).- Parameters:
chats- the chats
-
onNewsletters
Called when the socket receives all the newsletters from WhatsappWeb's Socket- Parameters:
whatsapp- an instance to the calling apinewsletters- the newsletters
-
onNewsletters
Called when the socket receives all the newsletters from WhatsappWeb's Socket- Parameters:
newsletters- the newsletters
-
onChatMessagesSync
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 apichat- the chatlast- whether the messages in this chat are complete or there are more coming
-
onChatMessagesSync
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 chatlast- 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 nowrecent- whether the sync is about the recent messages or older messages
-
onHistorySyncProgress
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 apipercentage- the percentage synced up to nowrecent- whether the sync is about the recent messages or older messages
-
onNewMessage
Called when a new message is received in a chat- Parameters:
whatsapp- an instance to the calling apiinfo- the message that was sent
-
onNewMessage
Called when a new message is received in a chat- Parameters:
info- the message that was sent
-
onMessageDeleted
Called when a message is deleted- Parameters:
whatsapp- an instance to the calling apiinfo- the message that was deletedeveryone- whether this message was deleted by you only for yourself or whether the message was permanently removed
-
onMessageDeleted
Called when a message is deleted- Parameters:
info- the message that was deletedeveryone- whether this message was deleted by you only for yourself or whether the message was permanently removed
-
onMessageStatus
Called when the status of a message changes inside a chat- Parameters:
whatsapp- an instance to the calling apiinfo- the message whose status changed
-
onMessageStatus
Called when the status of a message changes inside a chat- Parameters:
info- the message whose status changed
-
onStatus
Called when the socket receives all the status updated from WhatsappWeb's Socket.- Parameters:
whatsapp- an instance to the calling apistatus- the status
-
onStatus
Called when the socket receives all the status updated from WhatsappWeb's Socket.- Parameters:
status- the status
-
onNewStatus
Called when the socket receives a new status from WhatsappWeb's Socket- Parameters:
whatsapp- an instance to the calling apistatus- the new status message
-
onNewStatus
Called when the socket receives a new status from WhatsappWeb's Socket- Parameters:
status- the new status message
-
onSocketEvent
Called when an event regarding the underlying is fired- Parameters:
whatsapp- an instance to the calling apievent- the event
-
onSocketEvent
Called when an event regarding the underlying is fired- Parameters:
event- the event
-
onMessageReply
Called when a message answers a previous message- Parameters:
response- the responsequoted- the quoted message
-
onMessageReply
Called when a message answers a previous message- Parameters:
whatsapp- an instance to the calling apiresponse- the responsequoted- the quoted message
-
onProfilePictureChanged
Called when a contact's profile picture changes- Parameters:
contact- the contact whose pic changed
-
onProfilePictureChanged
Called when a contact's profile picture changes- Parameters:
whatsapp- an instance to the calling apicontact- the contact whose pic changed
-
onGroupPictureChanged
Called when a group's picture changes- Parameters:
group- the group whose pic changed
-
onGroupPictureChanged
Called when a group's picture changes- Parameters:
whatsapp- an instance to the calling apigroup- the group whose pic changed
-
onNameChanged
Called when the companion's name changes- Parameters:
oldName- the non-null old namenewName- the non-null new name
-
onNameChanged
Called when the companion's name changes- Parameters:
whatsapp- an instance to the calling apioldName- the non-null old namenewName- the non-null new name
-
onAboutChanged
Called when the companion's about changes- Parameters:
oldAbout- the non-null old aboutnewAbout- the non-null new about
-
onAboutChanged
Called when the companion's about changes- Parameters:
whatsapp- an instance to the calling apioldAbout- the non-null old aboutnewAbout- the non-null new about
-
onProfilePictureChanged
Called when the companion's picture changes- Parameters:
oldPicture- the non-null old picturenewPicture- the non-null new picture
-
onProfilePictureChanged
Called when the companion's picture changes- Parameters:
whatsapp- an instance to the calling apioldPicture- the non-null old picturenewPicture- the non-null new picture
-
onLocaleChanged
Called when the companion's locale changes- Parameters:
oldLocale- the non-null old localenewLocale- the non-null new picture
-
onLocaleChanged
Called when the companion's locale changes- Parameters:
whatsapp- an instance to the calling apioldLocale- the non-null old localenewLocale- the non-null new picture
-
onContactBlocked
Called when a contact is blocked or unblocked- Parameters:
contact- the non-null contact
-
onContactBlocked
Called when a contact is blocked or unblocked- Parameters:
whatsapp- an instance to the calling apicontact- the non-null contact
-
onNewContact
Called when the socket receives a new contact- Parameters:
whatsapp- an instance to the calling apicontact- the new contact
-
onNewContact
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 apioldPrivacyEntry- the old entrynewPrivacyEntry- the new entry
-
onPrivacySettingChanged
default void onPrivacySettingChanged(PrivacySettingEntry oldPrivacyEntry, PrivacySettingEntry newPrivacyEntry) Called when a privacy setting is modified- Parameters:
oldPrivacyEntry- the old entrynewPrivacyEntry- the new entry
-
onLinkedDevices
Called when the list of companion devices is updated- Parameters:
whatsapp- an instance to the calling apidevices- the non-null devices
-
onLinkedDevices
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
Called when an OTP is requested from a new device Only works on the mobile API- Parameters:
whatsapp- an instance to the calling apicode- the registration code
-
onCall
Called when a phone call arrives- Parameters:
call- the non-null phone call
-
onCall
Called when a phone call arrives- Parameters:
whatsapp- an instance to the calling apicall- the non-null phone call
-