An open API service indexing awesome lists of open source software.

https://github.com/hazzik/signalrwindsorfacility

SignalR Windsor Facility
https://github.com/hazzik/signalrwindsorfacility

Last synced: 2 months ago
JSON representation

SignalR Windsor Facility

Awesome Lists containing this project

README

        

# SignalRWindsorFacility

SignalRWindsorFacility adds ability to call client side services just with injected interface

## Why?

1. It is testable. You are using these interfaces as any normal .NET interface
2. It supports intellisense

## Example

1. Define contract for client-side service

```csharp
public interface IChat
{
void AddMessage(string msg);
}
```

2. Register `IChat` as client-side service associated with `ChatHub`

```csharp
public class DefaultInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility();

container.Register(
Component.For().AsClientService().WithHub());
}
}
```

3. Write your client-side logic

```js
(function ($) {
$.extend($.connection.chatHub.client, {
addMessage: function(msg) {
alert(msg);
}
});
$.connection.hub.start();
})(jQuery);
```

4. Inject `IChat` anywhere and call its methods as normal

```csharp
public class HomeController : Controller
{
readonly IChat chat;

public HomeController(IChat chat)
{
this.chat = chat;
}

public ActionResult Index()
{
chat.AddMessage("Hello");

return View();
}
}
```