Skip to content

Commit 2225b37

Browse files
authored
Merge pull request #10 from gourav-d/redesign-ui-getmdl
Redesign ui getmdl
2 parents ba7a723 + 9a96a35 commit 2225b37

40 files changed

+13543
-317
lines changed

README.md

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
SignalR-Web-Client
1+
SignalR-Web-Client
22
======================
3-
This is a JavaScript based SignalR Web Client.
3+
This is a JavaScript-based SignalR Web Client.
44

5-
It is a debugging tool to test ASP.Net Core SignalR hubs. This is a UI based SignalR client. Using this tool, we can send the data to the SignalR hub and receive the response from the SignalR Hub. This tool is design for dotnetcore developer to make their life easier when they will work with SignalR.
5+
It is a debugging tool to test ASP.Net Core SignalR hubs. This is a UI based SignalR client. Using this tool, we can send the data to the SignalR hub and receive a response from the SignalR Hub. This tool is designed for DotNet core developers to make their life easier when they will work with SignalR.
66

77
<p align="center">
88
<img src="./src/images/SignalR-Web-Client.jpg" >
99
<br>
1010
</p>
1111

12+
<div align="center" style="width: 1000px; height: 600px;">
13+
<img src="./src/images/Basic_View.gif" width="100%" height="100%">
14+
</div>
15+
1216
*Table of Contents*
1317

1418

