Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class BaseService<TMessage> : Hub
- {
- private readonly IHubContext _hub;
- public BaseService()
- {
- _hub = (IHubContext) GlobalHost.ConnectionManager
- .GetType()
- .GetMethod("GetHubContext", new Type[0])
- .MakeGenericMethod(GetType())
- .Invoke(GlobalHost.ConnectionManager, new object[0]);
- }
- public void Send(TMessage message)
- {
- _hub.Clients.All.Receive(message);
- }
- }
- ["Service"]
- public class Service : BaseService<char>, IService<char>
- {
- }
- var hubConnection = new HubConnection("http://localhost:7800/myservice");
- _hubProxy = hubConnection.CreateHubProxy("Service");
- hubConnection.CreateHubProxy(typeof(IService<T>).ToString());
- this.HubName = this.GetType().ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement