chat ready

This commit is contained in:
s459315 2022-04-30 13:05:52 +02:00
parent 432334fe75
commit da0566ea39
36 changed files with 5612 additions and 10 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.SignalR;
namespace SignalRChat.Hubs
{
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}

View File

@ -1,10 +1,30 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<div class="container">
<div class="row">&nbsp;</div>
<div class="row">
<div class="col-2">User</div>
<div class="col-4"><input type="text" id="userInput" /></div>
</div>
<div class="row">
<div class="col-2">Message</div>
<div class="col-4"><input type="text" id="messageInput" /></div>
</div>
<div class="row">&nbsp;</div>
<div class="row">
<div class="col-6">
<input type="button" id="sendButton" value="Send Message" />
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<hr />
</div>
</div>
<div class="row">
<div class="col-6">
<ul id="messagesList"></ul>
</div>
</div>
<script src="~/js/signalr/dist/browser/signalr.js"></script>
<script src="~/js/chat.js"></script>

View File

@ -1,7 +1,11 @@
using SignalRChat.Hubs;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddSignalR();
var app = builder.Build();
@ -21,5 +25,6 @@ app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.MapHub<ChatHub>("/chatHub");
app.Run();

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

View File

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"SignalRChat/1.0.0": {
"runtime": {
"SignalRChat.dll": {}
}
}
}
},
"libraries": {
"SignalRChat/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net6.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "6.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "6.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,9 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,14 @@
{
"version": "1.0",
"defaultProvider": "unpkg",
"libraries": [
{
"library": "@microsoft/signalr@latest",
"destination": "wwwroot/js/signalr",
"files": [
"dist/browser/signalr.js",
"dist/browser/signalr.min.js"
]
}
]
}

14
SignalRChat/libman.json Normal file
View File

@ -0,0 +1,14 @@
{
"version": "1.0",
"defaultProvider": "unpkg",
"libraries": [
{
"library": "@microsoft/signalr@latest",
"destination": "wwwroot/js/signalr",
"files": [
"dist/browser/signalr.js",
"dist/browser/signalr.min.js"
]
}
]
}

View File

@ -0,0 +1 @@
f50d17b39169d86a157062e5385561763854e020

View File

@ -0,0 +1,27 @@
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\appsettings.Development.json
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\appsettings.json
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\libman.json
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\SignalRChat.staticwebassets.runtime.json
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\SignalRChat.exe
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\SignalRChat.deps.json
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\SignalRChat.runtimeconfig.json
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\SignalRChat.dll
D:\C#\SignalRChat\SignalRChat\bin\Debug\net6.0\SignalRChat.pdb
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.csproj.AssemblyReference.cache
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.GeneratedMSBuildEditorConfig.editorconfig
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.AssemblyInfoInputs.cache
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.AssemblyInfo.cs
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.csproj.CoreCompileInputs.cache
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.MvcApplicationPartsAssemblyInfo.cache
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.RazorAssemblyInfo.cache
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.RazorAssemblyInfo.cs
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\staticwebassets.build.json
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\staticwebassets.development.json
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\scopedcss\Pages\Shared\_Layout.cshtml.rz.scp.css
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\scopedcss\bundle\SignalRChat.styles.css
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\scopedcss\projectbundle\SignalRChat.bundle.scp.css
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.dll
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\refint\SignalRChat.dll
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.pdb
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\SignalRChat.genruntimeconfig.cache
D:\C#\SignalRChat\SignalRChat\obj\Debug\net6.0\ref\SignalRChat.dll

Binary file not shown.

View File

@ -0,0 +1 @@
ed073123de0b547a1aadce9d62072d9c2790710e

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,48 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand[b-qs0l4gmowu] {
white-space: normal;
text-align: center;
word-break: break-all;
}
a[b-qs0l4gmowu] {
color: #0077cc;
}
.btn-primary[b-qs0l4gmowu] {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active[b-qs0l4gmowu], .nav-pills .show > .nav-link[b-qs0l4gmowu] {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top[b-qs0l4gmowu] {
border-top: 1px solid #e5e5e5;
}
.border-bottom[b-qs0l4gmowu] {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow[b-qs0l4gmowu] {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy[b-qs0l4gmowu] {
font-size: 1rem;
line-height: inherit;
}
.footer[b-qs0l4gmowu] {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,49 @@
/* _content/SignalRChat/Pages/Shared/_Layout.cshtml.rz.scp.css */
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand[b-qs0l4gmowu] {
white-space: normal;
text-align: center;
word-break: break-all;
}
a[b-qs0l4gmowu] {
color: #0077cc;
}
.btn-primary[b-qs0l4gmowu] {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active[b-qs0l4gmowu], .nav-pills .show > .nav-link[b-qs0l4gmowu] {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top[b-qs0l4gmowu] {
border-top: 1px solid #e5e5e5;
}
.border-bottom[b-qs0l4gmowu] {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow[b-qs0l4gmowu] {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy[b-qs0l4gmowu] {
font-size: 1rem;
line-height: inherit;
}
.footer[b-qs0l4gmowu] {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@ -0,0 +1,49 @@
/* _content/SignalRChat/Pages/Shared/_Layout.cshtml.rz.scp.css */
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand[b-qs0l4gmowu] {
white-space: normal;
text-align: center;
word-break: break-all;
}
a[b-qs0l4gmowu] {
color: #0077cc;
}
.btn-primary[b-qs0l4gmowu] {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active[b-qs0l4gmowu], .nav-pills .show > .nav-link[b-qs0l4gmowu] {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top[b-qs0l4gmowu] {
border-top: 1px solid #e5e5e5;
}
.border-bottom[b-qs0l4gmowu] {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow[b-qs0l4gmowu] {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy[b-qs0l4gmowu] {
font-size: 1rem;
line-height: inherit;
}
.footer[b-qs0l4gmowu] {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
2.0

View File

@ -0,0 +1,30 @@
"use strict";
var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build();
//Disable the send button until connection is established.
document.getElementById("sendButton").disabled = true;
connection.on("ReceiveMessage", function (user, message) {
var li = document.createElement("li");
document.getElementById("messagesList").appendChild(li);
// We can assign user-supplied strings to an element's textContent because it
// is not interpreted as markup. If you're assigning in any other way, you
// should be aware of possible script injection concerns.
li.textContent = `${user} says ${message}`;
});
connection.start().then(function () {
document.getElementById("sendButton").disabled = false;
}).catch(function (err) {
return console.error(err.toString());
});
document.getElementById("sendButton").addEventListener("click", function (event) {
var user = document.getElementById("userInput").value;
var message = document.getElementById("messageInput").value;
connection.invoke("SendMessage", user, message).catch(function (err) {
return console.error(err.toString());
});
event.preventDefault();
});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long