在IO和Android之间发送数据? (字节数组) [英] Sending data between IOs and Android? (ByteArray)

查看:93
本文介绍了在IO和Android之间发送数据? (字节数组)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Android中的联网应用程序,该应用程序应该能够与IOs应用程序进行通信.我正在使用Appwarps多人游戏后端,并且具有发送和接收数据的功能.该函数接受一个字节数组,因此最初我以为我可以将一个消息"对象序列化为一个字节数组并将其发送出去,但是IOs应用程序能否将其解码回该对象中?

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?

另一面也是如此,因为IOs应用程序必须序列化并将Android必须保存的对象发送回该对象.我想我不完全了解字节数组如何存储整个对象,以及我们使用什么方法将它们重新带回对象.

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.

任何帮助/建议或链接到有用的文章都将是有用的! (我为IO和Android都标记了这个问题,因为任何一方都可能会提供帮助)

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)

推荐答案

您将需要一种通用的数据建模方法,以便Objective C和Java都可以解释该序列化的对象. Google-gson 非常适合Java对象的JSON序列化,而Objective-c具有用于

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 对于这种事情也非常有用.有关更多信息,请查看此SO帖子询问类似的问题.

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

这篇关于在IO和Android之间发送数据? (字节数组)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