Инициализация протокола Rosetta
This commit is contained in:
42
src/main/java/com/rosetta/im/Boot.java
Normal file
42
src/main/java/com/rosetta/im/Boot.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.rosetta.im;
|
||||
|
||||
import com.rosetta.im.executors.Executor0Handshake;
|
||||
import com.rosetta.im.packet.Packet0Handshake;
|
||||
import com.rosetta.im.protocol.packet.PacketManager;
|
||||
|
||||
public class Boot {
|
||||
|
||||
private PacketManager packetManager;
|
||||
|
||||
public Boot(PacketManager packetManager) {
|
||||
this.packetManager = packetManager;
|
||||
}
|
||||
|
||||
public PacketManager getPacketManager() {
|
||||
return this.packetManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Инициализация всех пакетов и их обработчиков
|
||||
*/
|
||||
public void bootstrap() {
|
||||
this.registerAllPackets();
|
||||
this.registerAllExecutors();
|
||||
this.printBootMessage();
|
||||
}
|
||||
|
||||
private void registerAllPackets() {
|
||||
this.packetManager.registerPacket(0, Packet0Handshake.class);
|
||||
}
|
||||
|
||||
private void registerAllExecutors() {
|
||||
this.packetManager.registerExecutor(0, Executor0Handshake.class);
|
||||
}
|
||||
|
||||
private void printBootMessage() {
|
||||
System.out.println("Bootstrapping completed. All packets and executors are registered.");
|
||||
System.out.println("Total packets registered: " + this.packetManager.totalPackets());
|
||||
System.out.println("Total executors registered: " + this.packetManager.totalExecutors());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user