Skip to content

Commit 605b4d4

Browse files
authored
Merge pull request #153 from acjh/signalr
ASP.NET Core SignalR 2.1.0 integration
2 parents 9c32c53 + 7af5277 commit 605b4d4

File tree

17 files changed

+227
-15
lines changed

17 files changed

+227
-15
lines changed

angular/.angular-cli.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"glob": "abp.signalr.js",
1515
"input": "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/",
1616
"output": "./assets/abp/"
17+
},
18+
{
19+
"glob": "abp.signalr-client.js",
20+
"input": "../node_modules/abp-web-resources/Abp/Framework/scripts/libs/",
21+
"output": "./assets/abp/"
1722
}
1823
],
1924
"index": "index.html",
@@ -43,6 +48,7 @@
4348
"../node_modules/lodash/lodash.min.js",
4449
"../node_modules/moment/min/moment.min.js",
4550
"../node_modules/signalr/jquery.signalR.js",
51+
"../node_modules/@aspnet/signalr-client/dist/browser/signalr-client.min.js",
4652
"../node_modules/toastr/toastr.js",
4753
"../node_modules/sweetalert/dist/sweetalert.min.js",
4854
"../node_modules/block-ui/jquery.blockUI.js",

angular/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@aspnet:registry=https://dotnet.myget.org/f/aspnetcore-dev/npm/

angular/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@angular/platform-browser": "^5.0.3",
2323
"@angular/platform-browser-dynamic": "^5.0.3",
2424
"@angular/router": "^5.0.3",
25+
"@aspnet/signalr-client": "1.0.0-preview1-27815",
2526
"@types/bootstrap": "^3.3.33",
2627
"@types/jquery": "^3.2.12",
2728
"@types/jquery.blockui": "0.0.28",
@@ -32,7 +33,7 @@
3233
"@types/signalr": "^2.2.33",
3334
"@types/toastr": "^2.1.33",
3435
"abp-ng2-module": "^1.3.0",
35-
"abp-web-resources": "^3.2.3",
36+
"abp-web-resources": "^3.3.0",
3637
"animate.css": "^3.5.2",
3738
"block-ui": "^2.70.1",
3839
"bootstrap": "^3.3.7",

angular/src/app/app.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AppConsts } from '@shared/AppConsts';
33
import { AppComponentBase } from '@shared/app-component-base';
44

55
import { SignalRHelper } from '@shared/helpers/SignalRHelper';
6+
import { SignalRAspNetCoreHelper } from '@shared/helpers/SignalRAspNetCoreHelper';
67

78
@Component({
89
templateUrl: './app.component.html'
@@ -19,7 +20,11 @@ export class AppComponent extends AppComponentBase implements OnInit, AfterViewI
1920

2021
ngOnInit(): void {
2122
if (this.appSession.application.features['SignalR']) {
22-
SignalRHelper.initSignalR();
23+
if (this.appSession.application.features['SignalR.AspNetCore']) {
24+
SignalRAspNetCoreHelper.initSignalR();
25+
} else {
26+
SignalRHelper.initSignalR();
27+
}
2328
}
2429

2530
abp.event.on('abp.notifications.received', userNotification => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { AppConsts } from '@shared/AppConsts';
2+
import { UtilsService } from '@abp/utils/utils.service';
3+
4+
export class SignalRAspNetCoreHelper {
5+
static initSignalR(): void {
6+
7+
var encryptedAuthToken = new UtilsService().getCookieValue(AppConsts.authorization.encrptedAuthTokenName);
8+
9+
abp.signalr = {
10+
autoConnect: true,
11+
connect: undefined,
12+
hubs: undefined,
13+
qs: AppConsts.authorization.encrptedAuthTokenName + "=" + encodeURIComponent(encryptedAuthToken),
14+
url: AppConsts.remoteServiceBaseUrl + '/signalr'
15+
};
16+
17+
jQuery.getScript(AppConsts.appBaseUrl + '/assets/abp/abp.signalr-client.js');
18+
}
19+
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/AbpCompanyName.AbpProjectName.Application.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1212
<RootNamespace>AbpCompanyName.AbpProjectName</RootNamespace>
1313
</PropertyGroup>
14+
15+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
16+
<DefineConstants>FEATURE_SIGNALR</DefineConstants>
17+
</PropertyGroup>
18+
19+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
20+
<DefineConstants>FEATURE_SIGNALR;FEATURE_SIGNALR_ASPNETCORE</DefineConstants>
21+
</PropertyGroup>
1422

1523
<ItemGroup>
1624
<ProjectReference Include="..\AbpCompanyName.AbpProjectName.Core\AbpCompanyName.AbpProjectName.Core.csproj" />

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Sessions/SessionAppService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public async Task<GetCurrentLoginInformationsOutput> GetCurrentLoginInformations
1919
ReleaseDate = AppVersionHelper.ReleaseDate,
2020
Features = new Dictionary<string, bool>
2121
{
22-
{ "SignalR", SignalRFeature.IsAvailable }
22+
{ "SignalR", SignalRFeature.IsAvailable },
23+
{ "SignalR.AspNetCore", SignalRFeature.IsAspNetCore }
2324
}
2425
}
2526
};

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/SignalR/SignalRFeature.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ public static bool IsAvailable
1010
return true;
1111
#else
1212
return false;
13+
#endif
14+
}
15+
}
16+
17+
public static bool IsAspNetCore
18+
{
19+
get
20+
{
21+
#if FEATURE_SIGNALR_ASPNETCORE
22+
return true;
23+
#else
24+
return false;
1325
#endif
1426
}
1527
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Core/AbpCompanyName.AbpProjectName.Web.Core.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
</PropertyGroup>
1919

2020
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
21+
<DefineConstants>FEATURE_SIGNALR;FEATURE_SIGNALR_OWIN</DefineConstants>
22+
</PropertyGroup>
23+
24+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
2125
<DefineConstants>FEATURE_SIGNALR</DefineConstants>
2226
</PropertyGroup>
2327

@@ -44,4 +48,8 @@
4448
<PackageReference Include="Abp.Owin" Version="3.2.4" />
4549
</ItemGroup>
4650

51+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
52+
<PackageReference Include="Abp.Web.SignalR.AspNetCore" Version="3.3.0" />
53+
</ItemGroup>
54+
4755
</Project>

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Core/Owin/BuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if FEATURE_SIGNALR
1+
#if FEATURE_SIGNALR_OWIN
22
using System;
33
using System.Collections.Generic;
44
using System.Threading.Tasks;

0 commit comments

Comments
 (0)