AppForm.HubController 0.2.6

dotnet add package AppForm.HubController --version 0.2.6
NuGet\Install-Package AppForm.HubController -Version 0.2.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AppForm.HubController" Version="0.2.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AppForm.HubController --version 0.2.6
#r "nuget: AppForm.HubController, 0.2.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AppForm.HubController as a Cake Addin
#addin nuget:?package=AppForm.HubController&version=0.2.6

// Install AppForm.HubController as a Cake Tool
#tool nuget:?package=AppForm.HubController&version=0.2.6

AppForm.HubController

The Hub Controller is an implementation of a MVC style controller pattern that you're probably familiar with for the SignlaR Hub. It makes managing socket commands much simpler when dealing with large or small projects. With the HubController you are now able to quickly and easily separate out the handling of your individual commands into their own logical controllers.

Get Started

Server Side

Getting started is quite simple. First you will want to edit your Startup.cs file to include the following.

public void ConfigureServices(IServiceCollection services)
{
  ...
  
  services.UseHubRouter();
  
  ...
}

Next create a new class that inherits from the BaseHubController class. This uses the full dependency injection chain under the hood so feel free to include any required services you need.

public class DemoHubController : BaseHubController
{
  private readonly MyService _myService;

  public DemoHubController(MyService myService)
  {
  	_myService = myService;
  }

  public async Task<List<string>> GetNames()
  {
  	return await _myService.GetNames();
  }
}

Lastly we will need to modify at least one SignalR Hub to enable it to use our new HubController. To do this, simply inherit from the AppFormHub class instead of the base SignalR Hub class.

public class AppHub : AppFormHub
{
	...
}
Client Side (Javascript)

See the AppForm.HubController Client Documentation.

Summary

Your new controller method can now be called by simply calling a single method client side now using async / promises. No more callback waiting management.

hubConnection.execute('demo/getNames')
  .then(result => {
    console.log('success!', result);
  })
  .catch(error => {
    console.error('uh oh!', error);
  });

or

var result = await hubConnection.execute('demo/getNames');
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.2.6 655 12/31/2019
0.2.5 568 12/31/2019
0.2.4 565 12/31/2019
0.2.3 564 12/31/2019
0.2.2 582 12/31/2019
0.2.1 605 12/31/2019
0.2.0 540 12/27/2019
0.1.0 464 12/27/2019

Initial release.