From d6a83e4a8c1b5c9971819a5d4287d8a03889d70c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 2 Oct 2021 16:57:34 -0500 Subject: add hubFactory --- src/web/src/lib/hubFactory.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/web/src/lib/hubFactory.js (limited to 'src/web') diff --git a/src/web/src/lib/hubFactory.js b/src/web/src/lib/hubFactory.js new file mode 100644 index 00000000..f03d89a0 --- /dev/null +++ b/src/web/src/lib/hubFactory.js @@ -0,0 +1,18 @@ +import { + JsonHubProtocol, + HubConnectionBuilder, + LogLevel +} from '@microsoft/signalr' + +import { rootUrl } from '../config'; +import * as session from '../lib/session'; + +export const createApplicationHubConnection = () => + new HubConnectionBuilder() + .withUrl(`${rootUrl}/hub/application`, { + accessTokenFactory: session.getToken + }) + .withAutomaticReconnect() + .withHubProtocol(new JsonHubProtocol()) + .configureLogging(LogLevel.Information) + .build(); \ No newline at end of file -- cgit v1.2.3