S
S
Sasha Pleshakov2016-11-15 20:58:41
ASP.NET
Sasha Pleshakov, 2016-11-15 20:58:41

Why isn't a message coming to the SignalR group?

Methods from the hub.

public void UserConnect(string message)
{
    Clients.Group("managers").notifyManager(Context.ConnectionId, message);
}

public void ManagerConnect()
{
    Groups.Add(Context.ConnectionId, "managers");
}

For some reason, when debugging, it does not enter the notifyManager
JS method that calls the UserConnect method
$('#connectButton').click(function () {
    $('#connectButton').remove();
    $('#sendMsgButton').show();
    var chat = $.connection.chatHub;
    chat.client.notifyManager = function (connectionId, message) {
      //При дебаге не заходит в этот метод
        $('#notifyManagerPanel').append(
            `<div class="panel panel-default">
                <div id="clientId">connectionId</div>
                <div class ="panel-body">${htmlEncode(message)}</div>
                <div class="panel-footer">
                    <input type="button" class ="btn btn-success" connectionId="${connectionId}" value="Принять" />
                    <input type="button" class="btn btn-danger" value="Отклонить" />
                </div>
              </div>`);
    };
    appendAnswer();    
    $.connection.hub.start().done(function () {
        chat.server.userConnect(htmlEncode($('#messageText').val()));
        $('#sendMsgButton').click(function () {
            appendAnswer();
            chat.server.userConnect(htmlEncode($('#messageText').val()));
        });
    });    
});

JS calling ManagerConnect
$(document).ready(function () {
    var chat = $.connection.chatHub;
    $.connection.hub.start().done(function () {
        chat.server.managerConnect();
    });
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2016-11-15
@kttotto

Causes suspicion that at you $.connection.hub.start() starts twice on the page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question