Wednesday, November 3, 2010

03 November 2010 - Bonjour, multiple iOS sending data to OSX (listener)

Started the day with the setting up of the MacBook Pro as we need a third simulator to simulate multiple iOS-es. While doing that, we did research on how to go about having our listener receive data from multiple iOS-es. Spent quite a long time trying to do research, but in the end, nothing much could be found. Therefore, we decided to try things out ourselves.

Currently, our application has only instance variables for one NSInputStream and one NSOutputStream. This definitely cannot cater for multiple users. Then I thought that since we have the stream delegate, adding the various different streams into an array whenever there is a new user would not be a problem. I went on to try that out and it really worked. Our server was able to receive data from multiple users.

However, there was still one problem. Data sent from multiple users were merged together as they were all making use of the same instance variable that we have on the server, which is used to store leftover data. We went on to research on how to get the client's device name the moment a connection is established. This way, we would be able to identify the different users and have individual NSInputStreams, NSOutputStreams, as well as leftover data for each user. We spent quite a long time trying to get an answer, but all we could do was to retrieve the client's IP address. From there, we reworked our application in such a way that it takes in the device's IP address instead of the name.

We managed to complete the second stage of the application today - having multiple iOS-es connecting and sending data to the listener (OSX). We would be working on the third stage tomorrow - one client sends data to the server, the server receives the data and sends this data to all connected clients, resulting in synchronized displays on the server, as well as all clients connected to the server.

No comments:

Post a Comment