Skip to content

Commit 1184e8e

Browse files
authored
websockets playground init (#108)
1 parent a8b7b0a commit 1184e8e

File tree

8 files changed

+85
-1
lines changed

8 files changed

+85
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
inbox.md
22
.DS_Store
3-
playground/
3+
/playground
44

55
## Ignore Visual Studio temporary files, build results, and
66
## files generated by popular Visual Studio add-ons.

Nist.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Errors.Playground", "e
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nist.Errors", "errors\lib\Nist.Errors.csproj", "{65C9AFED-F255-4743-BBE7-2ED2E488F05D}"
1111
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "websockets", "websockets", "{B1CFABB9-9703-4B35-9FBD-119234DF5101}"
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{53E0C99D-9D72-4B96-9168-5AB070F1EF9C}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Playground.WebSockets", "websockets\dotnet\playground\Playground.WebSockets.csproj", "{5150ABCD-009A-4F38-B8CE-5DF57E4F8903}"
17+
EndProject
1218
Global
1319
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1420
Debug|Any CPU = Debug|Any CPU
@@ -26,9 +32,15 @@ Global
2632
{65C9AFED-F255-4743-BBE7-2ED2E488F05D}.Debug|Any CPU.Build.0 = Debug|Any CPU
2733
{65C9AFED-F255-4743-BBE7-2ED2E488F05D}.Release|Any CPU.ActiveCfg = Release|Any CPU
2834
{65C9AFED-F255-4743-BBE7-2ED2E488F05D}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{5150ABCD-009A-4F38-B8CE-5DF57E4F8903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{5150ABCD-009A-4F38-B8CE-5DF57E4F8903}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{5150ABCD-009A-4F38-B8CE-5DF57E4F8903}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{5150ABCD-009A-4F38-B8CE-5DF57E4F8903}.Release|Any CPU.Build.0 = Release|Any CPU
2939
EndGlobalSection
3040
GlobalSection(NestedProjects) = preSolution
3141
{3448B6A0-78B9-4F52-A971-9407F9B331CF} = {AA026DC3-ACA9-418C-9D5F-C0FA54F764CA}
3242
{65C9AFED-F255-4743-BBE7-2ED2E488F05D} = {AA026DC3-ACA9-418C-9D5F-C0FA54F764CA}
43+
{53E0C99D-9D72-4B96-9168-5AB070F1EF9C} = {B1CFABB9-9703-4B35-9FBD-119234DF5101}
44+
{5150ABCD-009A-4F38-B8CE-5DF57E4F8903} = {53E0C99D-9D72-4B96-9168-5AB070F1EF9C}
3345
EndGlobalSection
3446
EndGlobal

websockets/dotnet/article/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```sh
2+
dotnet new web --name Playground.WebSockets
3+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="WebSocket4Net" Version="0.15.2" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Net.WebSockets;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
var app = builder.Build();
6+
7+
app.UseWebSockets();
8+
9+
app.Map("/echo", async (HttpContext context) => {
10+
var webSocket = await context.WebSockets.AcceptWebSocketAsync();
11+
var buffer = new byte[8];
12+
var result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
13+
await webSocket.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), WebSocketMessageType.Text, true, CancellationToken.None);
14+
});
15+
16+
app.Run();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "http://localhost:5102",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": true,
17+
"applicationUrl": "https://localhost:7032;http://localhost:5102",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)