1
假設我有論壇,人們發佈他們的問題,另一個人發佈答案。比如說A人發帖提問「什麼是信號員?」並站在該頁面上。其他人也會打開該頁面進行回答。如果其他人發佈任何答案,那麼我希望那個答案將顯示在該頁面由其他用戶打開。假設五個用戶打開該頁面,其中一個用戶回答,那麼五個用戶將看到該答案。使用信號器廣播投遞郵件到特定頁面
正常的時候就喜歡廣播的任何消息都那麼我們就用類似語法在服務器端
Clients.All.broadcastMessage(name, message);
所以根據我的上述情況,我需要用什麼樣的語法?
這裏有一些指導,我發現了撒施消息類型,而這些都是遵循我需要使用
// Call send on everyone
Clients.All.send(message);
// Call send on everyone except the caller
Clients.Others.send(message);
// Call send on everyone except the specified connection ids
Clients.AllExcept(Context.ConnectionId).send(message);
// Call send on the caller
Clients.Caller.send(message);
// Call send on everyone in group "foo"
Clients.Group("foo").send(message);
// Call send on everyone else but the caller in group "foo"
Clients.OthersInGroup("foo").send(message);
// Call send on everyone in "foo" excluding the specified connection ids
Clients.Group("foo", Context.ConnectionId).send(message);
// Call send on to a specific connection
Clients.Client(Context.ConnectionId).send(message);
哪一個?請解釋&謝謝。