PDA

View Full Version : scheduleExecution



theworldinunion
04-25-2011, 09:56 AM
Hi,

I'm using Electroserver's scheduleExecution() method to send users a message every 30 seconds. The code runs as a server plugin, not a room plugin. It works great,... for 10 minutes only for any logged in users. After a user (client) has logged onto electroserver for 10 minutes, it stops receiving the message. That problem occurs everytime.

I'm using "-1" for numberOfTimes parameter, so theoretically it's infinite. And I haven't got a single line of cancelScheduledExecution() in my code. Any idea what the problem is?

Thanks.



public class MyTimerPlugin extends BasePlugin {

public static final String SERVERTIME = "SERVERTIME";

public static final int TIMERDURATION = 30000; // 30 seconds
public static final int INFINITETIMES = -1;

private EsObject message = new EsObject();

@Override
public void init(EsObjectRO parameters) {
getApi().getLogger().debug("Starting plugin " + getApi().getName());
this.helperSetUpTimer();
}

// ----------------------------
// Set up a timer
// ----------------------------
public void helperSetUpTimer() {
getApi().scheduleExecution(TIMERDURATION, INFINITETIMES,
new ScheduledCallback() {
public void scheduledCallback() {
java.util.Date now = new java.util.Date();
message.setNumber(SERVERTIME, now.getTime());
getApi().sendGlobalPluginMessage(message);
}
});
}
}

tcarr
04-25-2011, 12:54 PM
Are the users that you are testing with doing anything other than listening? Because 10 minutes is the default client idle time out. That is, if a client doesn't send any messages to ES5 in 10 minutes, it is automatically logged off. See Users are being disconnected from ES5 (http://www.electrotank.com/docs/es5/manual/users_are_being_disconnected_b.htm) for tips.