Hybrid mode
Hybrid Mode
Introduction
Hybrid mode enables the My-Scan 5 apps to continue the barcode scanning, in case there is a short blackspot in the WiFi connection. Previously, an item would not be added in such a case, giving a risk of shrinkage.
Requirements
- Before each item scan, we check if the server can be reached. We do this by opening a socket connection to a port of the endpoint of the My-Scan 5 app. This is a very fast operation, meaning we only delay the call by a couple of milliseconds when checking the connection.
- If there is no internet connection to the backend, then the item will be added in the offline mode. This means that it will be added to the basket as a raw barcode.
- When another add or remove action is performed, we check again if the server is reachable. If so, we synchronize the queue of items that we have created, restoring the online state of the basket.
- Next to checking the internet before a new basket action, we also periodically check the internet each 15 seconds, and if there is a connection, the basket will start synchronizing as well.
- If there are interruptions, we'll display them, with the item name in the pop-up, to make it more clear what the pop-up is for. This interruption handling is customer specific, and needs to be created in each app. It is not activated by default.
- We can remove all items of an online added item in the offline mode, in this case, we'll display it with a strikethrough, as the action is not executed yet. As soon as we're online again, the item will be removed.
- The increment and decrement actions are not available in offline mode, and will fail in this case. The reason for this is that the logic of the increment and decrement actions remove all instances of an item and add them again with the correct quantity 'under the hood'. This means if you decrement your 4 bottles of Cola by 1, the basket will display the 4 bottles of Cola as removed with a strikethrough, and will add 3 raw barcodes of the Cola item. This makes no sense for the user, which is why it isn't supported at this point. The same holds for the ModifyQuantity call, if it is supported in the My-Scan 5 app.
- Offline scanned items can be removed from the basket. When this happens, the item will not be communicated to the server. (So the app will not do an Add, in order to do a Remove again later. We just remove it from the queue, to save some IO on the backend.)
- If the synchronization process is interrupted (because the WiFi is down again), the items will remain on the queue, and the new scanned item will also be added to the queue again. The synchronization process is continued when the internet has returned. This means that even though there is internet at the point of scanning an item, the item will be added as a raw barcode, because the synchronization happens before the adding of the last scanned item. We do this so that the order of the basket remains correct.
- Before finishing a basket, all items in the basket need to be synchronized, which is why the app synchronized before the EOT call is executed. If the basket cannot be synchronized, because the internet drops during the process, then the EOT call will fail, and it will have to be scanned again.
Scenarios:
Items used in scenarios:
Item | Barcode |
---|---|
Beer | 11111 |
Chips | 22222 |
Cola | 33333 |
Action | Online basket | Offline basket | Combined basket | Outstanding offline actions | Note |
---|---|---|---|---|---|
Connect to network | |||||
Add Beer | 1 x Beer (id: 1) | 1 x Beer | |||
Add Beer | 2 x Beer (id: 1) | 2 x Beer | |||
Add Chips | 2 x Beer 1 x Chips (id: 2) | 2 x Beer 1 x Chips | |||
Disconnect from network | |||||
Add 11111 (Beer) | 2 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 11111 (id: 3) | 2 x Beer 1 x Chips 1 x 11111 | Add 11111 | |
Add 22222 (Chips) | 2 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 11111 (id: 3) 1 x 22222 (id: 4) | 2 x Beer 1 x Chips 1 x 11111 1 x 22222 | Add 11111 Add 22222 | |
Add 33333 (Cola) | 2 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 11111 (id: 3) 1 x 22222 (id: 4) 1 x 33333 (id: 5) | 2 x Beer 1 x Chips 1 x 11111 1 x 22222 1 x 33333 | Add 11111 Add 22222 Add 33333 | |
Add 33333 (Cola) | 2 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 11111 (id: 3) 1 x 22222 (id: 4) 2 x 33333 (id: 5) | 2 x Beer 1 x Chips 1 x 11111 1 x 22222 2 x 33333 | Add 11111 Add 22222 Add 33333 Add 33333 | |
Remove Chips (id: 2) | 2 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 11111 (id: 3) 1 x 22222 (id: 4) 2 x 33333 (id: 5) | 2 x Beer 1 x Chips 1 x 11111 1 x 22222 2 x 33333 | Add 11111 Add 22222 Add 33333 Add 33333 Remove Chips (id: 2) | |
Remove 2 x 33333 (id: 5) | 2 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 11111 (id: 3) 1 x 22222 (id: 4) | 2 x Beer 1 x Chips 1 x 11111 1 x 22222 | Add 11111 Add 22222 Remove Chips (id: 2) | 1 |
Connect to network | |||||
UI -> process offline "Add 11111" | 3 x Beer (id: 1) 1 x Chips (id: 2) | 1 x 22222 (id: 4) | 3 x Beer 1 x Chips 1 x 22222 | Add 22222 Remove Chips (id: 2) | |
UI -> process offline "Add 22222" | 3 x Beer (id: 1) 2 x Chips (id: 2) | 3 x Beer 2 x Chips | Remove Chips (id: 2) | ||
UI -> process offline "Remove Chips (id: 2)" | 3 x Beer (id: 1) | 3 x Beer | 2 |