简体   繁体   English

从Android客户端轮询asp.net MVC服务器

[英]Polling asp.net MVC server from an Android client

After much research and bumping into the wall a couple of times, it's time to ask some questions. 经过大量研究并多次碰壁,是时候提出一些问题了。

I'm developing a project which is going to send a message from a web client to a server, then the server should notify multiple clients about the update, which should be done in seconds. 我正在开发一个项目,该项目将从Web客户端向服务器发送消息,然后服务器应将更新通知给多个客户端,这应在几秒钟内完成。

First I thought of using GCM notifications, but the user then have to push the notification in order for some code to run on the client (turning on gps and stuff) but my clients don't have time for clicking the notification when it arrives. 首先,我想到了使用GCM通知,但是用户必须推送通知,以便在客户端上运行一些代码(打开gps和东西),但是我的客户没有时间在到达通知时单击通知。 So it has to be done without user interaction. 因此,它必须在没有用户交互的情况下完成。

Next thing I thought about was if the android client could listen to the c# server and run code when the server had a new message, but I haven't found a working torturial yet. 我想到的下一件事是,如果Android客户端可以在服务器收到新消息时侦听c#服务器并运行代码,但是我还没有找到正常的运行环境。 I was looking into GCM again without push, just messages back and forward, but it's getting difficult to get to work. 我一直在没有推送的情况下再次查看GCM,只是来回传递消息,但是开始工作变得越来越困难。 Also sockets was a option, but it also seems really difficult to get to work and I'm not sure if those options are the way to go. 套接字也是一个选项,但是似乎也很难上班,我不确定这些选项是否可行。

So I was thinking to just let the android have a background service which is polling either a database or a method on my c# server. 所以我在想让android有一个后台服务,该服务在我的C#服务器上轮询数据库或方法。

Can anybody give me an idea of what is the right option and maybe a link to a tutorial which is a nice step by step thing. 谁能给我一个正确选择的想法,也许可以链接到教程,这是一步一步的好选择。

It could be nice if I had the option to also use it on IOS at a later point. 如果以后可以在IOS上使用它,那可能会很好。

If i understand correctly, what you are trying to do can be easily done by one of the following or more ways: 如果我正确理解,可以通过以下一种或多种方式轻松地完成您要尝试的操作:

1)Use GCM messages with a Payload! 1)使用有效载荷的GCM消息! When the mobile client receives the Notification it gets the Payload and proceeds on specific actions. 当移动客户端收到通知时,它将获得有效负载并继续执行特定操作。 http://developer.android.com/google/gcm/adv.html - http://developer.android.com/training/cloudsync/gcm.html#react http://developer.android.com/google/gcm/adv.html - http://developer.android.com/training/cloudsync/gcm.html#react

2)Use a SyncAdapter and make your app use an AlarmManager which will periodically tell to the app to poll the server through the SyncAdapter and check for new content. 2)使用SyncAdapter并让您的应用使用AlarmManager ,它会定期通知应用通过SyncAdapter轮询服务器并检查新内容。 Another way of triggering the SyncAdapter is sending a GCM notification like in the first step. 触发SyncAdapter另一种方法是像第一步一样发送GCM通知。 http://developer.android.com/training/sync-adapters/creating-sync-adapter.html http://developer.android.com/training/sync-adapters/creating-sync-adapter.html

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

相关问题 Asp.net MVC-从服务器推送延迟的客户端消息 - Asp.net MVC - Push a deferred client message from server C#ASP.NET从服务器轮询XML并将其缓存 - C# ASP.NET Polling XML from server and cache it 如何从.NET客户端上的ASP.NET MVC5 +身份服务器接收身份验证失败? - How to receive auth failure from ASP.NET MVC5+Identity server on .NET client? 什么是ASP.NET MVC的客户端/服务器等效项 - What is the Client/Server Equivalent for ASP.NET MVC 在ASP.NET MVC中将客户端日期时间转换为服务器日期时间 - Convert a client datetime to server datetime in ASP.NET MVC ASP.NET MVC 中的客户端和服务器端验证 - Client side & Server side validations in ASP.NET MVC 模型如何在Asp.Net MVC3中将数据从客户端传递到服务器? - How Model passes data from client to server in Asp.Net MVC3? 从客户端计算机到ASP.NET MVC中的服务器批量上传图像 - Bulk Image Upload from client machine to server in ASP.NET MVC ASP.NET MVC登录客户端/ ASP.NET WebAPI身份验证/授权服务器分离 - ASP.NET MVC login client / ASP.NET WebAPI authentication/authorization server separation 在ASP.NET MVC 5的客户端PC中从Crystal Report打印 - Print From Crystal Report In client PC in ASP.NET MVC 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM