I am writing an app that uses WiFi for a 2-way communicate with a program running on a Mac. I started by modifying the WiTap example. But the problem I have is that, unlike WiTap, my app needs to immediately send a message when the stream is open and respond to incoming TCP messages by sending a reply message. In WiTap, once the NSStreamEventOpenCompleted event is sent to the stream event handler, it displays an alert and returns. But what I want to do at that point is to send my first message to the server. If I try to do it from inside the event handler, hasSpaceAvailable is always false and transmission is impossible. Furthermore, I need to send reply messages whenever I get an incoming message and the same problem exists if I try to reply before returning from the stream event handler.
So it seems like I need to just set a value in the stream event handler and then fire another event off of my own design and then test that value in my event handler. But new as I am to iPhone (or Mac) development, I don't know how to do fire events or write event handlers - or even if this is the correct approach. Or does the solution lie in using the run loop - also new to me?
Anyone?
So it seems like I need to just set a value in the stream event handler and then fire another event off of my own design and then test that value in my event handler. But new as I am to iPhone (or Mac) development, I don't know how to do fire events or write event handlers - or even if this is the correct approach. Or does the solution lie in using the run loop - also new to me?
Anyone?