SOCKET chat C# with private messaging
- by Sergei
I want to create SOCKET chat(server + clients) with private messaging.
When client write smth to stream, he should notify server that it
is private message for user X, how can i do this?
Actually i can do smth like this:
string command = "PRIV|" + txtMessage.Text;
swSender.WriteLine(command);
but i think it isn't good, for example if user wants send message
like our "PRIV|" flag it will be errors
public class TestChat
{
private StreamWriter swSender;
private IPAddress ipAddr;
private void InitializeandSend()
{
//ip from text box
ipAddr = IPAddress.Parse(txtIp.Text);
// Start a new TCP connections to the chat server
tcpServer = new TcpClient();
tcpServer.Connect(ipAddr, 1986);
//...
//sending message from text box
swSender.WriteLine(txtMessage.Text);
swSender.Flush();
}
}