There's no built-in way to know when a specific print job has completed (with or without an error), that would be the job of a print spooler service. In a way, that looks similar (to some extent) to what you're building, so here are some suggestions:
Have you validated that ~HS will give you a response in all the scenarios you're listening on? The documentation ( https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf ) indicates that ~HS will not send back a response if the printer is in one of a number of error states (MEDIA OUT, RIBBON OUT, HEAD OPEN, REWINDER FULL, HEAD OVER-TEMPERATURE). ~HQES is an alternative command you may want to look into.
If you want to coordinate across multiple clients sending to the same server, you may want to implement spooling on your server. You can receive print jobs from the clients in a central service and add them all to a queue, so there's really only one client talking to the printer (your central service). That central service can then process print jobs from all clients in order so none of the clients can be starved.
If you don't want to have a single central service do the printing but still want to coordinate among clients, if you're already using a SQL database in your project, you can use the DB as a distributed lock. Clients would attempt to acquire a lock before printing and release it afterwards. If a client cannot acquire the lock because some other client has it, it has to wait until the lock is free, so there's again only one client talking to the printer at any given time.
Another alternative could be to, instead of sending multiple print jobs, build a single print job that consists of multiple pages and doing everything in one go.
Will any of those help with your use case?
Technical Architect, Kutir Mobility
Posted on behalf of Zebra Technologies