简体   繁体   English

对于我的任务,您应该如何通过3G网络在iPhone设备之间进行通信?

[英]For my task how should you communicate between iphone devices over the 3G network?

I have a situation where I would like to communicate between 2-4 devices over the 3G network (it should also work over WLAN, but 3G solution is critical). 我有一种情况,我想通过3G网络在2-4个设备之间进行通信(它也应该可以在WLAN上工作,但是3G解决方案至关重要)。

Every device (except one) asks for a GPS-location every ~5 seconds, but when this process is cancelled by the user of that device, one device needs to be informed of this event. 每个设备(一个设备除外)每隔约5秒钟会请求GPS定位,但是当该设备的用户取消了此过程时,需要将此事件通知一个设备。

I was thinking that one device could act as a server, and the rest as clients that should connect to the server. 我当时以为一台设备可以充当服务器,其余设备可以充当应连接到服务器的客户端。 Is this possible over the 3G network? 通过3G网络有可能吗?

I've also read about push-notifications, is this relevant here? 我还阅读了有关推送通知的信息,这与这里有关吗? Can you receive notifications without disturbing the user with a popups etc? 您可以在不弹出窗口打扰用户的情况下接收通知吗?

Are there other ways? 还有其他方法吗?

Basically I would like to use apple "standard" solutions (if there are any) before diving into eventual socket-programming or anything similar... 基本上,在进入最终的套接字编程或类似方法之前,我想使用苹果的“标准”解决方案(如果有的话)...

What I would like to avoid is to have a webserver or some similar "3rd-party" solution, because I don't want many users to simultaniously connect and "pull" from the same external server in a final solution... 我要避免的是拥有Web服务器或一些类似的“第三方”解决方案,因为我不希望很多用户在最终解决方案中同时从同一台外部服务器连接并“拉出” ...

UPDATE: 更新:

Basically my application will have thousands of users that will need to be informed if an even occurs. 基本上,我的应用程序将有成千上万的用户,如果发生偶发事件,则需要通知他们。 Also this happens simultanously ~5 second, what would be the best solution to reduce load and avoid spamming? 同样,这会同时发生〜5秒,减少负载并避免垃圾邮件的最佳解决方案是什么?

I was thinking that one device could act as a server, and the rest as clients that should connect to the server. 我当时以为一台设备可以充当服务器,其余设备可以充当应连接到服务器的客户端。 Is this possible over the 3G network? 通过3G网络有可能吗?

It could work, but having a dedicated server would be a better choice 它可以工作,但是拥有专用服务器将是更好的选择

I've also read about push-notifications, is this relevant here? 我还阅读了有关推送通知的信息,这与这里有关吗? Can you receive notifications without disturbing the user with a popups etc? 您可以在不弹出窗口打扰用户的情况下接收通知吗?

In your case no, since you will need a server to communicate with apple 在您的情况下,否,因为您将需要服务器与Apple通讯

Basically I would like to use apple "standard" solutions (if there are any) before diving into eventual socket-programming or anything similar... 基本上,在进入最终的套接字编程或类似方法之前,我想使用苹果的“标准”解决方案(如果有的话)...

There are no standard solution, other than you should probably rethink about using a dedicated remote server for this 没有标准的解决方案,除了您可能应该重新考虑为此使用专用的远程服务器

iPhones can't communicate directly with each other using 3G. iPhone无法使用3G彼此直接通信。 You can access the internet through the 3G, but you can't do peer-to-peer as you are suggesting. 您可以通过3G访问互联网,但不能按照您的建议进行点对点。 If you were close enough, you could use bluetooth, but I expect you are too far away. 如果距离足够近,可以使用蓝牙,但是我希望您距离太远。

You would have no way of detecting the one device that acts as a server from the other devices. 您将无法从其他设备检测充当服务器的一台设备。 The IP address could (and probably would) change every time the device connects to a mobile data network. 每次设备连接到移动数据网络时,IP地址都可能(并且可能会)更改。 You would need a central server to co-ordinate all of the clients. 您将需要一个中央服务器来协调所有客户端。

You have multiple questions, but I'll try to address as many of them as I can: 您有多个问题,但我将尝试解决尽可能多的问题:

I was thinking that one device could act as a server, and the rest as clients that should connect to the server. 我当时以为一台设备可以充当服务器,其余设备可以充当应连接到服务器的客户端。 Is this possible over the 3G network? 通过3G网络有可能吗?

No, you cannot run a server on a iPhone/iPad that is accessible over 3G without an external website acting as an intermediary. 不可以,如果没有外部网站充当中介,您将无法在通过3G访问的iPhone / iPad上运行服务器。 (You can run one that is accessible over Wi-Fi, but this does not solve your problem as stated.) (您可以运行可通过Wi-Fi访问的服务器,但这不能解决您所说的问题。)

I've also read about push-notifications, is this relevant here? 我还阅读了有关推送通知的信息,这与这里有关吗? Can you receive notifications without disturbing the user with a popups etc? 您可以在不弹出窗口打扰用户的情况下接收通知吗?

Push requires you (or a third party contracted by you) to have a web server, so if you want a server-free solution it is not relevant here. 推送要求您(或与您签约的第三方)具有Web服务器,因此,如果您需要不依赖服务器的解决方案,则此处不相关。

Are there other ways? 还有其他方法吗?

Over 3G you will, under the current Apple restrictions, always need an external server. 在当前的Apple限制下,超过3G时,您将始终需要外部服务器。

Basically I would like to use apple "standard" solutions (if there are any) before diving into eventual socket-programming or anything similar... 基本上,在进入最终的套接字编程或类似方法之前,我想使用苹果的“标准”解决方案(如果有的话)...

Diving won't help you here. 潜水对您无济于事。 Even using low-level socket programming you will not be able to run a server on an iPhone accessible over 3G without an external website to aid in establishing a connection. 即使使用低级套接字编程,如果没有外部网站来帮助建立连接,您将无法在通过3G访问的iPhone上运行服务器。

You can try using GameCenter. 您可以尝试使用GameCenter。 The mechanism of network games in Game Center allows connect up to four players with no third-party solutions. Game Center中的网络游戏机制可在没有第三方解决方案的情况下最多连接四个玩家。

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

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