简体   繁体   English

在运行相同应用程序的设备之间发送消息的最佳方法?

[英]Best way to send messages between devices running the same application?

I am planning on creating an application that will allow multiple devices running the application to send messages (urls/ids/strings) to a another device running the application. 我正计划创建一个应用程序,该应用程序将允许多个运行该应用程序的设备将消息(URL / ID /字符串)发送到另一个运行该应用程序的设备。

So if I had 4 devices. 因此,如果我有4台设备。 Device A, B, C & D. Device A decides to become the host device, devices B, C & D will then like to see Device A through the app, and then send some requests to Device A. 设备A,B,C和D。设备A决定成为主机设备,然后设备B,C和D将希望通过该应用查看设备A,然后向设备A发送一些请求。

My challenge is picking the correct/most efficient and cost effective method of doing this. 我的挑战是选择正确/最有效和最具成本效益的方法。

I have considered the following options 我考虑了以下选项

  • Peer-to Peer connection 对等连接
  • Starting and running a server on host device on the fly 快速启动并在主机设备上运行服务器
  • Push notifications 推送通知

I have deliberately avoided the user of a middle-man server as I want to avoid additional costs as I do not have any foresight on how this app will do commercially. 我故意避免使用中间人服务器,因为我想避免增加成本,因为我对这个应用程序的商业运作方式没有任何远见。 I secondly must mention that at any one time, I would not expect more than 10 devices would want to send messages to this 'Host Device' and no more than 50-100 messages to be sent over the course of 5 hours. 其次,我必须提到,在任何时候,我都不希望有超过10台设备希望向该“主机设备”发送消息,并且在5个小时内不会发送超过50-100条消息。 So not to taxing. 因此不要征税。

All the devices would be on their individual mobile networks but potentially on the same wifi. 所有设备都将位于各自的移动网络上,但可能位于同一wifi上。 I do not want to restrict this to being on the same network. 我不想将其限制在同一网络上。

Any thoughts on what would be the best option in my case would be greatly appreciated. 对于在我的情况下最好的选择的任何想法,将不胜感激。 I am personally leaning towards peer-to-peer as it would seem easiest to implement and would do fine with the number of requests the host device would be able to handle. 我个人倾向于点对点,因为它似乎最容易实现,并且可以很好地处理主机设备能够处理的请求数量。

Thanks in advance, James 预先感谢,詹姆斯

Considering they may be on different mobile networks and you don't need real time communication, I would consider push notifications. 考虑到它们可能位于不同的移动网络上,并且您不需要实时通信,因此我将考虑推送通知。

And you can have problems with peer-to-peer connection across different mobile networks, it is probably blocked. 您可能会遇到跨不同移动网络的对等连接问题,这可能已被阻止。 And you would waste resources to connect/disconnect for every message, because you can't keep the connection running or you will drain the device's battery. 而且,您将浪费资源来连接/断开每条消息,因为您无法保持连接的运行状态,否则将耗尽设备的电池电量。

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

相关问题 通过设备发送数据的最佳方法? (Android) - Best way to send data through devices? (Android) 可以使用gcm在Android设备之间发送和接收消息吗? - Can gcm be used to send and receive messages between android devices? QuickBlox:发送消息不会在具有相同登录名的其他设备上更新 - QuickBlox: Send messages is not updated on other devices with same login 在Sencha Touch中同一网络上的设备之间传输消息 - Transfer messages between devices on same network in Sencha Touch 一次将消息发送到所有用户设备的最佳方法是什么? - What is the best way to send a message to all my users' devices at once? 将通知发送到Android应用程序的最佳方法 - Best way to send notifications to an Android application 在所有设备上将图像定位在同一位置的最佳方法? - Best way to position image in the same spot on all devices? 使应用程序背景适合不同设备的最佳方法 - Best way to go about making application background fit different devices 在同一网络上的两个Android设备之间发送数据 - Send data between two Android devices on same network 蓝牙 LE 通过应用程序在 Android 设备之间发送字符串数据 - Bluetooth LE send string data between Android devices via application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM