Learn how you can go down to the TCP layer of the networking stack and build a real-time chat application with this input & output streams tutorial for iOS.
Hi Luke
Is it is ok to have this kind of approach to use for notifying mobile client app when some updates happens on server.
Our use case involves each and everything whatever happens on server needs to immediate updated to client app.
If we use TCP approach does it will make any impact on apple review process and also is it will drain more battery as its keeps open always stream to receive updates ?
I think the tutorial may be missing setting the delegate of the outputStream? I set it after the inputStream delegate. I’m getting an error “Your browser sent a request that this server could not understand” with code that matches the final chat app, is there something extra I have to do to setup the server?
I figured this out myself. Now that I have it running, with my own and the completed code will show an additional set of users printed out in the listener in the terminal window every time a new user name is entered into the user join field. Is this expected?
Project have incorrect layout for tableView, which is tableView.frame = CGRect(x: 0, y: 0 … And message “User has joined” appear behind navigation bar.
Then, go back to ChatRoomViewController.swift and add the same line to viewWillDisappear(_:).
stopChatSession()
Correct is chatRoom.stopChatSession()
@lxkant Sorry, I’ve not used this in production before so I don’t really have a good answer for you! Feel free to let me know if you find anything out that would be useful to know when building a production system like this!
@surayashivji I don’t think setting the output stream’s delegate is strictly necessary so I didn’t add it, but it shouldn’t hurt either. If you do set it you’ll need to make sure to differentiate between the two streams in the delegate callback method. There shouldn’t be anything extra you need to do to set up the server though! Maybe try going into the Go code and switching the port and then rebuilding the server?
@roward Yeah that’s expected! Just a quirk of telnet I think!
@dony Oh interesting, I wonder if it broke with a new version of Xcode. I’ll pull it down and fix it!
@marse32m I don’t think it would be the easiest thing in the world. I found a gist where someone was sending and receiving UDP packets but it looks they dropped down to plain C for most of it. I haven’t researched enough to know if this is the only way or if there are some better cocoa apis for doing it: send and receive a broadcast udp packet in c or objective c · GitHub
Got through the tutorial. Interesting. Having trouble making it work with a real device connected as opposed to the simulator. I have an iphone6s running 10.3.3. Getting error “Connection has no connected handler-error occurred” when I try to enter the username. Any ideas?
This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]