Skip to content

Commit

Permalink
Merge pull request #6548 from aspnetboilerplate/feat/6538
Browse files Browse the repository at this point in the history
Allow passing options to SignalR withUrl
  • Loading branch information
ismcagdas committed Sep 21, 2022
2 parents 2e2cd35 + c018238 commit 158088f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit 158088f

Please sign in to comment.