I am trying to add a simple Private message type system to a chat client in order to par up to users to play a game. The way I am sending the first request to the server is sending a message with a prefix + username of the person you want to play with. The server catches and then removes the prefix to get the username.
it uses 2 hashtables for the uernames and there connection.
it usesCode:// This hash table stores users and connections (browsable by user) public static Hashtable htUsers = new Hashtable(30); // 30 users at one time limit // This hash table stores connections and users (browsable by connection) public static Hashtable htConnections = new Hashtable(30); // 30 users at one time limit
to send a message to each person where i is a int in a for loop where it ranges from 0 to the number of connections.Code:swSenderSender = new StreamWriter(tcpClients[i].GetStream());
How can I make this so I can send a message back to the username specify in the incoming message?
example:
there are 3 users online.
User1 = "Bob";
User2 = "Smith";
User3 = "Joe";
now user1 clicks on a username in the listbox of all online users and then the button to initiate the game.
He clicked on Smith so the message is sent as "5|Smith"
now on the server side, it has Bob as the sender, it catches the "5|" prefix and removes it and now the string message is "Smith"
This is where im stuck, how can i get the address to use with
based on the username name stored in the hastables.Code:swSenderSender = new StreamWriter(tcpClients[i].GetStream());


Reply With Quote
Bookmarks