Skip to content
This repository was archived by the owner on Apr 23, 2023. It is now read-only.

Commit f65eb47

Browse files
Merge branch 'signalr' into webhooks
2 parents 40096f1 + 63a1587 commit f65eb47

File tree

19 files changed

+62
-2668
lines changed

19 files changed

+62
-2668
lines changed

SignalRAndWebHooks/Readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This chapter contains these samples:
66
* SignalR (ASP.NET Core App, HTML client, Windows App client)
77
* WebHooksReceiver (with Dropbox and GitHub)
88

9-
The WebHooks packages for .NET Core are early versions available on NuGet.
9+
The WebHooks packages for .NET Core are early versions available on NuGet, this is not part of .NET Core 2.1.
1010

11-
You need to configure the myget server to get the early packages:
11+
For WebHooks you need to configure the myget server to get the early packages:
1212

1313
* [.NET Core MyGet](https://dotnet.myget.org/F/dotnet-core/api/v3/index.json)
1414
* [ASP.NET Core MyGet](https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json)
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<UserSecretsId>329439ca-02ee-452b-8378-e171fa3c5c97</UserSecretsId>
56
</PropertyGroup>
67

78
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0-preview1-final" />
9-
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.0-preview1-final" />
9+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.3" />
10+
<!--<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.3" />
11+
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="1.0.3" />-->
12+
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.0-preview1-10200" />
1013
</ItemGroup>
1114

1215
</Project>

SignalRAndWebHooks/SignalRSample/ChatServer/Hubs/GroupChatHub.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ public interface IGroupClient
1111

1212
public class GroupChatHub : Hub<IGroupClient>
1313
{
14-
public Task AddGroup(string groupName) =>
15-
Groups.AddAsync(Context.ConnectionId, groupName);
14+
public Task AddGroup(string groupName)
15+
=> Groups.AddToGroupAsync(Context.ConnectionId, groupName);
1616

17-
public Task LeaveGroup(string groupName) =>
18-
Groups.RemoveAsync(Context.ConnectionId, groupName);
17+
public Task LeaveGroup(string groupName)
18+
=> Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
1919

2020
public void Send(string group, string name, string message) =>
2121
Clients.Group(group).MessageToGroup(group, name, message);

SignalRAndWebHooks/SignalRSample/ChatServer/Startup.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Startup
1111
{
1212
public void ConfigureServices(IServiceCollection services)
1313
{
14-
services.AddSignalR();
14+
services.AddSignalR(); //.AddAzureSignalR();
1515
}
1616

1717
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
@@ -21,13 +21,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
2121
app.UseDeveloperExceptionPage();
2222
}
2323

24-
app.UseStaticFiles();
24+
app.UseFileServer();
2525

2626
app.UseSignalR(routes =>
2727
{
2828
routes.MapHub<ChatHub>("/chat");
2929
routes.MapHub<GroupChatHub>("/groupchat");
3030
});
31+
//app.UseAzureSignalR(routes =>
32+
//{
33+
// routes.MapHub<ChatHub>("/chat");
34+
// routes.MapHub<GroupChatHub>("/groupchat");
35+
//});
3136

3237
app.Run(async (context) =>
3338
{

SignalRAndWebHooks/SignalRSample/ChatServer/package-lock.json

-13
This file was deleted.

SignalRAndWebHooks/SignalRSample/ChatServer/package.json

-9
This file was deleted.

SignalRAndWebHooks/SignalRSample/ChatServer/wwwroot/ChatWindow.html

+10-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
<title>Chat Client</title>
66
</head>
77
<body>
8-
9-
<script src="js/signalr.js"></script>
8+
<script src="https://cdn.jsdelivr.net/npm/@aspnet/[email protected]/dist/browser/signalr.js"></script>
109
<script>
1110
document.addEventListener("DOMContentLoaded", function () {
12-
let connection = new signalR.HubConnection('/chat');
11+
const connection = new signalR.HubConnectionBuilder()
12+
.configureLogging(signalR.LogLevel.Trace)
13+
.withUrl("/chat")
14+
.build();
15+
1316
connection.on('broadcastMessage', (name, message) => {
1417
console.log(message);
1518
document.getElementById('output').innerHTML += `message from ${name}: ${message}<br />`;
@@ -33,8 +36,10 @@
3336
<input type="text" id="message" />
3437
<br />
3538
<input id="sendButton" type="button" value="send" />
36-
<p />
37-
<output id="output"></output>
39+
<p>
40+
<output id="output"></output>
41+
</p>
42+
3843

3944
</body>
4045
</html>

0 commit comments

Comments
 (0)