This is form in razor page:
<div>
<b>Message :</b> <input value="@Context" @onchange="@(e => { Context = e.Value.ToString(); })" />
<button class="btn btn-default" @onclick="@(() => HubConnection.SendAsync("Message", TableId, @playerName, @Context))">Send</button>
</div>
this is my MultiplayerHub function:
public async Task Message(string tableId, string playername, string context)
{
await Clients.GroupExcept(tableId, Context.ConnectionId).SendAsync("NewMessage", playername, context);
}
and Im receiving "NewMessage" in razor page this way:
protected override void OnInitialized()
{
HubConnection.On<string, string>("NewMessage", (playername, context) => {
messages.Add(new Message(playername, context));
});
}
Problem is that I can't receive signal from hub and add item to list. Form works and it correctly sends variables and message to MultiplayerHub, but then nothing more happens. Does someone know how can I fix it?
I have another functions similar to this and it works correct.
Github project: https://github.com/dawid628/CheckersApp
Edit:
When I use Clients.All.SendAsync(...) it works, but to all hubs.