public void handleToolsEvents(object o, ClientToolsEvent e) { switch (e.Type) { case ClientToolsEvent.typeEvent.ERROR: string errorMessage = Utils.decodeString(e.Message[0]); MessageBox.Show("Le serveur sur lequel vous êtes connecté à renvoyé l'erreur suivante : " + errorMessage, "Attention", MessageBoxButtons.OK); break; case ClientToolsEvent.typeEvent.EXTINCTION: MessageBox.Show("Le serveur sur lequel vous étiez connecté a signalé une extinction!", "Attention", MessageBoxButtons.OK); if (request.Visible) { disconnect(); request.Dispose(); request.Close(); request = null; } break; case ClientToolsEvent.typeEvent.MESSAGE: if (int.Parse(e.Stamp) == queryNumber - 1) { setQueryNumberToHighest(); } else { emptyQueryNumbers.Add(int.Parse(e.Stamp)); } ServiceInfos ks = queries[int.Parse(e.Stamp)]; if (ks.Operation.Keys.First() != catalogue_name) { Dictionary <string, List <Type> > operation = ks.Operation; //opération de la requête List <Type> types = operation.Values.First(); //types pour la première et unique opération de cette structure Type type = types[types.Count - 1]; //on récupère le dernier type de la liste, correspondant à la valeur de retour de l'opération object retour = Utils.decode(e.Message[0], type); request.appendTextToLog(retour.ToString() + Environment.NewLine); } else { //traiter le getinfos ici mySelf.Disconnect(); mySelf = null; } break; } }
public bool connectToCatalogue() { mySelfClient = LibraryInterfaceClient.Utils.createClient(adresse_catalogue, int.Parse(port_catalogue)); if (mySelfClient.Connect()) { mySelfClient.Subscribe(handleToolsEvents); appendTextToLog("Connected to catalog server!" + Environment.NewLine); return true; } else MessageBox.Show("Impossible d'atteindre le serveur catalogue demandé (adresse = " + adresse_catalogue + ", port = " + port_catalogue + ")"); return false; }
public bool connect(String ip, String port) { mySelf = LibraryInterfaceClient.Utils.createClient(ip, int.Parse(port)); if (mySelf.Connect()) { mySelf.Subscribe(handleToolsEvents); return true; } else MessageBox.Show("Impossible d'atteindre le serveur demandé (adresse = " + ip + ", port = " + port+")", "Attention", MessageBoxButtons.OK); return false; }
public bool connectToCatalogue() { mySelfClient = LibraryInterfaceClient.Utils.createClient(adresse_catalogue, int.Parse(port_catalogue)); if (mySelfClient.Connect()) { mySelfClient.Subscribe(handleToolsEvents); appendTextToLog("Connected to catalog server!" + Environment.NewLine); return(true); } else { MessageBox.Show("Impossible d'atteindre le serveur catalogue demandé (adresse = " + adresse_catalogue + ", port = " + port_catalogue + ")"); } return(false); }
public bool connect(String ip, String port) { mySelf = LibraryInterfaceClient.Utils.createClient(ip, int.Parse(port)); if (mySelf.Connect()) { mySelf.Subscribe(handleToolsEvents); return(true); } else { MessageBox.Show("Impossible d'atteindre le serveur demandé (adresse = " + ip + ", port = " + port + ")", "Attention", MessageBoxButtons.OK); } return(false); }
public void handleToolsEvents(object o, ClientToolsEvent e) { switch (e.Type) { case ClientToolsEvent.typeEvent.ERROR: string errorMessage = e.Message[0]; MessageBox.Show("Le serveur sur lequel vous êtes connecté à renvoyé l'erreur suivante : " +errorMessage, "Attention", MessageBoxButtons.OK); break; case ClientToolsEvent.typeEvent.EXTINCTION: MessageBox.Show("Le serveur sur lequel vous étiez connecté a signalé une extinction!", "Attention", MessageBoxButtons.OK); if (request.Visible) { disconnect(); request.Dispose(); request.Close(); request = null; dgv_infos.Rows.Clear(); } break; case ClientToolsEvent.typeEvent.MESSAGE: //if (int.Parse(e.Stamp) == queryNumber - 1) // setQueryNumberToHighest(); //else emptyQueryNumbers.Add(int.Parse(e.Stamp)); ServiceInfos ks = queries[int.Parse(e.Stamp)]; if (ks.Operation.Keys.First() != "getinfos") { //Dictionary<string, List<Type>> operation = ks.Operation; //opération de la requête //List<Type> types = operation.Values.First(); //types pour la première et unique opération de cette structure //Type type = types[types.Count - 1]; //on récupère le dernier type de la liste, correspondant à la valeur de retour de l'opération //object retour = Utils.decode(e.Message[0], type); request.appendTextToLog(e.Message[0] + Environment.NewLine); } else { prepareServerInfos(e.Message, e.Message.Count); mySelf.Disconnect(); mySelf = null; } queries.Remove(int.Parse(e.Stamp)); break; } }