How to use the @microsoft/signalr.HttpTransportType.WebSockets 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("connection id is alwys null is negotiation is skipped", async (done) => {
        try {
            const hubConnection = getConnectionBuilder(
                    HttpTransportType.WebSockets,
                    undefined,
                    { skipNegotiation: true },
                )
                .build();

            expect(hubConnection.connectionId).toBeNull();

            await hubConnection.start();

            expect(hubConnection.connectionId).toBeNull();

            await hubConnection.stop();

            expect(hubConnection.connectionId).toBeNull();

            done();
github dotnet / aspnetcore / src / SignalR / clients / ts / FunctionalTests / ts / HubConnectionTests.ts View on Github external
it("can reconnect after skipping negotiation", async (done) => {
        try {
            const reconnectingPromise = new PromiseSource();
            const reconnectedPromise = new PromiseSource();
            const hubConnection = getConnectionBuilder(
                    HttpTransportType.WebSockets,
                    undefined,
                    { skipNegotiation: true },
                )
                .withAutomaticReconnect()
                .build();

            hubConnection.onreconnecting(() => {
                reconnectingPromise.resolve();
            });

            hubConnection.onreconnected((connectionId?) => {
                reconnectedPromise.resolve(connectionId);
            });

            await hubConnection.start();
github sketch7 / signalr-client / src / hub-connection.factory.ts View on Github external
create(...connectionOptions: HubConnectionOptions[]): this {
		for (const connectionOption of connectionOptions) {
			if (!connectionOption.key) {
				throw new Error(`${this.source} create :: connection key not set`);
			}
			if (!connectionOption.endpointUri) {
				throw new Error(`${this.source} create :: connection endpointUri not set for ${connectionOption.key}`);
			}
			if (!connectionOption.options) {
				connectionOption.options = {
					transport: HttpTransportType.WebSockets
				};
			} else if (!connectionOption.options.transport) {
				connectionOption.options.transport = HttpTransportType.WebSockets;
			}

			this.hubConnections[connectionOption.key] = new HubConnection(connectionOption);
		}
		return this;
	}
github sketch7 / signalr-client / src / hub-connection.factory.ts View on Github external
create(...connectionOptions: HubConnectionOptions[]): this {
		for (const connectionOption of connectionOptions) {
			if (!connectionOption.key) {
				throw new Error(`${this.source} create :: connection key not set`);
			}
			if (!connectionOption.endpointUri) {
				throw new Error(`${this.source} create :: connection endpointUri not set for ${connectionOption.key}`);
			}
			if (!connectionOption.options) {
				connectionOption.options = {
					transport: HttpTransportType.WebSockets
				};
			} else if (!connectionOption.options.transport) {
				connectionOption.options.transport = HttpTransportType.WebSockets;
			}

			this.hubConnections[connectionOption.key] = new HubConnection(connectionOption);
		}
		return this;
	}
github dotnet / aspnetcore / src / SignalR / clients / ts / FunctionalTests / ts / Common.ts View on Github external
export function getHttpTransportTypes(): HttpTransportType[] {
    const transportTypes = [];
    if (typeof window === "undefined") {
        transportTypes.push(HttpTransportType.WebSockets);
        transportTypes.push(HttpTransportType.ServerSentEvents);
    } else {
        if (typeof WebSocket !== "undefined") {
            transportTypes.push(HttpTransportType.WebSockets);
        }
        if (typeof EventSource !== "undefined") {
            transportTypes.push(HttpTransportType.ServerSentEvents);
        }
    }
    transportTypes.push(HttpTransportType.HttpStreaming);
    transportTypes.push(HttpTransportType.LongPolling);

    return transportTypes;
}