Created
April 10, 2013 20:09
-
-
Save Buildstarted/5358003 to your computer and use it in GitHub Desktop.
Sample chat whatever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace MvcApplication1.Controllers | |
| { | |
| using Microsoft.AspNet.SignalR; | |
| public class Chat : Hub | |
| { | |
| public void SendMessage(string text) | |
| { | |
| Clients.All.sendMessage(text); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title></title> | |
| <script type="text/javascript" src="/Scripts/jquery-1.9.1.min.js"></script> | |
| <script type="text/javascript" src="/Scripts/jquery.signalR-1.0.1.min.js"></script> | |
| <script type="text/javascript" src="/signalr/hubs"></script> | |
| <script type="text/javascript"> | |
| (function($) { | |
| var chat = $.connection.chat; | |
| chat.client.sendMessage = function(message) { | |
| console.log(message); | |
| }; | |
| $.connection.hub.start() | |
| .done(function() { | |
| chat.server.sendMessage("hello"); | |
| }); | |
| })(jQuery) | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment