0

I am working on an networked application in Android that should be able to communicate with the IOs app. I am using Appwarps multiplayer back-end and there is a function to send and receive data. The function accepts a byte-array, so Initially I thought I could serialize a 'message' object into a byte-array and send that across - however would the IOs app be able to decode this back into the object?

Same applies to the other side, as the IOs app would have to serialize and send the object that Android would have to save back into the object. I guess I don't entirely understand how Byte-Arrays store entire objects and what the methods we use do to get them back to the object.

Any help/advice or linking to a useful article would be useful! (I tagged this question for both IOs and Android, as either side could potentially help)

Kevin Pione
  • 299
  • 3
  • 12
  • Think about it a bit different, lets say you have a backend for iOS and Android apps, you don't create 2 seperate backends foreach platform, right? – SuperFrog Sep 19 '15 at 15:53
  • No - however I need all devices to be able to communicate in real time. So i need to be able to send information from an Android device to any other device (IOs or Android) and the other way around. – Kevin Pione Sep 19 '15 at 16:03
  • Without a server in the middle? – SuperFrog Sep 19 '15 at 16:04
  • There is a server in the middle, but I don't have any control other it really. It just receives the data and sends it on to all recipients – Kevin Pione Sep 19 '15 at 16:05

1 Answers1

0

You'll need a common way to model the data so that both Objective C and Java can interpret that serialized object. Google-gson works great for JSON serialization of Java objects and Objective-c has tools for parsing JSON as well.

Protobuf is also fantastic for this sort of thing. For more info, check out this SO post asking a similar question.

Community
  • 1
  • 1
Alex
  • 69
  • 5
  • Thanks for that - really helpful. Am I able to send the JSON data via a byte array so both sides can get the JSON data out? – Kevin Pione Sep 19 '15 at 16:19
  • Hi @Alex could you please share information. How you resolved. I am also facing same issue unable to parse ByteArray from android to ios and vice versa. Thank you in advance. – Sathish Gadde Oct 22 '20 at 13:33
  • THis is a horrible answer. He asked for how to parse a byte array. The answer is you don't- you just read it in. A socket's native format is byte array. What you're telling him to do is wrap it in some other format. Which may be appropriate for some things, but its not how you parse a byte array. – Gabe Sechan Nov 09 '22 at 04:37