HD908571842 于 2016.09.06 11:08 提问
- .net Signalr实时通信求个大神指点。
-
chatbox.chat.server.send(this.options.id, this.$input.val()); //这句话都不执行
下面这个我也配置了
using Microsoft.AspNet.SignalR; using Owin; using Microsoft.Owin; [assembly: OwinStartup(typeof(CarRental.Web.App_Start.Startup))] namespace CarRental.Web.App_Start { public class Startup { public void Configuration(IAppBuilder app) { HubConfiguration configuration = new HubConfiguration { EnableJSONP = true }; app.MapSignalR(configuration); } } }
就是不会运行到后面来
public void Send(string id, string message) { if (!Context.User.Identity.IsAuthenticated) { return; } Principal principal = (Principal)Context.User; string name = principal.DisplayName; string dateTime = DateTime.Now.ToString("HH:mm"); int idA = principal.ID; int idB = int.Parse(id); //向自己发送 Clients.Caller.addMessageA(message, dateTime, idB, name); //检查对方是否在线 if (!_onlines.ContainsKey(idB) || _onlines[idB] <= 0) { Clients.Caller.addMessageSys("对方是离线状态", dateTime, idB); } //向对方发送 Clients.Group(idB.ToString()).addMessageB(message, dateTime, idA, name); ChatSvc.AddMessage(idA, idB, message); }
请问一下这怎么解决,看了很多教程都做不出来。
-
-
caozhy
2016.09.07 00:23
微软官网上有一个signalr的聊天的程序,你先下载下来什么也不改,去看能不能运行。检查下你的环境和网络的设置。
-
- u011848198 2016.10.09 10:40
app.UseCors(AllowAll.Cors)//跨域操作,
app.MapSignalR(configuration);
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!