MCPcopy
hub / github.com/PokemonGoF/PokemonGo-Bot / buildBuilderBrowser

Function buildBuilderBrowser

map-chat/javascript/browserMqtt.js:925–963  ·  view source on GitHub ↗
(mqttClient, opts)

Source from the content-addressed store, hash-verified

923}
924
925function buildBuilderBrowser (mqttClient, opts) {
926 var url,
927 parsed = _URL.parse(document.URL);
928
929 if (!opts.protocol) {
930 if ('https:' === parsed.protocol) {
931 opts.protocol = 'wss';
932 } else {
933 opts.protocol = 'ws';
934 }
935 }
936
937 if (!opts.hostname) {
938 opts.hostnme = opts.host;
939 }
940
941 if (!opts.hostname) {
942 opts.hostname = parsed.hostname;
943 if (!opts.port) {
944 opts.port = parsed.port;
945 }
946 }
947
948 if (!opts.port) {
949 if ('wss' === opts.protocol) {
950 opts.port = 443;
951 } else {
952 opts.port = 80;
953 }
954 }
955
956 if (!opts.path) {
957 opts.path = '/';
958 }
959
960 url = opts.protocol + '://' + opts.hostname + ':' + opts.port + opts.path;
961
962 return websocket(url, 'mqttv3.1');
963}
964
965if ('browser' !== process.title) {
966 module.exports = buildBuilder;

Callers

nothing calls this directly

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected