1
這些是我在數據庫中添加的表格。與Signalr的羣聊。如何發送給特定用戶?
//Group Chat Hub
public void GroupChatSend(string name, string message)
{
//AddMessageinCacheWallChat(name, message);
Clients.All.addNewMessageToGroupPage(name, message);
}
和 // JavaScript的
var GroupChat = function() {
// Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub;
// Create a function that the hub can call back to display messages.
chat.client.addNewMessageToGroupPage = function (name, message) {
// Add the message to the page.
$('#discussionGroupChat').append('<li><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>');
};
// Set initial focus to message input box.
$('#messageGroupChat').focus();
// Start the connection.
$.connection.hub.start().done(function() {
var name = $('#userName').val();
chat.server.connectWallChat(name);
$('#sendmessageGroupChat').click(function() {
// Call the Send method on the hub.
chat.server.groupChatSend(name, $('#messageGroupChat').val());
// Clear text box and reset focus for next comment.
$('#messageGroupChat').val('').focus();
});
});
// This optional function html-encodes messages for display in the page.
function htmlEncode(value) {
var encodedValue = $('<div />').text(value).html();
return encodedValue;
}
}
我怎麼能發送消息給才集團。有會員桌ID和用戶名等也。我沒有使用owin