?? 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 + -