Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public abstract class BaseService<TMessage> : Hub
  2. {
  3. private readonly IHubContext _hub;
  4.  
  5. public BaseService()
  6. {
  7. _hub = (IHubContext) GlobalHost.ConnectionManager
  8. .GetType()
  9. .GetMethod("GetHubContext", new Type[0])
  10. .MakeGenericMethod(GetType())
  11. .Invoke(GlobalHost.ConnectionManager, new object[0]);
  12. }
  13.  
  14. public void Send(TMessage message)
  15. {
  16. _hub.Clients.All.Receive(message);
  17. }
  18. }
  19.  
  20. ["Service"]
  21. public class Service : BaseService<char>, IService<char>
  22. {
  23. }
  24.  
  25. var hubConnection = new HubConnection("http://localhost:7800/myservice");
  26. _hubProxy = hubConnection.CreateHubProxy("Service");
  27.  
  28. hubConnection.CreateHubProxy(typeof(IService<T>).ToString());
  29.  
  30. this.HubName = this.GetType().ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement