Boolean buscando = true;
BluetoothClient client = null;
do
{
Console.WriteLine("TUTAJ1");
client = btListener.AcceptBluetoothClient();//jak wejdzie tutaj drugi raz to nie wychodzi
Console.WriteLine("TUTAJ2");
stream = client.GetStream();
if (stream.CanRead)
{
byte[] myReadBuffer = new byte[1024];
StringBuilder myCompleteMessage = new StringBuilder();
int numberOfBytesRead = 0;
// Incoming message may be larger than the buffer size.
do
{
numberOfBytesRead = stream.Read(myReadBuffer, 0, myReadBuffer.Length);
myCompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
}
while (stream.DataAvailable);
int a = int.Parse(Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
Console.WriteLine(a.ToString());
stream = null;
VirtualMouse.Move(a, 0);
Console.WriteLine("You received the following message : " + myCompleteMessage);
}
client = null; // zakomentowane czy nie nie działa
//btListener.Stop();
buscando = true;
} while (buscando);
}
}
Używam biblioteki od InTheHand. Odbieram już pierwszego stringa wysłanego z telefonu. Lecz po wysłaniu drugiego już nie mogę odebrać i muszę wyłączyć i włączyć od nowa program. Wtedy obierze znowu tylko jedną wiadomość.
client = btListener.AcceptBluetoothClient();
Nie wychodzi mi z tej metody jak wejdzie drugi raz.