📄 mytest2eventpullsource.java
字号:
package nl.justobjects.pushlet.test;
import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.EventPullSource;
import nl.justobjects.pushlet.util.Rand;
public class MyTest2EventPullSource {
public static class wyyCityPullSource extends EventPullSource {
static String[] cities = { "222222city1", null, "222222city2", null,
"22222city3", null, "22222city4", null, "222222city5", null };
@Override
protected long getSleepTime() {
return Rand.randomLong(0, 3000);
}
@Override
protected Event pullEvent() {
int cityNumber = Rand.randomInt(0, (cities.length) / 2 - 1);
int nextCityIndex = 2 * cityNumber;
Event event = Event.createDataEvent("/mytest");
event.setField("number", "" + cityNumber);
event.setField("city", cities[nextCityIndex]);
if (cities[nextCityIndex + 1] == null) {
cities[nextCityIndex + 1] = "" + Rand.randomInt(5, 10);
}
int currentCityValue = new Integer(cities[nextCityIndex + 1])
.intValue();
int newCityValue = currentCityValue + Rand.randomInt(-2, 2);
event.setField("value", "" + newCityValue);
return event;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -