| | |
| | | } else { |
| | | protocols.wx = require('./wx') |
| | | protocols.wxs = require('./wx') |
| | | |
| | | protocols.ali = require('./ali') |
| | | protocols.alis = require('./ali') |
| | | } |
| | | |
| | | protocols.ws = require('./ws') |
| | |
| | | |
| | | if (opts.cert && opts.key) { |
| | | if (opts.protocol) { |
| | | if (['mqtts', 'wss', 'wxs'].indexOf(opts.protocol) === -1) { |
| | | if (['mqtts', 'wss', 'wxs', 'alis'].indexOf(opts.protocol) === -1) { |
| | | switch (opts.protocol) { |
| | | case 'mqtt': |
| | | opts.protocol = 'mqtts' |
| | |
| | | break |
| | | case 'wx': |
| | | opts.protocol = 'wxs' |
| | | break |
| | | case 'ali': |
| | | opts.protocol = 'alis' |
| | | break |
| | | default: |
| | | throw new Error('Unknown protocol for secure connection: "' + opts.protocol + '"!') |
| | |
| | | 'ws', |
| | | 'wss', |
| | | 'wx', |
| | | 'wxs' |
| | | 'wxs', |
| | | 'ali', |
| | | 'alis' |
| | | ].filter(function (key, index) { |
| | | if (isSecure && index % 2 === 0) { |
| | | // Skip insecure protocols when requesting a secure one. |