Skip to content

Commit

Permalink
fix(count):token may be erased by another package with same token
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Sep 27, 2021
1 parent 1a4a6d9 commit 214a3a2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/conn/ESNSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ public int countNotifications(int from,int to)throws Exception{
if (!"".equals(result.Error)){
throw new Exception(result.Error);
}
PackRespCount count=selectPack(token,PackRespCount.class);
Debug.debug("Selecting count pack...");
PackRespCount count=selectPack(token+"-1",PackRespCount.class);
Debug.debug("Count:"+count.Amount);
return count.Amount;
}

Expand Down
28 changes: 28 additions & 0 deletions src/test/CountTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package test;

import conn.ESNSession;
import conn.ISessionListener;
import packs.PackRespNotification;
import packs.PackResult;
import util.Debug;

public class CountTest {
public static void main(String[] args)throws Exception {
Debug.debug=true;
ESNSession session=new ESNSession("localhost:3003", "root", "changeMe", 5000, new ISessionListener() {
@Override
public void notificationReceived(PackRespNotification notification) {
System.out.println("new no:"+notification.Content);
}

@Override
public void sessionLogout(PackResult result) {

}
});
for (int i=0;i<100;i++) {
int count = session.countNotifications(0, 100);
System.out.println(i+"$$$$$$$$$$$$$$$$count:" + count);
}
}
}
2 changes: 1 addition & 1 deletion src/test/PushTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class PushTest {
public static void main(String[] args) throws Exception{
// Debug.debug=true;
ESNSession session=new ESNSession("39.100.5.139:3003", "root", "turtle", 5000, new ISessionListener() {
ESNSession session=new ESNSession("localhost:3003", "root", "changeMe", 5000, new ISessionListener() {
@Override
public void notificationReceived(PackRespNotification notification) {
System.out.println("new no:"+notification.Content);
Expand Down

0 comments on commit 214a3a2

Please sign in to comment.