├── .gitattributes ├── .gitignore ├── BlazorChatSample.Client ├── App.razor ├── BlazorChatSample.Client.csproj ├── Pages │ ├── Index.razor │ └── Index.razor.css ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── Instructions.razor │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css ├── _Imports.razor └── wwwroot │ ├── css │ ├── app.css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ ├── favicon.ico │ └── index.html ├── BlazorChatSample.ConsoleApp ├── BlazorChatSample.ConsoleApp.csproj └── Program.cs ├── BlazorChatSample.Server ├── BlazorChatSample.Server.csproj ├── Hubs │ └── ChatHub.cs ├── Program.cs ├── Properties │ ├── PublishProfiles │ │ └── FolderProfile.pubxml │ └── launchSettings.json └── Startup.cs ├── BlazorChatSample.Shared ├── BlazorChatSample.Shared.csproj ├── ChatClient.cs └── Messages.cs ├── BlazorChatSample.sln ├── README.md └── azure-pipelines.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /BlazorChatSample.Client/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/BlazorChatSample.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @using BlazorChatSample.Shared 2 | @page "/" 3 | @inject NavigationManager navigationManager 4 | 5 |
6 | @if (chatting) 7 | { 8 |

You are connected as @username

9 | 10 | } 11 |
12 | 13 |
14 | 15 |

Blazor SignalR Chat Sample

16 | 17 | @if (!chatting) 18 | { 19 | @* Moved instructions to shared component *@ 20 | 21 | 22 |

Chat

23 | 24 |

25 | Enter your name to start chatting: 26 |

27 | 28 | 29 | 30 | 31 | @if (message != null) 32 | { 33 |
@message
34 | @message 35 | } 36 | } 37 | 38 | @if (chatting) 39 | { 40 |
41 | 42 | @foreach (var item in messages) 43 | { 44 |
45 |
@item.Username
46 |
@item.Body
47 |
48 | } 49 |
50 | 51 | 52 |
53 | } 54 |
55 | 56 | @code { 57 | // flag to indicate chat status 58 | bool chatting = false; 59 | 60 | // name of the user who will be chatting 61 | string username = null; 62 | 63 | ChatClient client = null; 64 | 65 | // on-screen message 66 | string message = null; 67 | 68 | // new message input 69 | string newMessage = null; 70 | 71 | // list of messages in chat 72 | List messages = new List(); 73 | 74 | /// 75 | /// Start chat client 76 | /// 77 | async Task Chat() 78 | { 79 | // check username is valid 80 | if (string.IsNullOrWhiteSpace(username)) 81 | { 82 | message = "Please enter a name"; 83 | return; 84 | }; 85 | 86 | try 87 | { 88 | // remove old messages if any 89 | messages.Clear(); 90 | 91 | // Create the chat client 92 | string baseUrl = navigationManager.BaseUri; 93 | client = new ChatClient(username, baseUrl); 94 | // add an event handler for incoming messages 95 | client.MessageReceived += MessageReceived; 96 | // start the client 97 | Console.WriteLine("Index: chart starting..."); 98 | await client.StartAsync(); 99 | Console.WriteLine("Index: chart started?"); 100 | 101 | chatting = true; 102 | } 103 | catch (Exception e) 104 | { 105 | message = $"ERROR: Failed to start chat client: {e.Message}"; 106 | Console.WriteLine(e.Message); 107 | Console.WriteLine(e.StackTrace); 108 | } 109 | } 110 | 111 | /// 112 | /// Inbound message 113 | /// 114 | /// 115 | /// 116 | void MessageReceived(object sender, MessageReceivedEventArgs e) 117 | { 118 | Console.WriteLine($"Blazor: receive {e.Username}: {e.Message}"); 119 | bool isMine = false; 120 | if (!string.IsNullOrWhiteSpace(e.Username)) 121 | { 122 | isMine = string.Equals(e.Username, username, StringComparison.CurrentCultureIgnoreCase); 123 | } 124 | 125 | var newMsg = new Message(e.Username, e.Message, isMine); 126 | messages.Add(newMsg); 127 | 128 | // Inform blazor the UI needs updating 129 | StateHasChanged(); 130 | } 131 | 132 | async Task DisconnectAsync() 133 | { 134 | if (chatting) 135 | { 136 | await client.StopAsync(); 137 | client = null; 138 | message = "chat ended"; 139 | chatting = false; 140 | } 141 | } 142 | 143 | async Task SendAsync() 144 | { 145 | if (chatting && !string.IsNullOrWhiteSpace(newMessage)) 146 | { 147 | // send message to hub 148 | await client.SendAsync(newMessage); 149 | // clear input box 150 | newMessage = ""; 151 | } 152 | } 153 | 154 | class Message 155 | { 156 | public Message(string username, string body, bool mine) 157 | { 158 | Username = username; 159 | Body = body; 160 | Mine = mine; 161 | } 162 | 163 | public string Username { get; set; } 164 | public string Body { get; set; } 165 | public bool Mine { get; set; } 166 | 167 | /// 168 | /// Determine CSS classes to use for message div 169 | /// 170 | public string CSS 171 | { 172 | get 173 | { 174 | return Mine ? "sent" : "received"; 175 | } 176 | } 177 | } 178 | 179 | } 180 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Pages/Index.razor.css: -------------------------------------------------------------------------------- 1 | /* css for index page */ 2 | 3 | textarea { 4 | border: 1px dashed #888; 5 | border-radius: 5px; 6 | width: 80%; 7 | overflow: auto; 8 | background: #f7f7f7 9 | } 10 | 11 | 12 | 13 | /* improved CSS for speech bubbles */ 14 | 15 | .received, .sent { 16 | position: relative; 17 | font-family: arial; 18 | font-size: 1.1em; 19 | border-radius: 10px; 20 | padding: 20px; 21 | margin-bottom: 20px; 22 | } 23 | 24 | .received:after, .sent:after { 25 | content: ''; 26 | border: 20px solid transparent; 27 | position: absolute; 28 | margin-top: -30px; 29 | } 30 | 31 | .sent { 32 | background: #03a9f4; 33 | color: #fff; 34 | margin-left: 10%; 35 | top: 50%; 36 | text-align: right; 37 | } 38 | 39 | .received { 40 | background: #4CAF50; 41 | color: #fff; 42 | margin-left: 10px; 43 | margin-right: 10%; 44 | } 45 | 46 | .sent:after { 47 | border-left-color: #03a9f4; 48 | border-right: 0; 49 | right: -20px; 50 | } 51 | 52 | .received:after { 53 | border-right-color: #4CAF50; 54 | border-left: 0; 55 | left: -20px; 56 | } 57 | 58 | /* div within bubble for name */ 59 | .user { 60 | font-size: 0.8em; 61 | font-weight: bold; 62 | color: #000; 63 | } 64 | 65 | .msg { 66 | /*display: inline;*/ 67 | } 68 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | 7 | namespace BlazorChatSample.Client 8 | { 9 | public static class Program 10 | { 11 | public static async Task Main(string[] args) 12 | { 13 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 14 | builder.RootComponents.Add("#app"); 15 | 16 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 17 | 18 | await builder.Build().RunAsync(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:6839/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BlazorChatSample.Client": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:6841/" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /BlazorChatSample.Client/Shared/Instructions.razor: -------------------------------------------------------------------------------- 1 | 

2 | This application demonstrates the use of SignalR 3 | to create a Blazor chat application. 4 |

5 | 6 |

7 | New The app now uses the Microsoft.AspNetCore.SignalR.Client 8 | library which is now compatible with the Mono WASM runtime. This really simplifies the ChatClient code. 9 |

10 |

11 | Previously this sample used JavaScript SignalR client. If you want to see how the JavaScript client version worked, I've retained 12 | it in this branch. 13 |

14 |
Demo
15 |

16 | A demo application is available at https://blazorchatsample.azurewebsites.net 17 |

18 |
Improvements & Suggestions
19 |

20 | If you have any improvements or suggestions please submit as issues/pull requests on the Github repo. 21 |

22 |
Acknowledgements
23 |

24 | Thanks to Code-Boxx for the article https://code-boxx.com/responsive-css-speech-bubbles/ that helped me create simple CSS speech bubbles that improve the layout 25 |

26 |

27 | Source code at Github. 28 |

29 | 30 |
-------------------------------------------------------------------------------- /BlazorChatSample.Client/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 | @Body 10 |
11 |
12 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | .main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 767.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 768px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .main > div { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 21 |
22 | 23 | @code { 24 | bool collapseNavMenu = true; 25 | 26 | void ToggleNavMenu() 27 | { 28 | collapseNavMenu = !collapseNavMenu; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 768px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Components.Forms 3 | @using Microsoft.AspNetCore.Components.Routing 4 | @using Microsoft.AspNetCore.Components.Web 5 | @using Microsoft.JSInterop 6 | @using BlazorChatSample.Client 7 | @using BlazorChatSample.Client.Shared -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conficient/BlazorChatSample/fde2c569e6f3646295a5d582cf31bbe6c1b36b6b/BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conficient/BlazorChatSample/fde2c569e6f3646295a5d582cf31bbe6c1b36b6b/BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conficient/BlazorChatSample/fde2c569e6f3646295a5d582cf31bbe6c1b36b6b/BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conficient/BlazorChatSample/fde2c569e6f3646295a5d582cf31bbe6c1b36b6b/BlazorChatSample.Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conficient/BlazorChatSample/fde2c569e6f3646295a5d582cf31bbe6c1b36b6b/BlazorChatSample.Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /BlazorChatSample.Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | BlazorChatSample 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /BlazorChatSample.ConsoleApp/BlazorChatSample.ConsoleApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /BlazorChatSample.ConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 | using BlazorChatSample.Shared; 2 | using Microsoft.AspNetCore.SignalR.Client; 3 | using System; 4 | using System.Threading.Tasks; 5 | 6 | namespace BlazorChatSample.ConsoleApp 7 | { 8 | class Program 9 | { 10 | /// 11 | /// Console app 12 | /// 13 | /// 14 | /// 15 | static async Task Main(string[] args) 16 | { 17 | // pause for 3 seconds to allow the web host to boot up 18 | Console.WriteLine("Starting App..."); 19 | try 20 | { 21 | string username; 22 | do 23 | { 24 | Console.WriteLine("Enter your name: "); 25 | username = Console.ReadLine(); 26 | } 27 | while (string.IsNullOrWhiteSpace(username)); 28 | 29 | // connect to host: the HTTPS version may not work on localhost as the local IIS cert isn't valid 30 | const string url = "http://localhost:6840"; 31 | var client = new ChatClient(username, url); 32 | 33 | // create a message received handler 34 | client.MessageReceived += Client_MessageReceived; 35 | 36 | await client.StartAsync(); 37 | bool exit = false; 38 | Console.WriteLine("Enter message, or 'exit' to quit"); 39 | do 40 | { 41 | var message = Console.ReadLine(); 42 | await client.SendAsync(message); 43 | 44 | // either Ctrl-C or type 'exit' to quit 45 | if (message?.ToLower() == "exit") 46 | exit = true; 47 | 48 | } while (!exit); 49 | 50 | Console.WriteLine("press any key to exit"); 51 | Console.ReadKey(); 52 | } 53 | catch (Exception e) 54 | { 55 | Console.WriteLine("ERROR: " + e.Message); 56 | } 57 | } 58 | 59 | 60 | private static void Client_MessageReceived(object sender, MessageReceivedEventArgs e) 61 | { 62 | Console.WriteLine($"[{e.Username}] {e.Message}"); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /BlazorChatSample.Server/BlazorChatSample.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | 6 | https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; 7 | https://dotnet.myget.org/F/blazor-dev/api/v3/index.json; 8 | 9 | latest 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /BlazorChatSample.Server/Hubs/ChatHub.cs: -------------------------------------------------------------------------------- 1 | using BlazorChatSample.Shared; 2 | using Microsoft.AspNetCore.SignalR; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace BlazorChatSample.Server.Hubs 10 | { 11 | /// 12 | /// The SignalR hub 13 | /// 14 | public class ChatHub : Hub 15 | { 16 | /// 17 | /// connectionId-to-username lookup 18 | /// 19 | /// 20 | /// Needs to be static as the chat is created dynamically a lot 21 | /// 22 | private static readonly Dictionary userLookup = new Dictionary(); 23 | 24 | /// 25 | /// Send a message to all clients 26 | /// 27 | /// 28 | /// 29 | /// 30 | public async Task SendMessage(string username, string message) 31 | { 32 | await Clients.All.SendAsync(Messages.RECEIVE, username, message); 33 | } 34 | 35 | /// 36 | /// Register username 37 | /// 38 | /// 39 | /// 40 | public async Task Register(string username) 41 | { 42 | var currentId = Context.ConnectionId; 43 | if (!userLookup.ContainsKey(currentId)) 44 | { 45 | // maintain a lookup of connectionId-to-username 46 | userLookup.Add(currentId, username); 47 | // re-use existing message for now 48 | await Clients.AllExcept(currentId).SendAsync( 49 | Messages.RECEIVE, 50 | username, $"{username} joined the chat"); 51 | } 52 | } 53 | 54 | /// 55 | /// Log connection 56 | /// 57 | /// 58 | public override Task OnConnectedAsync() 59 | { 60 | Console.WriteLine("Connected"); 61 | return base.OnConnectedAsync(); 62 | } 63 | 64 | /// 65 | /// Log disconnection 66 | /// 67 | /// 68 | /// 69 | public override async Task OnDisconnectedAsync(Exception e) 70 | { 71 | Console.WriteLine($"Disconnected {e?.Message} {Context.ConnectionId}"); 72 | // try to get connection 73 | string id = Context.ConnectionId; 74 | if (!userLookup.TryGetValue(id, out string username)) 75 | username = "[unknown]"; 76 | 77 | userLookup.Remove(id); 78 | await Clients.AllExcept(Context.ConnectionId).SendAsync( 79 | Messages.RECEIVE, 80 | username, $"{username} has left the chat"); 81 | await base.OnDisconnectedAsync(e); 82 | } 83 | 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /BlazorChatSample.Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 3 | using Microsoft.AspNetCore.Hosting; 4 | using Microsoft.Extensions.Configuration; 5 | 6 | namespace BlazorChatSample.Server 7 | { 8 | public static class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | BuildWebHost(args).Run(); 13 | } 14 | 15 | public static IWebHost BuildWebHost(string[] args) => 16 | WebHost.CreateDefaultBuilder(args) 17 | .UseConfiguration(new ConfigurationBuilder() 18 | .AddCommandLine(args) 19 | .Build()) 20 | .UseStartup() 21 | .Build(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /BlazorChatSample.Server/Properties/PublishProfiles/FolderProfile.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | FileSystem 9 | FileSystem 10 | Release 11 | Any CPU 12 | 13 | True 14 | False 15 | netcoreapp3.0 16 | win-x86 17 | 60b3a1f2-b3d2-491e-98cb-d15343d8384f 18 | true 19 | <_IsPortable>false 20 | bin\Debug\netcoreapp3.0\publish\ 21 | True 22 | 23 | -------------------------------------------------------------------------------- /BlazorChatSample.Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:6836/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BlazorChatSample.Server": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:6840/" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /BlazorChatSample.Server/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.ResponseCompression; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.FileProviders; 6 | using Microsoft.Extensions.Hosting; 7 | using Newtonsoft.Json.Serialization; 8 | using System.IO; 9 | using System.Linq; 10 | 11 | namespace BlazorChatSample.Server 12 | { 13 | public class Startup 14 | { 15 | // This method gets called by the runtime. Use this method to add services to the container. 16 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 17 | public void ConfigureServices(IServiceCollection services) 18 | { 19 | services.AddControllersWithViews(); 20 | 21 | // I think this was pre-Core3.x 22 | //services.AddMvc(); 23 | services.AddSignalR(); 24 | 25 | // not sure this is required any more 26 | //services.AddResponseCompression(opts => 27 | //{ 28 | // opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat( 29 | // new[] { "application/octet-stream" }); 30 | //}); 31 | } 32 | 33 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 34 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 35 | { 36 | if (env.IsDevelopment()) 37 | { 38 | app.UseDeveloperExceptionPage(); 39 | app.UseWebAssemblyDebugging(); 40 | } 41 | 42 | app.UseStaticFiles(); 43 | app.UseBlazorFrameworkFiles(); // preview2 change 44 | 45 | app.UseRouting(); 46 | 47 | app.UseEndpoints(endpoints => 48 | { 49 | endpoints.MapDefaultControllerRoute(); 50 | // SignalR endpoint routing setup 51 | endpoints.MapHub(Shared.ChatClient.HUBURL); 52 | 53 | endpoints.MapFallbackToFile("index.html"); // preview2 change 54 | }); 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /BlazorChatSample.Shared/BlazorChatSample.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /BlazorChatSample.Shared/ChatClient.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.SignalR.Client; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace BlazorChatSample.Shared 6 | { 7 | 8 | /// 9 | /// Generic client class that interfaces .NET Standard/Blazor with SignalR Javascript client 10 | /// 11 | public class ChatClient : IAsyncDisposable 12 | { 13 | public const string HUBURL = "/ChatHub"; 14 | 15 | private readonly string _hubUrl; 16 | private HubConnection _hubConnection; 17 | 18 | /// 19 | /// Ctor: create a new client for the given hub URL 20 | /// 21 | /// The base URL for the site, e.g. https://localhost:1234 22 | /// 23 | /// Changed client to accept just the base server URL so any client can use it, including ConsoleApp! 24 | /// 25 | public ChatClient(string username, string siteUrl) 26 | { 27 | // check inputs 28 | if (string.IsNullOrWhiteSpace(username)) 29 | throw new ArgumentNullException(nameof(username)); 30 | if (string.IsNullOrWhiteSpace(siteUrl)) 31 | throw new ArgumentNullException(nameof(siteUrl)); 32 | // save username 33 | _username = username; 34 | // set the hub URL 35 | _hubUrl = siteUrl.TrimEnd('/') + HUBURL; 36 | } 37 | 38 | /// 39 | /// Name of the chatter 40 | /// 41 | private readonly string _username; 42 | 43 | /// 44 | /// Flag to show if started 45 | /// 46 | private bool _started = false; 47 | 48 | /// 49 | /// Start the SignalR client 50 | /// 51 | public async Task StartAsync() 52 | { 53 | if (!_started) 54 | { 55 | // create the connection using the .NET SignalR client 56 | _hubConnection = new HubConnectionBuilder() 57 | .WithUrl(_hubUrl) 58 | .Build(); 59 | Console.WriteLine("ChatClient: calling Start()"); 60 | 61 | // add handler for receiving messages 62 | _hubConnection.On(Messages.RECEIVE, (user, message) => 63 | { 64 | HandleReceiveMessage(user, message); 65 | }); 66 | 67 | // start the connection 68 | await _hubConnection.StartAsync(); 69 | 70 | Console.WriteLine("ChatClient: Start returned"); 71 | _started = true; 72 | 73 | // register user on hub to let other clients know they've joined 74 | await _hubConnection.SendAsync(Messages.REGISTER, _username); 75 | } 76 | } 77 | 78 | /// 79 | /// Handle an inbound message from a hub 80 | /// 81 | /// event name 82 | /// message content 83 | private void HandleReceiveMessage(string username, string message) 84 | { 85 | // raise an event to subscribers 86 | MessageReceived?.Invoke(this, new MessageReceivedEventArgs(username, message)); 87 | } 88 | 89 | /// 90 | /// Event raised when this client receives a message 91 | /// 92 | /// 93 | /// Instance classes should subscribe to this event 94 | /// 95 | public event MessageReceivedEventHandler MessageReceived; 96 | 97 | /// 98 | /// Send a message to the hub 99 | /// 100 | /// message to send 101 | public async Task SendAsync(string message) 102 | { 103 | // check we are connected 104 | if (!_started) 105 | throw new InvalidOperationException("Client not started"); 106 | // send the message 107 | await _hubConnection.SendAsync(Messages.SEND, _username, message); 108 | } 109 | 110 | /// 111 | /// Stop the client (if started) 112 | /// 113 | public async Task StopAsync() 114 | { 115 | if (_started) 116 | { 117 | // disconnect the client 118 | await _hubConnection.StopAsync(); 119 | // There is a bug in the mono/SignalR client that does not 120 | // close connections even after stop/dispose 121 | // see https://github.com/mono/mono/issues/18628 122 | // this means the demo won't show "xxx left the chat" since 123 | // the connections are left open 124 | await _hubConnection.DisposeAsync(); 125 | _hubConnection = null; 126 | _started = false; 127 | } 128 | } 129 | 130 | public async ValueTask DisposeAsync() 131 | { 132 | Console.WriteLine("ChatClient: Disposing"); 133 | await StopAsync(); 134 | } 135 | } 136 | 137 | /// 138 | /// Delegate for the message handler 139 | /// 140 | /// the SignalRclient instance 141 | /// Event args 142 | public delegate void MessageReceivedEventHandler(object sender, MessageReceivedEventArgs e); 143 | 144 | /// 145 | /// Message received argument class 146 | /// 147 | public class MessageReceivedEventArgs : EventArgs 148 | { 149 | public MessageReceivedEventArgs(string username, string message) 150 | { 151 | Username = username; 152 | Message = message; 153 | } 154 | 155 | /// 156 | /// Name of the message/event 157 | /// 158 | public string Username { get; set; } 159 | 160 | /// 161 | /// Message data items 162 | /// 163 | public string Message { get; set; } 164 | 165 | } 166 | 167 | } 168 | 169 | -------------------------------------------------------------------------------- /BlazorChatSample.Shared/Messages.cs: -------------------------------------------------------------------------------- 1 | namespace BlazorChatSample.Shared 2 | { 3 | /// 4 | /// Stores shared names used in both client and hub 5 | /// 6 | public static class Messages 7 | { 8 | /// 9 | /// Event name when a message is received 10 | /// 11 | public const string RECEIVE = "ReceiveMessage"; 12 | 13 | /// 14 | /// Name of the Hub method to register a new user 15 | /// 16 | public const string REGISTER = "Register"; 17 | 18 | /// 19 | /// Name of the Hub method to send a message 20 | /// 21 | public const string SEND = "SendMessage"; 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /BlazorChatSample.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28822.285 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorChatSample.Server", "BlazorChatSample.Server\BlazorChatSample.Server.csproj", "{60B3A1F2-B3D2-491E-98CB-D15343D8384F}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorChatSample.Client", "BlazorChatSample.Client\BlazorChatSample.Client.csproj", "{21C1FE9F-16FB-4A1B-A06B-6EDA345C4F2D}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{DC59E8D8-30F7-493B-AC7D-5966AA67298A}" 11 | ProjectSection(SolutionItems) = preProject 12 | azure-pipelines.yml = azure-pipelines.yml 13 | README.md = README.md 14 | EndProjectSection 15 | EndProject 16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorChatSample.Shared", "BlazorChatSample.Shared\BlazorChatSample.Shared.csproj", "{D5007DB1-3CC9-4BD4-9E38-1499E953FE6D}" 17 | EndProject 18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorChatSample.ConsoleApp", "BlazorChatSample.ConsoleApp\BlazorChatSample.ConsoleApp.csproj", "{58A145AB-D772-4058-9E87-0BD237EEBDF7}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {60B3A1F2-B3D2-491E-98CB-D15343D8384F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {60B3A1F2-B3D2-491E-98CB-D15343D8384F}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {60B3A1F2-B3D2-491E-98CB-D15343D8384F}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {60B3A1F2-B3D2-491E-98CB-D15343D8384F}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {21C1FE9F-16FB-4A1B-A06B-6EDA345C4F2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {21C1FE9F-16FB-4A1B-A06B-6EDA345C4F2D}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {21C1FE9F-16FB-4A1B-A06B-6EDA345C4F2D}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {21C1FE9F-16FB-4A1B-A06B-6EDA345C4F2D}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {D5007DB1-3CC9-4BD4-9E38-1499E953FE6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {D5007DB1-3CC9-4BD4-9E38-1499E953FE6D}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {D5007DB1-3CC9-4BD4-9E38-1499E953FE6D}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {D5007DB1-3CC9-4BD4-9E38-1499E953FE6D}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {58A145AB-D772-4058-9E87-0BD237EEBDF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {58A145AB-D772-4058-9E87-0BD237EEBDF7}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {58A145AB-D772-4058-9E87-0BD237EEBDF7}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {58A145AB-D772-4058-9E87-0BD237EEBDF7}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityGlobals) = postSolution 47 | SolutionGuid = {554AC177-3E3F-4BB1-9F22-562E6BFDB33A} 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blazor Chat Sample 2 | 3 | [![Build Status](https://dev.azure.com/conficient/BlazorChatSample/_apis/build/status/conficient.BlazorChatSample?branchName=master)](https://dev.azure.com/conficient/BlazorChatSample/_build/latest?definitionId=2&branchName=master) 4 | 5 | > Now upgraded for [.NET 5 RTM](https://devblogs.microsoft.com/aspnet/announcing-asp-net-core-in-net-5/) - Please ensure you have the .NET 5 SDK loaded and VS 2019 v16.8 or later. 6 | > One change since the release candidates is that the scoped CSS is now `AppName.styles.css` in place of the `_framework/scoped.styles.css` 7 | 8 | This application demonstrates the use of [SignalR](https://www.asp.net/signalr) 9 | to create a [Blazor](https://blazor.net/) chat application. 10 | 11 | ### Now JavaScript-Free! 12 | 13 | The app now uses the `Microsoft.AspNetCore.SignalR.Client` 14 | library which is now compatible with the Mono WASM runtime. This really simplifies the 15 | `ChatClient` code. 16 | 17 | Previously this sample used JavaScript SignalR client. If you want to see how the JavaScript client version worked, I've retained 18 | it in [this branch](https://github.com/conficient/BlazorChatSample/tree/netcore-3.2.0-preview1) 19 | 20 | ## .NET 6 21 | 22 | Upgraded the demo to .NET 6. 23 | 24 | ## Demo 25 | 26 | A demo application is available at https://blazorchatsample.azurewebsites.net 27 | 28 | ### Improvements & Suggestions 29 | 30 | If you have any improvements or suggestions please submit as issues/pull requests on the Github repo. 31 | 32 | ### Acknowledgements 33 | 34 | Thanks to Code-Boxx for the article https://code-boxx.com/responsive-css-speech-bubbles/ 35 | that helped me create simple CSS speech bubbles that improve the layout. 36 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # ASP.NET Core 2 | # Build and test ASP.NET Core projects targeting .NET Core. 3 | # Add steps that run tests, create a NuGet package, deploy, and more: 4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core 5 | 6 | trigger: 7 | - main 8 | 9 | pool: 10 | vmImage: 'windows-latest' # publish needs to be win-x86 11 | 12 | variables: 13 | buildConfiguration: 'Release' 14 | 15 | steps: 16 | - task: UseDotNet@2 17 | displayName: 'Installing .NET Core SDK 6.0' 18 | inputs: 19 | packageType: 'sdk' 20 | version: '6.0.x' 21 | 22 | - task: DotNetCoreCLI@2 23 | displayName: 'Restore packages' 24 | inputs: 25 | command: 'restore' 26 | projects: 'BlazorChatSample.sln' 27 | feedsToUse: 'select' 28 | 29 | - task: DotNetCoreCLI@2 30 | displayName: 'Build' 31 | inputs: 32 | command: 'build' 33 | projects: 'BlazorChatSample.sln' 34 | arguments: '--configuration $(buildConfiguration) --no-restore' 35 | 36 | - task: DotNetCoreCLI@2 37 | displayName: 'publish' 38 | inputs: 39 | command: 'publish' 40 | arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory) --self-contained true --runtime win-x86 --no-build' 41 | 42 | - task: DotNetCoreCLI@2 43 | displayName: 'publish' 44 | inputs: 45 | command: 'publish' 46 | publishWebProjects: false 47 | projects: 'BlazorChatSample.Server\BlazorChatSample.Server.csproj' 48 | arguments: '--configuration $(BuildConfiguration) --output "$(build.artifactstagingdirectory)" --framework net6.0 --self-contained true --runtime win-x86' 49 | modifyOutputPath: false 50 | 51 | - task: PublishBuildArtifacts@1 52 | displayName: 'Publishing Build Artifacts...' 53 | --------------------------------------------------------------------------------