@@ -23,43 +27,44 @@ It is a debugging tool to test ASP.Net Core SignalR hubs. This is a UI based Sig
2327
- [Data Type supports:](#data-type-supports)
2428
- [Advance View](#advance-view)
2529
- [Reporting Issues](#reporting-issues)
26-
- [How to integrate?](#how-to-integrate)
30+
- [Samples](#samples)
2731
- [Technologies](#technologies)
2832
- [Browser Support](#browser-support)
2933
- [License](#license)
3034

3135

3236
# Prior Knowledge:
3337

34-
Before using this tool, you should be know about:
38+
Before using this tool, you should know about:
3539

3640
- [What is Asp.Net Core?](https://dotnet.microsoft.com/learn/aspnet/what-is-aspnet-core)
3741
- [What is SignalR in Asp.Net Core?](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-3.0)
3842

3943
# Prerequisite
4044

4145
- Node.Js
46+
-
4247
- Npm
4348
- Git
4449

4550
# Install
4651

4752
SignalR Web Client is available [here](https://gourav-d.github.io/SignalR-Web-Client/dist/).
4853

49-
To setup in local enviornment:
54+
To set up in local environment:
5055

5156
1. Clone repository.<br/>
5257
Open cmd and run the below command:
5358
```
5459
git clone "https://github.com/gourav-d/SignalR-Web-Client.git"
5560
```
56-
2. Once the cloning is completed, go to "SignalR-Web-Client" folder.
61+
2. Once the cloning is completed, go to the "SignalR-Web-Client" folder.
5762
```
5863
cd SignalR-Web-Client
5964
```
60-
3. The **tool need to be run under some server**. This is one of the requirement of SignalR library. So, if you already have a running server, then copy the content of "SignalR-Web-Client\dist" folder and put it on your server.<br/>
61-
If you don't have server or wants to run the tool in different server, no worry.<br/>
62-
Will tell you two approches to run this tool.
65+
3. The **tool needs to be run under some server**. This is one of the requirements of the SignalR library. So, if you already have a running server, then copy the content of "SignalR-Web-Client\dist" folder and put it on your server.<br/>
66+
If you don't have a server or wants to run the tool in a different server, no worry.<br/>
67+
Will tell you two approaches to run this tool.
6368
1. ***Using http server(npm)*** <br/>
6469
Here, we will install http-server and then we will host SignalR Web Client(published files) using this server.<br/>
6570
```
@@ -81,7 +86,7 @@ To setup in local enviornment:
8186
8287
2. ***Using Webpack Dev Server*** <br/>
8388
Here, we will not use the published files. Instead, we will build the tool and then run under the webpack dev server.<br/>
84-
*NOTE*:: If you wants to customize the tool, then you can you this approch.
89+
*NOTE*:: If you want to customize the tool, then you can you this approach.
8590
```
8691
npm install
8792
npm run dev
@@ -94,11 +99,11 @@ To setup in local enviornment:
9499
i 「wds」: Project is running at http://localhost:8080/
95100
i 「wds」: webpack output is served from /
96101
```
97-
4. This step is required if SignalR Web client and Hub server hosted seperately.<br/>
98-
ex: Hub Server is running on : http://localhost:5001 and <br/>
99-
SignalR Web client is running on : http://localhost:6001<br/>
102+
4. This step is required if SignalR Web client and Hub server hosted separately.<br/>
103+
ex: Hub Server is running on http://localhost:5001 and <br/>
104+
SignalR Web client is running on : http://localhost:8080<br/>
100105
101-
In such case, we have to inform the Hub Server, that allow SignalR Web Client (http://localhost:6001) origin.
106+
In such a case, we have to inform the Hub Server, that allows SignalR Web Client (http://localhost:8080) origin.
102107
103108
```
104109
Startup.cs
@@ -111,52 +116,59 @@ To setup in local enviornment:
111116
.AllowAnyMethod()
112117
.AllowAnyHeader()
113118
.AllowCredentials()
114-
.WithOrigins("http://localhost:6001");//SignalR Web Client Url
119+
.WithOrigins("http://localhost:8080"); //SignalR Web Client Url
115120
}));
116121
117122
...
118123
}
119124
125+
##refer this file
120126
```
121127
122128
# How it works?
123129
124-
SignalR Web Client have two views:
130+
SignalR Web Client has two views:
125131
1. Basic
126132
- Send data to Hub
127-
- Listen the hub broadcast messages
133+
- Listen to the hub broadcast messages
128134
2. Advance
129135
- Send data to Hub
130-
- Listen the hub broadcast messages
131-
- Support token based authentication
132-
- Support multiple transport type (like *WebSocket, Long Pooling, Server Send Event*)
136+
- Listen to the hub broadcast messages
137+
- Support token-based authentication
138+
- Support multiple transport type (like *WebSocket, Long Polling, Server Send Event*)
139+
- Skip Negotiation, this feature only supported when the WebSockets transport is the only enabled transport. This setting can't be enabled when using the Azure SignalR Service.
133140
134-
### Baisc View
141+
### Basic View
142+
143+
144+
<div align="center" style="width: 1000px; height: 600px;">
145+
<img src="./src/images/Basic_View_Json_Param.gif" width="100%" height="100%">
146+
</div>
135147
136148
137149
1. Provide the valid hub url in *Hub Address* textbox.(for ex. https://localhost:5001/Test/OneHub).<br/><br/>
138-
<img src="./src/images/1.PNG" width="600px" height="400px" />
150+
<!-- <img src="./src/images/1.PNG" width="600px" height="400px" /> -->
139151
140-
1. Once click on connect button, it will make connection with server. Once the connection is established, if any data is broadcast from the Hub(ex. OneHub) to all the client then, it will be displayed in the response payload section.
152+
1. Click on the connect button, it will try to connect with the server. Once the connection is established, if any data is broadcast from the Hub(ex. SampleHub) to all the client then, it will be displayed in the response payload section.
141153
142-
2. If we want to call any Hub method. For exmaple TesCall method
154+
2. If we want to call any Hub method. For example SendMessage method
143155
```csharp
144-
public class OneHub : Hub
156+
public class SampleHub : Hub
145157
{
146-
public async Task TestCall(string data)
158+
public async Task SendMessage(string data)
147159
{
148160
var connectionId = Context.ConnectionId;
149-
await Clients.Client(connectionId).SendAsync("ReceiveData", $"Data Received from TestCall method: {data}");
161+
await Clients.Client(connectionId).SendAsync("ReceiveData", $"Data Received from SendMessage method: {data}");
150162
}
151163
}
152164
```
153165
In the tool, we have to pass the parameter.
154166

155167
#### Server Method:
156-
TestCall
168+
SendMessage
157169

158170
#### Request Payload:
159-
It can take multiple parameters. In our example, TestCall method only taking one parameter of type string.
171+
It can take multiple parameters. In our example, SendMessage method only takes one parameter of type string.
160172
ex. TestCall(string data)
161173
162174
Argument textbox : Hello
@@ -167,18 +179,20 @@ In the tool, we have to pass the parameter.
167179

168180
<img src="./src/images/5.PNG" width="300px" height="300px" />
169181

170-
Then click on send button. It will send all the data to the hub.
182+
Then click on the send button. It will send all the data to the hub.
171183

172-
<img src="./src/images/3.PNG" />
184+
<!-- <img src="./src/images/3.PNG" /> -->
173185

174186
### Advance View
175187

176-
It has all the functionality which basic view provides, also it has additional features:
177-
- Authentication Header -> We can you this, when Hub is protected using token based authentication.
178-
- Transport Type ([To know more about SignalR Transport](https://kevgriffin.com/signalr-transports-explained/)) -> WebSocket, Long Pooling, Server Send Event
188+
It has all the functionality which basic view provides, also it has additional features like:
189+
- Authentication Header -> We can you this when Hub is protected using token-based authentication.
190+
- Transport Type ([To know more about SignalR Transport](https://kevgriffin.com/signalr-transports-explained/)) -> WebSocket, Long Polling, Server Send Event
179191

180192

181-
<img src="./src/images/2.PNG" />
193+
<div align="center" style="width: 1000px; height: 600px;">
194+
<img src="./src/images/Advance_Token.gif" width="100%" height="100%">
195+
</div>
182196

183197

184198
### Reporting Issues
@@ -190,13 +204,8 @@ Nothing is perfect.
190204
Then, just open a [new clear and descriptive issue](../../issues/new).
191205

192206

193-
## How to integrate?
194-
195-
1. Create a new project.
196-
File -> New -> Project -> Select "ASP.NET Core Web Application"
207+
## Samples
197208

198-
2. Now we have to create hub.
199-
- Create a folder "Hubs". Inside that folder, create a file called "TestHub.cs".
200209

201210

202211

@@ -208,7 +217,7 @@ Then, just open a [new clear and descriptive issue](../../issues/new).
208217
- WebComponentsJs 2.2.10
209218

210219
# Browser Support
211-
Currently, it supports only chrome browser.
220+
Currently, it supports only the chrome browser.
212221

213222
# License
214223

@@ -217,4 +226,4 @@ Currently, it supports only chrome browser.
217226
---
218227
Copyright &copy; 2020,
219228
Created by [Gourav Dwivedi](https://github.com/gourav-d).
220-
Released under the terms of the [MIT license](https://github.com/gourav-d/SignalR-Web-Client/blob/master/LICENSE).
229+
Released under the terms of the [MIT license](https://github.com/gourav-d/SignalR-Web-Client/blob/master/LICENSE).

Samples/AspDotCore/WebApp/WebApp/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using Microsoft.AspNetCore.Mvc;
2-
using Microsoft.AspNetCore.SignalR;
32
using System.Diagnostics;
4-
using System.Threading.Tasks;
5-
using WebApp.Hubs;
63
using WebApp.Models;
74

85
namespace WebApp.Controllers

Samples/AspDotCore/WebApp/WebApp/Controllers/LoginController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ public LoginController(IConfiguration config)
2121
}
2222

2323
[AllowAnonymous]
24-
[HttpPost]
25-
public IActionResult Login([FromBody]UserModel login)
24+
[HttpGet("~/GetToken")]
25+
public IActionResult GetToken(string username, string password)
2626
{
27+
var login = new UserModel{ Username = username, Password = password };
2728
IActionResult response = Unauthorized();
2829
var user = AuthenticateUser(login);
2930

@@ -61,7 +62,7 @@ private UserModel AuthenticateUser(UserModel login)
6162
{
6263
UserModel user = null;
6364

64-
if (login.Username == "Test" && login.Password == "Abc@123")
65+
if (login.Username == "admin" && login.Password == "admin")
6566
{
6667
user = new UserModel { Username = "Test", EmailAddress = "test@test.com" };
6768
}

Samples/AspDotCore/WebApp/WebApp/Controllers/NotificationController.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ public NotificationController(IHubContext<SampleHub> hubContext)
1515
}
1616

1717
[HttpGet]
18-
public async Task<IActionResult> TestSRClient(string message)
18+
public IActionResult Send(string message)
1919
{
20-
await _hubContext.Clients.All.SendAsync("ReceiveData", $"This message has been sent from Controller. Here is you message - {message}");
20+
var task = Task.Run(async() =>
21+
{
22+
for (int i = 0; i < 5; i++)
23+
{
24+
await _hubContext.Clients.All.SendAsync("ReceiveData", $"This message has been sent from Web API. Here is your message - {message}");
25+
await Task.Delay(1500);
26+
}
27+
});
2128
return new JsonResult($"Message has been sent to all the clients");
2229
}
2330
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Http;
6+
using Microsoft.AspNetCore.Mvc;
7+
8+
namespace WebApp.Controllers
9+
{
10+
[Route("api/[controller]")]
11+
[ApiController]
12+
public class TestController : ControllerBase
13+
{
14+
// GET: api/Test
15+
[HttpGet]
16+
public IEnumerable<string> Get()
17+
{
18+
return new string[] { "value1", "value2" };
19+
}
20+
21+
// GET: api/Test/5
22+
[HttpGet("{id}", Name = "Get")]
23+
public IActionResult Get(int id)
24+
{
25+
return Ok("value");
26+
}
27+
28+
// POST: api/Test
29+
[HttpPost]
30+
public IActionResult Post([FromBody] string value)
31+
{
32+
return Ok($"Deleted {value}");
33+
}
34+
35+
// PUT: api/Test/5
36+
[HttpPut("{id}")]
37+
public IActionResult Put(int id, [FromBody] string value)
38+
{
39+
return Ok($"Put {id}, {value}");
40+
}
41+
42+
// DELETE: api/ApiWithActions/5
43+
[HttpDelete("{id}")]
44+
public IActionResult Delete(int id)
45+
{
46+
return Ok($"Deleted {id}");
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)