Skip to content

Commit a84e5ed

Browse files
authored
Update README.md
1 parent c96e3ba commit a84e5ed

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ client.setPrintQRCode(true);
4343
```
4444
To learn how to receive the qr code as BufferedImage please refer to "Message handlers".
4545

46+
### Complete example
47+
```java
48+
WAClient client = new WAClient();
49+
client.setPrintQRCode(true);
50+
client.addClientActionListener(new ClientActionListener() {
51+
@Override
52+
public void onQRCodeScanRequired(BufferedImage img) {
53+
System.out.println("Authentication required! Please scan the QR code!");
54+
}
55+
});
56+
int httpCode = client.openConnection();
57+
if(httpCode == 200) {
58+
System.out.println("Logged in successfully!");
59+
System.out.println("You have " + client.loadChats().length + " chats");
60+
} else {
61+
System.out.println("Login failed! Code: " + httpCode);
62+
}
63+
```
64+
4665
## Message handlers
4766
After a WAClient instance is initialized, the `addClientActionListener` method can be called to register a `ClientActionInterface` and receive a number of callbacks. `ClientActionListener` is an empty implementation of `ClientActionInterface` interface.
4867

0 commit comments

Comments
 (0)