Example #1
0
        private void cmdGetMaps_Click()
        {
            TcpClient client = new TcpClient();
            try {
                client.Connect(txtServer.Text, 7373);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Ошибка подключения к игровому серверу", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var stream = client.GetStream();
            getMapsListRequest gmlr = new getMapsListRequest();
            gmlr.sendMessage(stream);
            getMapsListResponse gml_resp = new getMapsListResponse();
            gml_resp = gml_resp.readMessage(stream) as getMapsListResponse;

            txtGame.Items.Clear();
            foreach (var map in gml_resp.Maps) {
                txtGame.Items.Add(map.name);
                maps.Add(map.name, map);
            }
            client.Close();
            txtGame.SelectedItem = txtGame.Items[0];
        }
Example #2
0
 void returnGamesList(NetworkStream stream)
 {
     getMapsListResponse gmlr = new getMapsListResponse();
     lock (games) {
         foreach (var name in games.Keys) {
             gmlr.Maps.Add(games[name].Map);
         }
     }
     gmlr.sendMessage(stream);
 }