Skip to content

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.
@jesusoterogomez jesusoterogomez force-pushed the feat/print_server_destroy/1 branch from 6fa9795 to 9d895df Compare November 2, 2017 10:27
@jesusoterogomez jesusoterogomez force-pushed the feat/print_server_destroy/1 branch from 807e90e to cb53d87 Compare November 9, 2017 16:36
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