https://github.com/hazzik/signalrwindsorfacility
SignalR Windsor Facility
https://github.com/hazzik/signalrwindsorfacility
Last synced: 2 months ago
JSON representation
SignalR Windsor Facility
- Host: GitHub
- URL: https://github.com/hazzik/signalrwindsorfacility
- Owner: hazzik
- Created: 2012-11-22T10:17:45.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-11-22T11:13:26.000Z (over 12 years ago)
- Last Synced: 2025-02-02T22:38:08.278Z (4 months ago)
- Language: JavaScript
- Size: 629 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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();
}
}
```