Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

targeting a specific client with a message #70

Open
twhalen08 opened this issue Feb 1, 2021 · 3 comments
Open

targeting a specific client with a message #70

twhalen08 opened this issue Feb 1, 2021 · 3 comments

Comments

@twhalen08
Copy link

I want to send a message to a specific client. I believe this is possible by adding another method to SimpleTCPServer.CS similar to...

public void Broadcast(byte[] data) { foreach(var client in _listeners.SelectMany(x => x.ConnectedClients)) { client.GetStream().Write(data, 0, data.Length); } }

but I am getting hung up on the lambda expression. Any chance anyone can help me out? I believe i could have a method like this that also takes in an IP address and port and then in the lambda area there, I would think you could select only the specific client from the dictionary that you want and send a message to that specific client.

Any help here would be super appreciated.

@Mariapori
Copy link

client.Send(); ?

@DaniEina
Copy link

the same problem. I need to send to a specific client

@lwshowl
Copy link

lwshowl commented Dec 27, 2022

you can save the TCPClient instances given by Server_ClientConnected
then you can do synchornized read write like a normal socket
you can also compare the TCPClient given by Message.TCPClient , then decide which to write depending on the client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants