Answer the question
In order to leave comments, you need to log in
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");
}
$('#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()));
});
});
});
$(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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question