C
C#8mo ago
Alex

✅ SignalR client to client communication (chat)

Is it correct that I can't send messages from client to client directly using SignalR? Do I need to send http POST request to endpoint, then inside endpoint I get IHubContext and execute method ReceiveChatMessage? (Client code)

const onSubmit = (
values: SubmitMessageSchema,
reset: UseFormReset<SubmitMessageSchema>
) => {
// METHOD USERNAME MESSAGE
connection?.send("ReceiveChatMessage", "Alex", values.text);
reset();
};

const onSubmit = (
values: SubmitMessageSchema,
reset: UseFormReset<SubmitMessageSchema>
) => {
// METHOD USERNAME MESSAGE
connection?.send("ReceiveChatMessage", "Alex", values.text);
reset();
};
2 Replies
Pobiega
Pobiega8mo ago
signalR and websockets in general are strictly server<->client so yes, you'll need to recieve the message on the server, then send something to the other client
Alex
AlexOP8mo ago
okay, thank you

Did you find this page helpful?