Tuesday 15 February 2011

c# - It's possible signalR client web to connect a server on a different PC? -


I have a console application that is a signal server on my PC.

I have html that is the signal r client on the internet but I try to connect to the server but I have a bad request 400 error. If the server is down, then I have another reponse.

Is it possible to signal signal clients to connect to a server on PC?

(Sorry for my English)

My page

  & lt; Input type = "text" id = "msg" value = "" /> & Lt; Input type = "button" id = "send" value = "send" /> & Lt; Ul id = "message" & gt; & Lt; / Ul & gt; & Lt; Script src = "scripts / jquery-1.6.4.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "scripts / jquery.signalR-1.1.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Open the connection to $ (function () {jQuery.support.cors = true; // remote connection var connection = $ .hubConnection ('http: // MyIpAddress: 8080'); var chat = connection.createHubProxy ('chat' '' Chat ', function (message) {$ (' # message '). APPEND ('   

My server code

  using Microsoft.Owin.Hosting; Using the system; Using System.IO; Using System.Net; Using System.Net.Sockets; // install-package Microsoft.Owin.Hosting -pre // install-package Microsoft.Owin.Host.HttpListener-former namespace test server (class program) {static zero main (string [] args) {LocalIPAddress (); String url = "http: // localhost: 8080"; (WebApplication.Start & lt; startup & gt; (url)) using {Console.WriteLine ("Server is running {0}", url); Console.ReadLine (); }}}}   

startup.cs

  using Microsoft.AspNet.SignalR; Use of ovine; Namespace Tester {public class startup {// This method is named Important Public Zero Configuration (IAppBuilder App) {var config = new HubConfiguration {EnableCrossDomain = true}; App.MapHubs (config); }}}   

chat.cs

  using Microsoft.AspNet.SignalR; Using the system; System usage threading. Task; Namespace Test Server Hobbs {Public class chat: hub {public override work on connect () {console. Videoline ("On-Connected" + Connection ID); Return basis.onconnect (); } Send Public Zero (String Message) {Console.WriteLine (string.Format ("Get: {0} by {0}", Message, Context.ConnectionId); Clients.All.send (message); What is this as the first line in your JS initial form:    

$ Connection.hub.url = "Your URL";

No comments:

Post a Comment