public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ip), port); CFStream.CreatePairWithSocketToHost(ipEndPoint, out readStream, out writeStream); inputStream = ObjCRuntime.Runtime.GetNSObject <NSInputStream>(readStream.Handle); outputStream = ObjCRuntime.Runtime.GetNSObject <NSOutputStream>(writeStream.Handle); inputStream.ServiceType = NSStreamServiceType.VoIP; outputStream.ServiceType = NSStreamServiceType.VoIP; // // or ? inputStream[NSStream.NetworkServiceType] = NSStream.NetworkServiceTypeVoIP; outputStream[NSStream.NetworkServiceType] = NSStream.NetworkServiceTypeVoIP; inputStream.OnEvent += HandleInputEvent; outputStream.OnEvent += HandleOutputEvent; outputStream.Schedule(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); // TODO check inputStream.Schedule(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); // TODO check // readStream.EnableEvents(CFRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); // writeStream.EnableEvents(CFRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); outputStream.Open(); inputStream.Open(); // UIApplication.SharedApplication.SetKeepAliveTimeout(1, null); // Not supported any more. return(true); }
internal ExternalAccessoryNetworkStream(EASession session) { _delegate = new EAStreamDelegate(this); _inputStream = session.InputStream; _outputStream = session.OutputStream; _inputStream.Open(); _outputStream.Delegate = _delegate; _outputStream.Schedule(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode); _outputStream.Open(); }