Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 701B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. const tls = require('tls');
  3. module.exports = (options = {}) => new Promise((resolve, reject) => {
  4. let timeout = false;
  5. const callback = async () => {
  6. socket.off('timeout', onTimeout);
  7. socket.off('error', reject);
  8. if (options.resolveSocket) {
  9. resolve({alpnProtocol: socket.alpnProtocol, socket, timeout});
  10. if (timeout) {
  11. await Promise.resolve();
  12. socket.emit('timeout');
  13. }
  14. } else {
  15. socket.destroy();
  16. resolve({alpnProtocol: socket.alpnProtocol, timeout});
  17. }
  18. };
  19. const onTimeout = async () => {
  20. timeout = true;
  21. callback();
  22. };
  23. const socket = tls.connect(options, callback);
  24. socket.on('error', reject);
  25. socket.once('timeout', onTimeout);
  26. });