Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all I want to thank you for your code above. It helped me a lot!</p> <p>Starting from your code I have created a solution where Nancy &amp; SignalR runs on the same port inside Owin.</p> <p>The console application code is this</p> <pre><code>using System; using Microsoft.AspNet.SignalR; using Microsoft.Owin.Hosting; using Nancy; using Owin; namespace NancySignalrOwin { class Program { static void Main(string[] args) { var url = "http://localhost:8080"; using (WebApp.Start&lt;Startup&gt;(url)) { Console.WriteLine("Running on http://localhost:8080", url); Console.WriteLine("Press enter to exit"); Console.ReadLine(); } } } public class Startup { public void Configuration(IAppBuilder app) { app.MapSignalR(); app.UseNancy(); } } public class MyHub : Hub { public void Send(string name, string message) { Console.WriteLine("{0} said {1}", name, message); Clients.All.addMessage(name, message); } } public class HomeModule : NancyModule { public HomeModule() { Get["/"] = x =&gt; { return View["index"]; }; } } } </code></pre> <p>and the view is this</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;SignalR Simple Chat&lt;/title&gt; &lt;style type="text/css"&gt; .container { background-color: #99CCFF; border: thick solid #808080; padding: 20px; margin: 20px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;input type="text" id="message" /&gt; &lt;input type="button" id="sendmessage" value="Send" /&gt; &lt;input type="hidden" id="displayname" /&gt; &lt;ul id="discussion"&gt;&lt;/ul&gt; &lt;/div&gt; &lt;!--Script references. --&gt; &lt;!--Reference the jQuery library. --&gt; &lt;script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"&gt;&lt;/script&gt; &lt;!--Reference the SignalR library. --&gt; &lt;script src="/Content/jquery.signalR-2.0.0-rc1.min.js"&gt;&lt;/script&gt; &lt;!--Reference the autogenerated SignalR hub script. --&gt; &lt;script src="/signalr/hubs"&gt;&lt;/script&gt; &lt;!--Add script to update the page and send messages.--&gt; &lt;script type="text/javascript"&gt; $(function () { // Declare a proxy to reference the hub. var chat = $.connection.myHub; // Create a function that the hub can call to broadcast messages. chat.client.addMessage = function (name, message) { // Html encode display name and message. var encodedName = $('&lt;div /&gt;').text(name).html(); var encodedMsg = $('&lt;div /&gt;').text(message).html(); // Add the message to the page. $('#discussion').append('&lt;li&gt;&lt;strong&gt;' + encodedName + '&lt;/strong&gt;:&amp;nbsp;&amp;nbsp;' + encodedMsg + '&lt;/li&gt;'); }; // Get the user name and store it to prepend to messages. $('#displayname').val(prompt('Enter your name:', '')); // Set initial focus to message input box. $('#message').focus(); // Start the connection. $.connection.hub.start().done(function () { $('#sendmessage').click(function () { // Call the Send method on the hub. chat.server.send($('#displayname').val(), $('#message').val()); // Clear text box and reset focus for next comment. $('#message').val('').focus(); }); }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload