Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing options to SignalR withUrl #6548

Merged
merged 1 commit into from
Sep 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/WebSite/SignalR-AspNetCore-Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ connecting:
abp.signalr.autoConnect = false;
abp.signalr.reconnectTime = 5000;
abp.signalr.maxTries = 8;
abp.signalr.withUrlOptions = {};
abp.signalr.increaseReconnectTime = function (time) { //anytime reconnection request gets fail abp will increase the time to wait before next request with using that function.
return time * 2; //(default is twice of previous time)
};
</script>

Note: See [Official SignalR documentation](https://learn.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-6.0&tabs=javascript#configure-additional-options) for withUrlOptions values.

In this case, you can call the **abp.signalr.connect()** function manually
whenever you need to connect to the server.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var abp = abp || {};
abp.signalr.increaseReconnectTime = abp.signalr.increaseReconnectTime || function (time) {
return time * 2;
};
abp.signalr.withUrlOptions = abp.signalr.withUrlOptions || {};

// Configure the connection for abp.signalr.hubs.common
function configureConnection(connection) {
Expand Down Expand Up @@ -101,8 +102,9 @@ var abp = abp || {};

return function start(transport) {
abp.log.debug('Starting connection using ' + signalR.HttpTransportType[transport] + ' transport');
abp.signalr.withUrlOptions.transport = transport;
var connection = new signalR.HubConnectionBuilder()
.withUrl(url, transport)
.withUrl(url, abp.signalr.withUrlOptions)
.build();

if (configureConnection && typeof configureConnection === 'function') {
Expand Down