watson / ipp-printer

An IPP printer written in Node.js
MIT License
548 stars 81 forks source link

Multiple Printers using the same server #23

Open fantapop opened 6 years ago

fantapop commented 6 years ago

I'm trying to wrap my head around how instantiating multiple printers works. It looks like the functionality is close to existing since you can pass a pre-existing server into the Printer object. The problem is that onrequest is called on the server for every printer which is instantiated https://github.com/watson/ipp-printer/blob/f8c0969fe4b9381c5a11f8a03e20baeb8861e30e/lib/bind.js#L19 so if I instantiate two printers with a pre-existing server and then send a print job to one of them the onrequest handler gets called twice and then it blows up because it is mutating the req._body field during each call https://github.com/watson/ipp-printer/blob/f8c0969fe4b9381c5a11f8a03e20baeb8861e30e/lib/bind.js#L49. Was this not intended to allow multiple printer objects?