0
votes

Here is my wcfService code -

 public class SystemService : ISystemService
{
    private IHubContext hubContext;
    public SystemService()
    {
       hubContext = GlobalHost.ConnectionManager.GetHubContext<WebApplication1.MyHub1>();    
    } 

    public void SendMessage(string sender, string message)
    {
        hubContext.Clients.All.SendMessage(sender, message);  
    }
}

My web application with signalR hub is working fine.

    namespace WebApplication1
{
    [HubName("myHub1")]
    public class MyHub1 : Hub
    {
        public void SendMessage(string name, string message)
        {
            // Call the broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message);

        }

    }
}

Only the messages from wcf client are not received. No error messages in tracelog. If possible can anyone advice what I am missing here. please ask if any other details needed.

1
I have researched already on stack overflow and other forums.. Didnt got anything to resolve my issue(specific this issue)Usha phulwani

1 Answers

0
votes

Changed the code to generate a proxy. And working now.

 public class SystemService : ISystemService
{
    private readonly IHubProxy proxy;
   // private IHubContext hubContext;
    public SystemService()
    {

       var con = new HubConnection("http://localhost:53098/");
        proxy = con.CreateHubProxy("myHub1");
        con.Start().Wait();
    } 

    public void SendMessage(string sender, string message)
    {
        proxy.Invoke("SendMessage", sender, message);
        //hubContext.Clients.All.SendMessage(sender, message);  
    }
}

But shocking, I was first trying with this method only but it didnt worked earlier.. So I tried with IhubContext as above in my question.