public void HandleInputEvent(object sender, NSStreamEventArgs e) { Console.WriteLine("***** Input ***** " + e.StreamEvent); if (e.StreamEvent == NSStreamEvent.HasBytesAvailable) { var buffer = new byte[1024]; nint bytesRead = inputStream.Read(buffer, 3); var stringRead = Encoding.UTF8.GetString(buffer); Console.WriteLine("***** String ***** " + stringRead); } }
private void InputStream_OnEvent(object sender, NSStreamEventArgs e) { Console.WriteLine($"InputStream:{e.StreamEvent}"); // something was scanned if (e.StreamEvent == NSStreamEvent.HasBytesAvailable) { if (!(sender is NSInputStream input)) { return; } byte[] buffer = new byte[1024]; var bytesRead = input.Read(buffer, 1024); var dataString = GetDataString(buffer, bytesRead); Console.WriteLine($"BytesRead:{bytesRead}"); Console.WriteLine($"Barcode:{dataString}"); Xamarin.Forms.MessagingCenter.Send <App, string>((App)Xamarin.Forms.Application.Current, "Barcode", dataString); } }
public void HandleOutputEvent(object sender, NSStreamEventArgs e) { Console.WriteLine("***** Output ***** " + e.StreamEvent); }
void Ignored(object sender, NSStreamEventArgs e) { //throw new NotImplementedException (); }
void DataReceived(object sender, NSStreamEventArgs e) { // TODO - ignored for now... // throw new NotImplementedException (); }
void Ignored (object sender, NSStreamEventArgs e) { //throw new NotImplementedException (); }
void DataReceived (object sender, NSStreamEventArgs e) { // TODO - ignored for now... // throw new NotImplementedException (); }