ios - Access GCDAsyncSocket read queue -


I am using GCDAsyncSocket Library for my iOS messaging app with twisted server in backend. Everything is fine setup and works fine, but I have learned about a specific situation when it does not work right. Therefore, my server is architecturally in such a way that when a user is offline, his message is cached on the server and when he is searched online, the server sends out all his cached pending messages once.

Now, GCDAsyncSocket uses internal reading and written queues, so here, the pending messages sent by the server are queued by the read queue until they are representative method - (zero) socket Is read by: didReadData: withTag: Now, in my app, this delegate method processes incoming messages and displays them in one tableview one by one, hence the issue of problem is that when If you suspend app, you are losing all unrestricted messages in the reading queue, so to combat this, I want to reach the reading queue so that I can suspend the app before suspending it. So that I can recover it when the app is opened.

Note : According to my understanding, the lost messages are from the queue and are not the server because the server shows that "all messages have been sent" before the representative processing Reaches half of the message. And after being suspended, this problem persists.

Am I doing it wrongfully? Or what's the way to reach the queue?

You may consider adding a receipt step to your protocol. Rather than allowing the server to send all queued messages and forget them immediately, as long as the customer does not send back the acceptance per message, you can remember them.

In this way, to display a special message and user that is between receiving any customer, that message will always be available for redistribution to the server. Only after the client has seen (and so accepted) the message will forget the server (and thus the client will not be transmitted again the next time the client sees it).

You can easily enter this message by specifying unique identifiers. These can be random UUIDs or - if your message should always be distributed in sequence - sequence numbers Sequence numbers are convenient (if they understand for your application), because by accepting a single message sequence number, your customers can indicate that they have processed many messages (because if they always execute them in sequence, then any pre- There should be a message with the serial number

The failure mode for this strategy is the opposite because the failure for your current strategy is very high. Now, when a phone is suspended before a message is received, it is lost. Using acceptance, the message can not be opened until it is processed (displayed). However, you can display the message and then fail to send any acknowledgment, this will be twice the message displayed.

You can also call the window on this phone for the failure. If the phone receives a message from the server that it knows that it has already been displayed, then it may skip displaying it and only the receipt Can send it again so that the server can forget it

This reduces the failed window when you display a message and when you manage to record locally, that message is displayed (or vice versa, if you Failure Mode is preferred, where messages are displayed twice, then lost). >

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -