How to use the @microsoft/signalr/dist/esm/Utils.Platform.isNode function in @microsoft/signalr

To help you get started, we’ve selected a few @microsoft/signalr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dotnet / aspnetcore / src / SignalR / clients / ts / FunctionalTests / ts / HubConnectionTests.ts View on Github external
it("sets the user agent header", async (done) => {
            const hubConnection = getConnectionBuilder(t, TESTHUBENDPOINT_URL)
                .withHubProtocol(new JsonHubProtocol())
                .build();

            try {
                await hubConnection.start();

                // Check to see that the Content-Type header is set the expected value
                const [name, value] = getUserAgentHeader();
                const headerValue = await hubConnection.invoke("GetHeader", name);

                if ((t === HttpTransportType.ServerSentEvents || t === HttpTransportType.WebSockets) && !Platform.isNode) {
                    expect(headerValue).toBeNull();
                } else {
                    expect(headerValue).toEqual(value);
                }

                await hubConnection.stop();
                done();
            } catch (e) {
                fail(e);
            }
        });
    });
github dotnet / aspnetcore / src / SignalR / clients / ts / FunctionalTests / ts / Common.ts View on Github external
export function getHttpClients(): HttpClient[] {
    const httpClients: HttpClient[] = [];
    if (typeof XMLHttpRequest !== "undefined") {
        httpClients.push(new XhrHttpClient(TestLogger.instance));
    }
    if (typeof fetch !== "undefined") {
        httpClients.push(new FetchHttpClient(TestLogger.instance));
    }
    if (Platform.isNode) {
        httpClients.push(new NodeHttpClient(TestLogger.instance));
    }
    return httpClients;
}