You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's see, I already had a running websocket server. How can I take the initiative to send a message to one of them?
Currently, I can only:
Wait a message from a client and make response, or
Make a broadcast so every client can receive the message.
But what I want is sending to a client its own message by some logic.
Anyone help, please.
The text was updated successfully, but these errors were encountered:
//Client id from db or file
string clientId = "9b0d327304bc433cb2c1968720cd2792";
//Message data
string message = "Hi!";
if (server.WebSocketServices["/Desktop"].Sessions.TryGetSession(clientId, out IWebSocketSession session))
{
//Client is open
if (session.State == WebSocketSharp.WebSocketState.Open)
{
server.WebSocketServices["/Desktop"].Sessions.SendTo(message, clientId);
//session.Context.WebSocket.Send(message);
}
}`
Let's see, I already had a running websocket server. How can I take the initiative to send a message to one of them?
Currently, I can only:
Wait a message from a client and make response, or
Make a broadcast so every client can receive the message.
But what I want is sending to a client its own message by some logic.
Anyone help, please.
The text was updated successfully, but these errors were encountered: