简体   繁体   English

使用 XMPP 协议通过 tigase 服务器将字符串数组从一个 Android 发送到另一个

[英]Sending a String array through a tigase server from one Android to another using XMPP protocol

I'm currently trying to use the Smack libraries and the Tigase server to send a String array from one Android to another using the XMPP protocol (I'm developing in Java with the Eclipse IDE).我目前正在尝试使用 Smack 库和 Tigase 服务器使用 XMPP 协议将字符串数组从一个 Android 发送到另一个(我正在 Java 中开发)。

Is the String array an Item?字符串数组是项吗? or something else?或者是其他东西? I might be able to also send it as a file but I think it might be more energy consuming (for the device's battery).我也可以将它作为文件发送,但我认为它可能更耗能(对于设备的电池)。

Is there a preferable way to accomplish this task?有没有更好的方法来完成这项任务?

I cannot help you with Smack library, however why don't you use Tigase's JaXMPP2 instead?我无法帮助您使用 Smack 库,但是您为什么不使用 Tigase 的 JaXMPP2 呢? https://projects.tigase.org/projects/jaxmpp2 This is Java library which has been created specifically to be compatible with Android, GWT and standalone Java applications. https://projects.tigase.org/projects/jaxmpp2 This is Java library which has been created specifically to be compatible with Android, GWT and standalone Java applications. So kind of portable Java library.这样的便携式 Java 库。 This way all the software you use comes from one vendor and I am sure in such a case nice guys from Tigase would be happy to help you out.这样,您使用的所有软件都来自一个供应商,我相信在这种情况下,来自 Tigase 的好人会很乐意为您提供帮助。

This is pretty simple to do.这很简单。

The simplest approach would be to simply create a chat between the two users and send the data as the message body.最简单的方法是在两个用户之间简单地创建一个聊天并将数据作为消息正文发送。 Since your content is just a string array it can be easily sent as a comma delimited list of strings that you can easily marshall/unmarshall at each end.由于您的内容只是一个字符串数组,它可以很容易地作为逗号分隔的字符串列表发送,您可以在每一端轻松地编组/解组。

The fact that you are using tigase is irrelevant in this case as it is basic XMPP and will work with any server.在这种情况下,您使用 tigase 的事实无关紧要,因为它是基本的 XMPP,并且可以与任何服务器一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM