基于SignalR的web端即时通讯 - ChatJS
运行作者提供的Demo
在Web项目中集成 ChatJS
using ChatJs.Admin; using Microsoft.Owin; using Owin; [assembly: OwinStartup(typeof (Startup))] namespace ChatJs.Admin { public partial class Startup { public void Configuration(IAppBuilder app) { this.ConfigureAuth(app); app.MapSignalR(); } } }
然后,在需要使用ChatJS的页面引入以下两个JS脚本:
<script src="/Scripts/jquery.signalR-2.0.3.min.js"></script> <script src="/signalr/hubs" type="text/javascript"></script>
<script src="/ChatJS/js/jquery.chatjs.min.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="/ChatJS/css/jquery.chatjs.css" />
<script type="text/javascript"> $(function() { $.chat({ // your user information userId: 1, // this should be dynamic // text displayed when the other user is typing typingText: ‘ is typing...‘, // the title for the user‘s list window titleText: ‘Chat‘, // text displayed when there‘s no other users in the room emptyRoomText: "There‘s no one around here. You can still open a session in another browser and chat with yourself :)", // the adapter you are using adapter: new SignalRAdapter() }); }); </script>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。