Пример #1
0
 private void getMap(string mapName)
 {
     TcpClient client = new TcpClient();
     try {
         client.Connect(txtServer.Text, 7373);
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, "Ошибка подключения", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     getMapRequest gmr = new getMapRequest(mapName);
     gmr.sendMessage(client.GetStream());
     getMapResponse gmr_resp = new getMapResponse();
     gmr_resp = gmr_resp.readMessage(client.GetStream()) as getMapResponse;
     File.WriteAllBytes(Path.Combine("maps", mapName),gmr_resp.data);
     client.Close();
 }
Пример #2
0
 void returnMapData(NetworkStream stream,getMapRequest gmr)
 {
     string mapName = gmr.name;
     byte[] data = File.ReadAllBytes(Path.Combine("maps", mapName));
     getMapResponse gm_resp = new getMapResponse();
     gm_resp.data = data;
     gm_resp.sendMessage(stream);
 }