简体   繁体   English

在位于WCF服务内的集线器中连接SignalR

[英]Connect SignalR in a hub that is inside WCF service

hi currently using SignalR in my WebApplication. 嗨,目前在我的WebApplication中使用SignalR。 I have a problem regarding the connection of signalR to my hub this is my connection code this is located on the Main App 我有一个关于signalR连接到我的集线器的问题这是我的连接代码,它位于主应用程序上

 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? 这是一个单独的WCF服务,他们在同一个解决方案但不同的项目,我认为它没有连接是否可以将我的客户端连接到实现SignalR库的WCF服务?

Sure you can, they are living under different hosts so you'll have to adapt the Urls to point at the right place. 当然可以,他们生活在不同的主人之下,所以你必须让Urls适应正确的位置。 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. 您可以 这里查看更多详情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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