https://github.com/adoconnection/tudasuda
C# SignalR Command/Response framework
https://github.com/adoconnection/tudasuda
Last synced: over 1 year ago
JSON representation
C# SignalR Command/Response framework
- Host: GitHub
- URL: https://github.com/adoconnection/tudasuda
- Owner: adoconnection
- License: mit
- Created: 2018-07-17T05:49:21.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T09:40:46.000Z (over 3 years ago)
- Last Synced: 2023-08-06T04:09:15.632Z (almost 3 years ago)
- Language: C#
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TudaSuda
C# SignalR Command/Reply framework
Its like controllers for websockets
Imagine you call this JS code on client side:
```javascript
uplink.send({
name: 'App/Organization/Sessions/List',
data:
{
organizationGuid: $stateParams.organizationGuid
}
});
uplink.on('App/Organization/Sessions/List', function(data, commandGuid) {
$scope.sessions = data;
});
```
Process it on server like this:
```cs
[TudaSudaCommand(Route = "App/Organization/Sessions/List")]
public class List : AppCommandProcessor
{
public List(InfraredEntities entities, TudaSudaTransmitter appHubTransmitter) : base(entities, appHubTransmitter)
{
}
protected override Task Process(AppCommandArgs message)
{
Guid? organizationGuid = message?.Data?.organizationGuid;
return this.TransmitConnection(
"App/Organization/Sessions/List",
this.Entities.Sessions
.Where(s => s.OrganizationGuid == organizationGuid)
.Select(SessionFormatter.Details)
.ToList()
);
}
}
```
with just a few lines of config
```cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddTudaSuda();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseTudaSuda();
}
}
```
Isn't it great?
Now you can!