Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lib/ConnectionContextBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { DataTransformer, DefaultDataTransformer } from "./dataTransformer";
import { TokenProvider } from "./auth/token";
import { ConnectionConfig } from "./connectionConfig";
import { SasTokenProvider } from "./auth/sas";
import rhea from "rhea";

import * as Constants from "./util/constants";
import * as os from "os";
Expand Down Expand Up @@ -141,7 +140,7 @@ export module ConnectionContextBase {
if (userAgent.length > Constants.maxUserAgentLength) {
throw new Error(
`The user-agent string cannot be more than 128 characters in length.` +
`The given user-agent string is: ${userAgent} with length: ${userAgent.length}`
`The given user-agent string is: ${userAgent} with length: ${userAgent.length}`
);
}

Expand All @@ -162,17 +161,19 @@ export module ConnectionContextBase {
operationTimeoutInSeconds: parameters.operationTimeoutInSeconds
};

if (parameters.config.webSocket || (typeof window !== "undefined" && (window as any).WebSocket)) {
if (
parameters.config.webSocket ||
(typeof window !== "undefined" && (window as any).WebSocket)
) {
const socket = parameters.config.webSocket || (window as any).WebSocket;
// TODO: expose websocket_connect via rhea-promise
const ws = rhea.websocket_connect(socket);
const host = parameters.config.host;
const endpoint = parameters.config.webSocketEndpointPath || '';
const endpoint = parameters.config.webSocketEndpointPath || "";

// connectionOptions is cast to any to work around type errors.
// The errors seem spurious and so are ignored.
(connectionOptions.connection_details as any) =
ws(`wss://${host}:443/${endpoint}`, ["AMQPWSB10"], {});
connectionOptions.webSocketOptions = {
webSocket: socket,
url: `wss://${host}:443/${endpoint}`,
protocol: ["AMQPWSB10"]
};
}

const connection = new Connection(connectionOptions);
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"stream": "stream-browserify"
},
"peerDependencies": {
"rhea": "^0.3.9",
"rhea-promise": "^0.1.13"
"rhea-promise": "^0.1.14"
},
"devDependencies": {
"@azure/ms-rest-js": "^1.7.0",
Expand All @@ -54,8 +53,7 @@
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
"nyc": "^13.3.0",
"rhea": "^0.3.9",
"rhea-promise": "^0.1.13",
"rhea-promise": "^0.1.14",
"rimraf": "^2.6.2",
"rollup": "^1.1.2",
"rollup-plugin-commonjs": "^9.2.0",
Expand Down