using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
namespace DBDLL.SingalRS
{
[HubName("mysingal")]//使用小写,试过使用大写,但是在html页会出错
public class MySingal : Hub
{
public void SendMessage(string name, string message)
{
//因为在后台调用,所以要这样,否则会出错,提示Using a Hub instance not created by the HubPipeline is unsupported</pre>
var hubContext = GlobalHost.ConnectionManager.GetHubContext<MySingal>();
hubContext.Clients.All.addNewMessageToPage(name, message); //用户调用客户端的函数
}
public void Init() { }
}