loading... Pacem JS

SignalR Hub-Proxy

Handles the connection and communication with a SignalR Hub.
May wrap many <pacem-hub-listener> elements, these handle specific message types pushed by the hub.

// server-side C# code (SignalR Hub)
public class DummyHub : Hub
{
    [HubMethodName("methodJ")]
    public async Task Send(params string[] args)
    {
        string sender = Context.User.Identity.Name;
        await Clients.All.SendAsync("event1", sender, args[0]);
        // ...
        await Clients.All.SendAsync("eventN", sender, args[args.Length-1]);
    }
}
<!-- HTML markup sample (receiving) -->
<pacem-hub-proxy id="hub" url="/hub-endpoint">
    <pacem-hub-listener method="event1" on-receive="<do-something>"></pacem-hub-listener>
    ...
    <pacem-hub-listener method="eventN" on-receive="<do-something-else>"></pacem-hub-listener>
</pacem-hub-proxy>
<!-- HTML markup sample (sending) -->
<pacem-button on-click="#hub.send('methodJ', 'arg1', 'arg2', ..., 'argN')"></pacem-button>

Demo

Here's a working DEMO: any user gets anonymously logged while joining, leaving or posting something, while you only get the exact feedback of what you posted.