Skip to content

Commit e525532

Browse files
authored
Merge pull request #10 from shahedc/SignalRPoll
SignalR poll
2 parents 45cc2f3 + 2dd3a94 commit e525532

62 files changed

Lines changed: 44814 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace NetLearner.SignalRPoll.Hubs
8+
{
9+
public class ChatHub : Hub
10+
{
11+
public async Task SendMessage(string user, string message)
12+
{
13+
await Clients.All.SendAsync("ReceiveMessage", user, message);
14+
}
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace NetLearner.SignalRPoll.Hubs
8+
{
9+
public class PollHub : Hub
10+
{
11+
public async Task SendMessage(string user, string message, string myProjectId, string myProjectVal)
12+
{
13+
await Clients.All.SendAsync("ReceiveMessage", user, message, myProjectId, myProjectVal);
14+
}
15+
}
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
9+
</ItemGroup>
10+
11+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetLearner.SignalRPoll", "NetLearner.SignalRPoll.csproj", "{C994BED5-17EE-4BD5-ABCD-AE7694F63E27}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{C994BED5-17EE-4BD5-ABCD-AE7694F63E27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C994BED5-17EE-4BD5-ABCD-AE7694F63E27}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C994BED5-17EE-4BD5-ABCD-AE7694F63E27}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C994BED5-17EE-4BD5-ABCD-AE7694F63E27}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {5A8FBC07-7939-4090-A1D2-5ED414D6DE41}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@page
2+
<div class="container">
3+
<div class="row">&nbsp;</div>
4+
<div class="row">
5+
<div class="col-2">User</div>
6+
<div class="col-4"><input type="text" id="userInput" /></div>
7+
</div>
8+
<div class="row">
9+
<div class="col-2">Message</div>
10+
<div class="col-4"><input type="text" id="messageInput" /></div>
11+
</div>
12+
<div class="row">&nbsp;</div>
13+
<div class="row">
14+
<div class="col-6">
15+
<input type="button" id="sendButton" value="Send Message" />
16+
</div>
17+
</div>
18+
</div>
19+
<div class="row">
20+
<div class="col-12">
21+
<hr />
22+
</div>
23+
</div>
24+
<div class="row">
25+
<div class="col-6">
26+
<ul id="messagesList"></ul>
27+
</div>
28+
</div>
29+
<script src="~/js/signalr/dist/browser/signalr.js"></script>
30+
<script src="~/js/chat.js"></script>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.AspNetCore.Mvc.RazorPages;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace NetLearner.SignalRPoll.Pages
11+
{
12+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
13+
public class ErrorModel : PageModel
14+
{
15+
public string RequestId { get; set; }
16+
17+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
18+
19+
private readonly ILogger<ErrorModel> _logger;
20+
21+
public ErrorModel(ILogger<ErrorModel> logger)
22+
{
23+
_logger = logger;
24+
}
25+
26+
public void OnGet()
27+
{
28+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
29+
}
30+
}
31+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<div class="text-center">
8+
<h1 class="display-4">Welcome</h1>
9+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
10+
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.RazorPages;
7+
using Microsoft.Extensions.Logging;
8+
9+
namespace NetLearner.SignalRPoll.Pages
10+
{
11+
public class IndexModel : PageModel
12+
{
13+
private readonly ILogger<IndexModel> _logger;
14+
15+
public IndexModel(ILogger<IndexModel> logger)
16+
{
17+
_logger = logger;
18+
}
19+
20+
public void OnGet()
21+
{
22+
23+
}
24+
}
25+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@page
2+
<div class="container">
3+
<div class="row">
4+
<div class="col-6">
5+
User: <input type="text" id="userInput" />
6+
<!--
7+
<br />
8+
Message...<input type="text" id="messageInput" />
9+
-->
10+
</div>
11+
<div class="col-6">&nbsp;</div>
12+
</div>
13+
<div class="row">POLL: Which ASP .NET Core web project template do you prefer?&nbsp;</div>
14+
<div class="row">
15+
<div class="col-12">
16+
<!-- input type="radio" name="group1" id="r1" value="1" /><label for="r1"> button one</label>-->
17+
18+
<input type="radio" name="myProject" id="webmvc" value="MVC (Model-View-Controller)" />
19+
<label for="webmvc">MVC (Model-View-Controller)</label>
20+
<br /><span id="webmvcBlock"></span><br />
21+
<input type="radio" name="myProject" id="webpages" value="Razor Pages" />
22+
<label for="webpages">Razor Pages</label>
23+
<br /><span id="webpagesBlock"></span><br />
24+
<input type="radio" name="myProject" id="webBlazor" value="Blazor" />
25+
<label for="webBlazor">Blazor</label>
26+
<br /><span id="webBlazorBlock"></span><br />
27+
</div>
28+
</div>
29+
<div class="row">
30+
<div class="col-12">
31+
<input type="button" id="sendButton" value="Vote Now" />
32+
<hr />
33+
</div>
34+
</div>
35+
<div class="row">
36+
<div class="col-12">
37+
<ul id="messagesList"></ul>
38+
</div>
39+
</div>
40+
</div>
41+
<script src="~/lib/jquery/dist/jquery.js"></script>
42+
<script src="~/js/signalr/dist/browser/signalr.js"></script>
43+
<script src="~/js/poll.js"></script>

0 commit comments

Comments
 (0)