android 调用 asp.net web api,如何从Android端或asp.net webapi控制webapi请求顺序?

I'm working on a project where there is android app also included.

there is a webapi call to update the status, from app side they will be sending id and the status.

Here we can update the status in sequence only, that is once the status is changed to A then only it can be changed to B then to C.

It is working fine when network is present.But we have an offline functionality where if three status update call is been done from app when offline-it will send all these three at a time when the system comes online.In this case the system is sending the request in some other order,So the status updation is not happening.

For each request I'm sending the acknowledgement-Issuccess or not.

So is there any way that I can control the sequence of request from .Net side?.

If it can be controlled from the Android side also ,then how?

I know this might be a commonly used scenario,but me and my colleague is pretty new to this ,please give us a hand.!

Talk1:

If setting the state to B is dependent upon the state being A, then there shouldn't be three calls. Only setting A and waiting for the state to be verified.

Solutions1

Assuming your api is rest, it is not wise to track the sequence of requests on the .net part (back-end). It should always be stateless (i.e, in short, you should not keep track of the requests and client state on the server side).

That being said,you could keep track of you status and persist it in the right order (with some kind of order indexing) or push it to a queue mechanism on the app, and later send it when the app is back online in the saved order. If it is working fine when it is online, i don't see a reason why this shouldn't work.

Talk1:

Thanks for that! Here the problem in offline is that -the first request to change the status to 'A ' will come along with some other data where as the other two is simple status change request.Since the first one will take more time,it is executing at last.In the online case this will not go altogether so no issue.

Solutions2

One solution can be Firebase Realtime Database. This article can help you: https://medium.com/step-up-labs/firebase-c-library-5c342989ad18#.t5ao4a6it

Or look into these libraries: FireSharp or FirebaseSharp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值