You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
using Microsoft.AspNet.SignalR;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace DefenseWeb.Signalr
|
|
{
|
|
public class codingChatHub : Hub
|
|
{
|
|
// http://stackoverflow.com/questions/11155064/signalr-signalr-hubs-404-not-found
|
|
// Fix cannot find ~/SignalR/hub
|
|
public void Hello(string name)
|
|
{
|
|
// 這邊會傳入 name 參數
|
|
// 呼叫所有連線狀態中頁面上的 javascript function => hello
|
|
// 透過 server 端呼叫 client 的 javascript function
|
|
// string message = " 歡迎使用者 " + name + " 加入聊天室 ";
|
|
// Clients.All.hello(message);
|
|
}
|
|
|
|
public void SendMessage(string name, string message)
|
|
{
|
|
// 這邊會傳入 name 和 message 參數
|
|
// 並且會呼叫所有連線狀態中頁面上的 javascript function => sendAllMessage
|
|
// 透過 server 端呼叫 client 的 javascript function
|
|
message = name + ":" + message;
|
|
Clients.All.sendAllMessge(message);
|
|
}
|
|
}
|
|
}
|