chat ready
This commit is contained in:
parent
432334fe75
commit
da0566ea39
1026
.vs/SignalRChat/config/applicationhost.config
Normal file
1026
.vs/SignalRChat/config/applicationhost.config
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
12
SignalRChat/Hubs/ChatHub.cs
Normal file
12
SignalRChat/Hubs/ChatHub.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
<div class="container">
|
||||
<div class="row"> </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"> </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>
|
@ -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();
|
||||
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
23
SignalRChat/bin/Debug/net6.0/SignalRChat.deps.json
Normal file
23
SignalRChat/bin/Debug/net6.0/SignalRChat.deps.json
Normal 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": ""
|
||||
}
|
||||
}
|
||||
}
|
BIN
SignalRChat/bin/Debug/net6.0/SignalRChat.dll
Normal file
BIN
SignalRChat/bin/Debug/net6.0/SignalRChat.dll
Normal file
Binary file not shown.
BIN
SignalRChat/bin/Debug/net6.0/SignalRChat.exe
Normal file
BIN
SignalRChat/bin/Debug/net6.0/SignalRChat.exe
Normal file
Binary file not shown.
BIN
SignalRChat/bin/Debug/net6.0/SignalRChat.pdb
Normal file
BIN
SignalRChat/bin/Debug/net6.0/SignalRChat.pdb
Normal file
Binary file not shown.
19
SignalRChat/bin/Debug/net6.0/SignalRChat.runtimeconfig.json
Normal file
19
SignalRChat/bin/Debug/net6.0/SignalRChat.runtimeconfig.json
Normal 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
@ -0,0 +1,9 @@
|
||||
{
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
SignalRChat/bin/Debug/net6.0/appsettings.json
Normal file
9
SignalRChat/bin/Debug/net6.0/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
14
SignalRChat/bin/Debug/net6.0/libman.json
Normal file
14
SignalRChat/bin/Debug/net6.0/libman.json
Normal 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
14
SignalRChat/libman.json
Normal 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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1 @@
|
||||
f50d17b39169d86a157062e5385561763854e020
|
@ -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
|
BIN
SignalRChat/obj/Debug/net6.0/SignalRChat.dll
Normal file
BIN
SignalRChat/obj/Debug/net6.0/SignalRChat.dll
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
ed073123de0b547a1aadce9d62072d9c2790710e
|
BIN
SignalRChat/obj/Debug/net6.0/SignalRChat.pdb
Normal file
BIN
SignalRChat/obj/Debug/net6.0/SignalRChat.pdb
Normal file
Binary file not shown.
BIN
SignalRChat/obj/Debug/net6.0/apphost.exe
Normal file
BIN
SignalRChat/obj/Debug/net6.0/apphost.exe
Normal file
Binary file not shown.
1
SignalRChat/obj/Debug/net6.0/project.razor.json
Normal file
1
SignalRChat/obj/Debug/net6.0/project.razor.json
Normal file
File diff suppressed because one or more lines are too long
BIN
SignalRChat/obj/Debug/net6.0/ref/SignalRChat.dll
Normal file
BIN
SignalRChat/obj/Debug/net6.0/ref/SignalRChat.dll
Normal file
Binary file not shown.
BIN
SignalRChat/obj/Debug/net6.0/refint/SignalRChat.dll
Normal file
BIN
SignalRChat/obj/Debug/net6.0/refint/SignalRChat.dll
Normal file
Binary file not shown.
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
1125
SignalRChat/obj/Debug/net6.0/staticwebassets.build.json
Normal file
1125
SignalRChat/obj/Debug/net6.0/staticwebassets.build.json
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
1
SignalRChat/obj/staticwebassets.pack.sentinel
Normal file
1
SignalRChat/obj/staticwebassets.pack.sentinel
Normal file
@ -0,0 +1 @@
|
||||
2.0
|
30
SignalRChat/wwwroot/js/chat.js
Normal file
30
SignalRChat/wwwroot/js/chat.js
Normal 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();
|
||||
});
|
3115
SignalRChat/wwwroot/js/signalr/dist/browser/signalr.js
vendored
Normal file
3115
SignalRChat/wwwroot/js/signalr/dist/browser/signalr.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
SignalRChat/wwwroot/js/signalr/dist/browser/signalr.min.js
vendored
Normal file
2
SignalRChat/wwwroot/js/signalr/dist/browser/signalr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user