Group Chat with Signalr. How to send to specific users?

By : Kashif

These are tables i added in database.

Database table 1

Database table 2

    //Group Chat Hub
    public void GroupChatSend(string name, string message)
        //AddMessageinCacheWallChat(name, message);
        Clients.All.addNewMessageToGroupPage(name, message);

AND // 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.  
    // Start the connection.
    $.connection.hub.start().done(function () {
        var name = $('#userName').val();
        $('#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. 
    // This optional function html-encodes messages for display in the page.
    function htmlEncode(value) {
        var encodedValue = $('<div />').text(value).html();
        return encodedValue;



How can i send message to group only. there is members table with id, username etc also. i am not using owin

By : Kashif


Clients.Group(groupName).[Method which should be called on this group](name, message);

By : Tester

No you can not define multiple actions with the same name.

It is independent of Rails, it's Ruby thing - the latter definition of the method will just override the former.

One of the solutions is to make method accept more arguments (some might be optional, for example) and differentiate based on these.

word is the first argument to the turn function.

['-' | x <- word] is the second argument and it's a list containing one '-' for each letter x in word. The fact that we give each letter the name x accomplishes nothing though, as we never refer to it, so we might as well write ['-' | _ <- word].

This syntax is known as a list comprehension and is meant to look similar to set notation.

By : sepp2k

This video can help you solving your question :)
By: admin