Skip to content
Snippets Groups Projects
Commit f86ef6f2 authored by OPALVENS Florence's avatar OPALVENS Florence
Browse files

changement dictionary

parent d8ae36c8
Branches
Tags
No related merge requests found
......@@ -19,7 +19,7 @@ namespace ServeurUdp
List<EndPoint> subscribers = new List<EndPoint>();
List<EndPoint> alreadyConnectedRoom = new List<EndPoint>();
string nameRoom = string.Empty;
static Dictionary<string, int> rooms = new Dictionary<string, int>();
static Dictionary<int, string> rooms = new Dictionary<int, string>();
static int numPort = 17021;
static bool display = false;
......@@ -58,9 +58,9 @@ namespace ServeurUdp
//sinon on envoie tous les noms de rooms créées
else
{
foreach (KeyValuePair<string, int> pair in rooms)//on récupère seulement le nom des rooms et on les place dans une string (comme pour les messages)
foreach(KeyValuePair<int, string> pair in rooms)//on récupère seulement le nom des rooms et on les place dans une string (comme pour les messages)
{
nameRoom += "NOM: "+ pair.Key + " || NUMERO PORT : " + pair.Value + '/';
nameRoom += "NOM: "+ pair.Value+ " || NUMERO PORT : " + pair.Key + '/';
}
byte[] buf = System.Text.Encoding.ASCII.GetBytes(nameRoom);
serverSocket.SendTo(buf, 0, buf.Length, SocketFlags.None, clientEP);
......@@ -139,7 +139,7 @@ namespace ServeurUdp
numPort++;
string[] args = { numPort.ToString() };//envoi du numéro de port pour la chat room (sera à chaque fois incrémenté)
Console.WriteLine(args[0]);
rooms.Add(nameRoom, numPort);//ajout de la room dans la liste du chat serveur
rooms.Add(numPort, nameRoom);//ajout de la room dans la liste du chat serveur
//création et lancement du Thread qui contiendra le MainServer
Thread chatServerThread = new System.Threading.Thread(() => chatServer.MainServer(args));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment