SIGNALR Communication Technology

Source: Internet
Author: User

New MVC Project

If there is no signale need to use NuGet installation SIGNALR

namespace signalrdemo{    publicclass  chathub:hub    {        publicvoid Send (string name,string  message)        {            Clients.All.broadcastMessage (name, message);     }}}
"Viewport"Content="Width=device-width"/> <title> Temporary chat tools </title> <script src="~/scripts/jquery-1.10.2.js"></script> <script src="~/scripts/jquery.signalr-2.0.0.js"></script> <script src="signalr/hubs"Type="Text/javascript"></script> <script type="Text/javascript">$ (function () {//define a proxy to refer to the Hub            varChat =$.connection.chathub; //The hub class on the server calls this function to push the content and update to each client "receive messages from the background, and then add them to the panel"Chat.client.broadcastMessage =function (name, message) {varEncodedname = $ ('<div/>'). Text (name). HTML (); varEncodedmsg = $ ('<div/>'). Text (message). HTML (); $('#discussion'). Append ('<li><strong>'+Encodedname+'</strong>:&nbsp;&nbsp;'+ encodedmsg +'</li>');            }; //Enter a name$('#displayname'). Val (Prompt ('Please enter your name:',"')); $('#message'). focus (); //Open Link$.connection.hub.start (). Done (function () {$ ('#sendmessage'). Click (function () {//calling the Send method in the hubChat.server.send ($ ('#displayname'). Val (), $ ('#message'). Val ()); $('#message'). Val ("'). focus ();            });        });    }); </script> <style type="Text/css">. Container {background-Color:yellowgreen;            Border:thick solid #0000ff;            padding:20px;        margin:20px; }    </style>class="Container"> <input type="text"Id="message"/> <input type="Button"Id="SendMessage"Value="Send"/> <input type="Hidden"Id="DisplayName"/> <ul id="discussion"></ul> </div></body>

SIGNALR Communication Technology

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.