Skip to content

adoconnection/TudaSuda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TudaSuda

C# SignalR Command/Reply framework

Its like controllers for websockets

Imagine you call this JS code on client side:

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:

[TudaSudaCommand(Route = "App/Organization/Sessions/List")]
public class List : AppCommandProcessor
{
    public List(InfraredEntities entities, TudaSudaTransmitter<InfraredAppHub> 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

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!

About

C# SignalR Command/Response framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages