Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for shutting down server and bonjour service / onError callback #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jesusoterogomez
Copy link

Changes:

  • Added a destroy function to printer to shutdown the server, unmap port and bonjour service.
  • Added support for attaching an onerror callback to the printer to catch initialization problems.

Referencing issue #17, I have made these changes, which enable the user to disable the printer without exiting the node process/closing the application. This is useful for an implementation where it's needed to make changes to the printer settings on "runtime".

Initializing a new printer without these changes would result in two possible exceptions, either the EADDRINUSE exception from node when the port/ip was already occupied. or a Bonjour exception stating that the "service name" (printer.name) was already taken.

These exceptions could not be caught by wrapping the printer setup code in a try...catch block. So I added an on('error') callback to the server, which isn't perfect at this point because it doesn't catch the bonjour/zeroconf errors, but it does the basic job.

P.S: I know these changes might not be readily mergeable, especially because of the use of a new dependency for adding support for destroying the server (This is something that would be easy to add without it). And for extending the printer object in bind.js.

Anyways, I look forward to reading your comments!

- Added support for attaching an onError callback to the printer to catch initialization problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant