private void AygitArama() { try { // Ayýt araþtýrma baþladý. Uygulama bloklanýr. Aygitlar = localAygit.DiscoverDevices(Sabitler.MAX_AYGIT_SAYISI); } catch (Exception ex) { Console.WriteLine(ex.ToString()); anaPencere.ArastirmaBilgisi("Arastirma sýrasýnda hata oluþtu. " + Aygitlar.Length + " aygýt bulundu."); anaPencere.ArastirmaButonu(); // Araþtýr butonunu aktifleþtir. return; } anaPencere.ArastirmaBilgisi("Arastirma tamamlandý. " + Aygitlar.Length + " aygýt bulundu."); for (int i = 0; i < Aygitlar.Length; i++) { anaPencere.AdresEkle(Aygitlar[i].DeviceAddress); // Adresleri koleksiyona ekle. anaPencere.SunucuEkle(Aygitlar[i].DeviceName); // Ýsimleri koleksiyona ekle. } anaPencere.ArastirmaButonu(); // Araþtýr butonunu aktifleþtir. }
private void Baglan() { int deneme = 0; sunucu = null; // Uzak makina ile baðlantý kurmaya çalýþýyoruz... do { try { sunucu = new BluetoothClient(); sunucu.Connect(new BluetoothEndPoint(sunucuAdresi, servisAdi)); } catch (SocketException ex) { if (deneme >= Sabitler.MAX_DENEME_SAYISI) { Console.WriteLine(ex.ToString()); } } deneme += 1; } while (sunucu == null && deneme < Sabitler.MAX_DENEME_SAYISI); if (sunucu.Connected == false) { HataGoster(); return; } if (sunucuStream == null) { try { sunucuStream = sunucu.GetStream(); } catch (Exception) { HataGoster(); return; } } anaPencere.ArastirmaBilgisi(sunucuAdi + " aygýtý ile baðlantý kuruldu."); anaPencere.MesajBilgisi(sunucuAdi + " aygýtý ile baðlantý kuruldu."); anaPencere.BaglanButonu(); baglantiKuruldu = true; // Sunucu ile baðlantý kuruldu... }