客户端事件不是要求" Clients.Group(groupName).MessageReceived(UserName,message,groupName); "

时间:2015-08-31 06:42:55

标签: signalr

集线器类

public void sendToAll(string UserName,string message,string grpId,string groupName,string UserId)

{

if (grpId == "3")
        {
            //This is working
            Clients.All.MessageReceived(UserName, message, groupName);
        }
        if (grpId == "4")

        { //This is not working 
            Clients.Group(groupName).MessageReceived(UserName,message,groupName);
        }

}

客户方:

        $('#btnSendToAll').click(function () {
            var GrpId = $(this).parent().attr('groupid');
            var GrpName = $(this).parent().attr('groupname1');
            chat.server.sendToAll($("#hdnUserName").val(), $('#txtMsg').val(), GrpId, GrpName, $("#hdnUserId").val());
            $('#dvGroupChat', $(this).parent()).find('ul').append($('#txtMsg').val());
            $('#message').val('').focus();
        });

        chat.client.messageReceived = function (name, message, groupType) {
            $('div[groupname1=' + groupType + ']').find('ul').append('<ul>' + name + ':&nbsp;&nbsp;' + message + '');
        };

0 个答案:

没有答案