fixed duplicate-recieve

This commit is contained in:
Mike Schwörer 2018-11-17 14:01:51 +01:00
parent 27b45098f0
commit 6f7529fc9b
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 7 additions and 10 deletions

View File

@ -283,10 +283,7 @@ public class ServerCommunication
SCNApp.refreshAccountTab(); SCNApp.refreshAccountTab();
if (json_int(json, "unack_count")>0) if (json_int(json, "unack_count")>0) ServerCommunication.requery(id, key, loader);
{
ServerCommunication.requery(id, key, loader);
}
} catch (Exception e) { } catch (Exception e) {
Log.e("SC:info", e.toString()); Log.e("SC:info", e.toString());
@ -432,12 +429,12 @@ public class ServerCommunication
} }
} }
public static void ack(int id, String key, CMessage msg) public static void ack(int id, String key, long msg_scn_id)
{ {
try try
{ {
Request request = new Request.Builder() Request request = new Request.Builder()
.url(BASE_URL + "ack.php?user_id=" + id + "&user_key=" + key + "&scn_msg_id=" + msg.SCN_ID) .url(BASE_URL + "ack.php?user_id=" + id + "&user_key=" + key + "&scn_msg_id=" + msg_scn_id)
.build(); .build();
client.newCall(request).enqueue(new Callback() { client.newCall(request).enqueue(new Callback() {

View File

@ -50,15 +50,15 @@ public class FBMService extends FirebaseMessagingService
public static void recieveData(long time, String title, String content, PriorityEnum prio, long scn_id, boolean alwaysAck) public static void recieveData(long time, String title, String content, PriorityEnum prio, long scn_id, boolean alwaysAck)
{ {
CMessage msg = CMessageList.inst().add(scn_id, time, title, content, prio);
if (CMessageList.inst().isAck(scn_id)) if (CMessageList.inst().isAck(scn_id))
{ {
Log.w("FB::MessageReceived", "Recieved ack-ed message: " + scn_id); Log.w("FB::MessageReceived", "Recieved ack-ed message: " + scn_id);
if (alwaysAck) ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, msg); if (alwaysAck) ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, scn_id);
return; return;
} }
CMessage msg = CMessageList.inst().add(scn_id, time, title, content, prio);
if (SCNApp.isBackground()) if (SCNApp.isBackground())
{ {
NotificationService.inst().showBackground(msg); NotificationService.inst().showBackground(msg);
@ -68,6 +68,6 @@ public class FBMService extends FirebaseMessagingService
NotificationService.inst().showForeground(msg); NotificationService.inst().showForeground(msg);
} }
ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, msg); ServerCommunication.ack(SCNSettings.inst().user_id, SCNSettings.inst().user_key, scn_id);
} }
} }