MCPcopy Create free account
hub / github.com/e2wugui/zeze / ModuleBuf

Class ModuleBuf

ZezeJava/ZezexJava/server/src/Game/Buf/ModuleBuf.java:16–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14import org.jetbrains.annotations.NotNull;
15
16public class ModuleBuf extends AbstractModule implements IModuleBuf {
17 private static final Logger logger = LogManager.getLogger(ModuleBuf.class);
18
19 private Future<?> timerIdHot;
20 public int counterHotTimer;
21
22 @Override
23 public int getCounter() {
24 return counterHotTimer;
25 }
26
27 @Override
28 public void setCounter(int value) {
29 counterHotTimer = value;
30 }
31
32 public static class HotTimer implements TimerHandle {
33 @Override
34 public void onTimer(@NotNull TimerContext context) throws Exception {
35 var mc = context.timer.zeze.getHotManager().getModuleContext("Game.Buf", IModuleBuf.class);
36 var ibuf = mc.getService();
37 var buf = (BBuf)context.customData;
38 var count = ibuf.getCounter();
39 if (buf.getId() != count)
40 throw new RuntimeException("buf " + buf.getId() + ":" + count);
41 buf.setId(count + 1);
42 Transaction.whileCommit(() -> ibuf.setCounter(count + 1));
43 }
44 }
45
46 @Override
47 public void StartLast() {
48 counterHotTimer = 0;
49 _tbufs.getChangeListenerMap().addListener(new BufChangeListener("Game.Buf.Bufs"));
50 var rand = Zeze.Util.Random.getInstance();
51 timerIdHot = Task.scheduleUnsafe(
52 rand.nextLong(3000) + 1000,
53 rand.nextLong(3000) + 1000,
54 () -> {
55 var module = App.Zeze.getHotManager().getModuleContext("Game.Equip", IModuleEquip.class);
56 var service = module.getService();
57 oldAccess = service.hotHelloWorld(oldAccess);
58 });
59
60 Task.call(App.Zeze.newProcedure(() -> {
61 hotTimerId = App.Zeze.getTimer().schedule(
62 rand.nextLong(3000) + 1000, rand.nextLong(3000) + 1000,
63 HotTimer.class, new BBuf());
64 return 0;
65 }, "hotTimer"));
66 }
67
68 int oldAccess = 0;
69
70 public final void Start(App app) {
71 }
72
73 String hotTimerId;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected