简体   繁体   中英

Connect SignalR in a hub that is inside WCF service

hi currently using SignalR in my WebApplication. I have a problem regarding the connection of signalR to my hub this is my connection code this is located on the Main App

 var chat = $.connection.sampleHub;

while this is my hub

using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SampleService
{
    public class SampleHub : Hub
    {
        public void Send(string name, string message)
        {
            //Update All the Clients Connected
            Clients.All.addNewMessageToPage(name, message);
        }
    }
}

this is located in a seperate WCF service they are on the same solution but different project i think its not connecting is it possible to connect my Client into the WCF service which is implementing the SignalR Library?

Sure you can, they are living under different hosts so you'll have to adapt the Urls to point at the right place. You will need to use an absolute address to the server where needed (like when referencing dynamic hubs), and to handle cross-domain requests. You can check here and here for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM