Self host SignalR with Cross domain ASP.Net Client callback fail

arkrathluque

New Member
I have a WPF application which use SignalR to achieve publish/subscribe model.When I used a WPF client to connect to the above application, the publish and callback worked successfully.Then I created a ASP.Net client. I use a cross domain property of SignalR to connect to above WPF application.It could connect to the application and call the method provided in the hub successfully.However, when the WPF application call the method in the ASP.Net Client, it seems that that call cannot be reached to the client browser (viewed in Firefox, the long polling does not return; break point cannot be reached even I have set the break point in the javascript callback function, and nothing could be displayed in the broswer).I have included the following script in html\[code\]<script src="http://stackoverflow.com/questions/14597723/@Url.Content("~/Scripts/jquery-1.6.4.min.js")" type="text/javascript</script><script src="http://stackoverflow.com/Scripts/jquery.signalR-1.0.0-rc2.min.js" type="text/javascript"></script><script src="http://localhost:9999/signalr/hubs" type="text/javascript"></script>\[/code\]The following is the javascript that I have used.\[code\]jQuery.support.cors = true; myHub = $.connection.subscriberHub; myHub.client.addMessage = function (msg, time) { $("#message").prepend("<div>" + time + " " + msg + "</div>"); }; $.connection.hub.url = 'http://localhost:9999/signalr'; $.connection.hub.start();\[/code\]The below is the server code in the WPF application:\[code\]public partial class App : Application{ private IDisposable app; private void Application_Startup(object sender, StartupEventArgs e) { string url = "http://localhost:9999"; app = WebApplication.Start<Startup>(url); } private void Application_Exit(object sender, ExitEventArgs e) { if (app != null) { app.Dispose(); } }}class Startup{ public void Configuration(IAppBuilder app) { app.MapHubs(); }}\[/code\]And I send the message when the WPF application clicked a button:\[code\]private void btn_sendMsg_Click(object sender, RoutedEventArgs e) { var context = GlobalHost.ConnectionManager.GetHubContext<SubscriberHub>(); DateTime sentTime = DateTime.Now; context.Clients.Group("subscriber").addMessage(tb_message.Text, sentTime); MessageList.Insert(0,string.Format("{0:yyyy-MM-dd HH:mm:ss} {1}", sentTime, tb_message.Text)); }\[/code\]The following is the hub that I have defined:\[code\]public class SubscriberHub : Hub{ string group = "subscriber"; public Task Subscribe() { return Groups.Add(Context.ConnectionId, group); } public Task Unsubscribe() { return Groups.Remove(Context.ConnectionId, group); }}\[/code\]Is there any problem in the above code?
 
Back
Top