i have problem with handleClientRequest, is there any solution to block spam or block if user already call handleclientrequest with the same request id, i just only need to run 1 time?
i already try to block with get the latest time and request id, but now it call at the same time. so i cannot block it.
thank you.
Code: Select all
public void handleClientRequest(User player, ISFSObject params) {
String requestId = params.getUtfString(SFSExtension.MULTIHANDLER_REQUEST_ID);
trace("-------action : "+ requestId);
long timeNow = System.currentTimeMillis();
trace("-------enddd "+ timeNow );
String lastRequest = "";
Long lastTimeRequest = (long) 0;
try {
lastRequest = (String) player.getProperty("lastRequest");
lastTimeRequest = (Long) player.getProperty("lastTimeRequest");
if(lastRequest.equals("act") ){
trace("lastRequest : "+lastRequest);
trace("lastTimeRequest : "+lastTimeRequest + " Now : "+ timeNow);
if(timeNow - lastTimeRequest < 200){
trace("action cancel!");
return;
}
}
player.setProperty("lastRequest",requestId);
player.setProperty("lastTimeRequest",timeNow);
} catch (Exception e) {
player.setProperty("lastRequest",requestId);
player.setProperty("lastTimeRequest",timeNow);
trace("-------action error : "+ e);
// TODO: handle exception
}
switch(requestId){
.
.
.
this is my log
11 Jun 2018 | 12:14:07,631 | INFO | SFSWorker:Ext:2 | Extensions | | {txh_game}: -------action : act
11 Jun 2018 | 12:14:07,631 | INFO | SFSWorker:Ext:3 | Extensions | | {txh_game}: -------action : act
11 Jun 2018 | 12:14:07,633 | INFO | SFSWorker:Ext:2 | Extensions | | {txh_game}: -------enddd 1528694047633
11 Jun 2018 | 12:14:07,633 | INFO | SFSWorker:Ext:3 | Extensions | | {txh_game}: -------enddd 1528694047633
11 Jun 2018 | 12:14:07,633 | INFO | SFSWorker:Ext:3 | Extensions | | {txh_game}: lastRequest : act
11 Jun 2018 | 12:14:07,633 | INFO | SFSWorker:Ext:2 | Extensions | | {txh_game}: lastRequest : act
11 Jun 2018 | 12:14:07,633 | INFO | SFSWorker:Ext:3 | Extensions | | {txh_game}: lastTimeRequest : 1528694008216 Now : 1528694047633
11 Jun 2018 | 12:14:07,633 | INFO | SFSWorker:Ext:2 | Extensions | | {txh_game}: lastTimeRequest : 1528694008216 Now : 1528694047633