-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alejandro Del Rincón López
committed
Oct 23, 2023
1 parent
1c86b9c
commit 317c38a
Showing
6 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
This is a configuration file for the SwitchStartupProject Visual Studio Extension | ||
See https://heptapod.host/thirteen/switchstartupproject/blob/branch/current/Configuration.md | ||
*/ | ||
{ | ||
/* Configuration File Version */ | ||
"Version": 3, | ||
|
||
/* Create an item in the dropdown list for each project in the solution? */ | ||
"ListAllProjects": true, | ||
|
||
/* | ||
Dictionary of named configurations with one or multiple startup projects | ||
and optional parameters like command line arguments and working directory. | ||
Example: | ||
|
||
"MultiProjectConfigurations": { | ||
"A + B (Ext)": { | ||
"Projects": { | ||
"MyProjectA": {}, | ||
"MyProjectB": { | ||
"CommandLineArguments": "1234", | ||
"WorkingDirectory": "%USERPROFILE%\\test", | ||
"StartExternalProgram": "c:\\myprogram.exe" | ||
} | ||
} | ||
}, | ||
"A + B": { | ||
"Projects": { | ||
"MyProjectA": {}, | ||
"MyProjectB": { | ||
"CommandLineArguments": "", | ||
"WorkingDirectory": "", | ||
"StartProject": true | ||
} | ||
} | ||
}, | ||
"D (Debug x86)": { | ||
"Projects": { | ||
"MyProjectD": {} | ||
}, | ||
"SolutionConfiguration": "Debug", | ||
"SolutionPlatform": "x86", | ||
}, | ||
"D (Release x64)": { | ||
"Projects": { | ||
"MyProjectD": {} | ||
}, | ||
"SolutionConfiguration": "Release", | ||
"SolutionPlatform": "x64", | ||
} | ||
} | ||
*/ | ||
"MultiProjectConfigurations": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@page "/Chat" | ||
@using Microsoft.AspNetCore.SignalR.Client | ||
@inject NavigationManager Navigation | ||
@implements IAsyncDisposable | ||
|
||
<PageTitle>Chat</PageTitle> | ||
|
||
<div class="form-group"> | ||
<label> | ||
User: | ||
<input @bind="userInput" /> | ||
</label> | ||
</div> | ||
<div class="form-group"> | ||
<label> | ||
Message: | ||
<input @bind="messageInput" size="50" /> | ||
</label> | ||
</div> | ||
<button @onclick="Send" disabled="@(!IsConnected)">Send</button> | ||
|
||
<hr> | ||
|
||
<ul id="messagesList"> | ||
@foreach (var message in messages) | ||
{ | ||
<li>@message</li> | ||
} | ||
</ul> | ||
|
||
@code { | ||
private HubConnection? hubConnection; | ||
private List<string> messages = new List<string>(); | ||
private string? userInput; | ||
private string? messageInput; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
hubConnection = new HubConnectionBuilder() | ||
.WithUrl(Navigation.ToAbsoluteUri("/chathub")) | ||
.Build(); | ||
|
||
hubConnection.On<string, string>("ReceiveMessage", (user, message) => | ||
{ | ||
var encodedMsg = $"{user}: {message}"; | ||
messages.Add(encodedMsg); | ||
StateHasChanged(); | ||
}); | ||
|
||
await hubConnection.StartAsync(); | ||
} | ||
|
||
private async Task Send() | ||
{ | ||
if (hubConnection is not null) | ||
{ | ||
await hubConnection.SendAsync("SendMessage", userInput, messageInput); | ||
} | ||
} | ||
|
||
public bool IsConnected => | ||
hubConnection?.State == HubConnectionState.Connected; | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (hubConnection is not null) | ||
{ | ||
await hubConnection.DisposeAsync(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace BlazorApp1.Server.Hubs; | ||
|
||
public class ChatHub : Hub | ||
{ | ||
public async Task SendMessage(string user, string message) | ||
{ | ||
await Clients.All.SendAsync("ReceiveMessage", user, message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters