Friday, October 29, 2010

29 October 2010 - More Bonjour!

As the title says, more Bonjour. We decided to go for a different approach today - to change our server and make use of delegation.

We managed to get the connections set up properly and were able to send and receive data on the client and server side. But, we have one problem. Since we're doing asynchronous data transfer, when the different touch evens are being called rapidly, the data being sent would be merged even before it reaches the receiving end. When this happens, unarchiving the data would cause the program to have errors, and we would not be able to display the user interactions properly.

We tried to solve the problem by applying threading, which I thought would work. Still, it failed. We didn't try doing synchronous data transfer as it would be slow if many users were to connect at the same time. We even tried to skip the unarchiving for data which exceeds a certain number of bytes, which obviously isn't the right way -.- this caused the interface to become jerky as some of the user interactions would be skipped.

Therefore, after doing some research, we realized that manual splitting and merging of the data's bytes has to be done before unarchiving on the receiving end starts. All along we were working based on the misconception that the way we send or receive is incorrect. However, that's not the case. It's actually due the the network that we're sending our data through. If data is being sent at a very fast rate, the data packets tend to be merged on the network. It has got nothing to do with the way we send or receive. It's much more of what should be on the receiving end before unarchiving the data.

Hence, we'll try out the splitting and merging of data packets on Monday to see what happens.

28 October 2010 - Bonjour again

Continued working with Bonjour again. Cracked our heads for the whole day! At first we missed out the code on the listening socket, which led to us not being able to listen to connections coming in. Once we added that in, things worked. We managed to establish the connections today - client joining the server.

However, there seems to be something wrong as the client is able to send the touches to the server, but not the other way round. We suspect that it has got to do with something related to NSOutputStream. Since it's already quite late, we decided to read up more on Bonjour after work.

Wednesday, October 27, 2010

27 October 2010 - Bonjour

Worked on the Bonjour protocol today. Had to get this right as this would be the groundwork for our project that we'll be working on soon in time to come. This time, it would not be the same as the assignments that we did before. Gotta research and try to get things working on our own. Only until the three of us (Kevin, Zac and I) are unable to find a solution, then it can be considered that we failed to do what we wanted. Then that is when we think of alternatives.

Kevin's right, we got to learn to express ourselves more. If we are unable to express ourselves well, we would tend to get the wrong message across, resulting in poor communications. The project could be directed onto another path because we failed to express ourselves well enough. Learnt this important lesson from Kevin today. Thanks Kevin :)

Managed to publish the NSNetService properly today. Gonna work on multiple interactions tomorrow. Hope that we can come up with something good :)

Tuesday, October 26, 2010

26 October 2010 - More on Touch

Continued working with Touch on iOS today. Managed to complete one of the multitouch assignment which requires interaction with irregular shapes before lunch. Zac and I found some classes on the net that catered for buttons with images that have transparent portions. Still don't quite understand how that class works though. The only thing I know is that the class is playing with the color pixels of the button's image. Gotta spend some more time understanding the codes.

Gonna go work on the other touch application in which a shape, say a square, would be able to follow the user's touch on the iDevice.

Just finished the second application, and it works! :D Time to go back and try to understand the classes that I used in the first application.

Watched the lecture on Bonjour protocol while waiting for Kevin to check on us. It's really cool! There are all sorts of things we can do with it. Really up to our imagination.

*edit* added some animations to the second application after Kevin came and looked at our work.

Monday, October 25, 2010

25 October 2010 - NSOperation & Touch

Tasks for the day:
- Watch lecture 14 on Multi-Touch
- Rework assignment 4 part 3 with the use of non-blocking technique
- Work on Multi-Touch Application

Watched the lecture on multi-touch this morning and tried out the demo applications. When we came back for lunch, Kevin took a look at our assignment 4 part 3. For that assignment, out interface was blocked whenever we retrieved data from Flickr. Hence, Kevin gave us a lecture on NSOperations (aka threading).

Kevin also told us about the hierarchy of data retrieval from the fastest to the slowest:
1. Memory
2. Disk
3. Local Network
4. Internet

We learnt that whenever we perform costly operations, it would always be good to make use of threading. This prevents blocking of codes and users would then have a better experience with the application. Else, if the application is being blocked due to the long code execution, the application would be unresponsive. The next thing on the user's mind would be to exit the application.

We managed to rework the application to remove blocking, and the whole process has become much more ideal. Here are some references used during the reworking of the application:


Now, we're given 2 multi-touch assignments to work on. We would be working on the second one first, which seems to be more difficult.

Got this useful link on the net to deal with irregular-shaped buttons. Gonna try it out tomorrow. Have to go back home and create the images.