-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Support raw NSData, not just JSON #3
Comments
The framework only expects JSON data for authentication purposes. After that its left up to you to determine what kinds of data packets you want to send over. See the demo, we are sending plain text encoded with NSUTF8StringEncoding, there is no JSON. If you are reading no JSON read throwing away garbage data in the console before your code is actually calling sendData it means something is going wrong with the authentication flow. |
What I do is wait for the connection state to become MGSessionStateConnected and then I send an NSData back to the peer. The thing is that both ends will do the same thing when they connect so that they are basically telling the other peer about themselves. When the receiver receives the NSData I get: "No JSON found. Throwing away garbage data." So yes I can see that it's using JSON for the initial connection and handshake, but I don't see it choosing to let the data through after that. The Demo has some problems in that I couldn't get it to send text from one side to the other successfully. I could see them connect, but no messages were displayed by the receiver if I typed into the other end. |
What's probably happening is something like this: Requestor ---------------- (requests connection) ----------------> Receiver ----> asks you for auth So basically, before the requestor can receive the JSON that this has been accepted your data instance is "tacked" on before sending it to the requesting peer so it cannot parse the JSON. The easiest work around is probably to wait for a bit and send new data only after a couple of seconds after the MGSessionStateConnected is received. It chooses to let non JSON data through in the MGSession class after it has 'finalized' the connection. Hopefully, I can work around this so that this bug doesn't appear in the first non beta release of the framework. As for the demo, you need to hit the return key for data to be sent over. It looks for the newline character and then sends the data over. I probably need to work on the demos a bit more to make them nicer but I have tested it and they do work (do not use it between the simulator and the mac) cause that may cause some problems but on an actual device and mac does work. |
OK, that's a possibility. I'll check that out and report back. RE the demo, I'd tried that; I'll try again. I had basically given up on the demo because of the problems with running it on iOS8. |
Having integrated the common code into a project in which I need to transmit binary data via NSData objects, the data is all being thrown away as the framework is expecting JSON only data.
I think, to be a truly useful, flexible framework it needs to support more than just JSON as a message package.
The text was updated successfully, but these errors were encountered: