Exemple #1
0
 //Send=>Server Method
 public void Send(string name, string message)
 {
     Product p = new Product();
     p.Name = name;
     p.Category = message;
     Clients.All.sendMessage(p);//sendMessage==>Client Menthod
 }
 public ActionResult Index(string name)
 {
     IHubContext context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
     Product p = new Product();
     p.Name = name;
     p.Category = DateTime.Now.ToString();
     context.Clients.All.sendMessage(p);
       //  h.Send(name, "Server Send:" + DateTime.Now.ToString());
     return View();//此範例需將WinForm執行起來
 }