Улучшена передача контекста (не нарушается принцип ответственности), добавлено логгирование, переработан Boot который собирает все древо приложения, улучшен протокол
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package io.orprotocol.packet;
|
||||
|
||||
import io.orprotocol.Context;
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.Settings;
|
||||
import io.orprotocol.client.Client;
|
||||
@@ -10,7 +9,6 @@ import io.orprotocol.client.Client;
|
||||
*/
|
||||
public abstract class PacketExecutor {
|
||||
public Settings settings;
|
||||
public Context context;
|
||||
|
||||
/**
|
||||
* Настройки сервера.
|
||||
@@ -19,15 +17,6 @@ public abstract class PacketExecutor {
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Контекст приложения переданный при создании сервера.
|
||||
* @return контекст
|
||||
*/
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Вызывается при получении пакета от клиента.
|
||||
* @param packet Пакет, полученный от клиента.
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.HashMap;
|
||||
public class PacketManager {
|
||||
|
||||
private HashMap<Integer, Class<? extends Packet>> packets;
|
||||
private HashMap<Integer, Class<? extends PacketExecutor>> executors;
|
||||
private HashMap<Integer, PacketExecutor> executors;
|
||||
|
||||
public PacketManager() {
|
||||
this.packets = new HashMap<>();
|
||||
@@ -46,7 +46,7 @@ public class PacketManager {
|
||||
* Возвращает зарегистрированные исполнители пакетов.
|
||||
* @return Хэш-карта зарегистрированных исполнителей пакетов.
|
||||
*/
|
||||
public HashMap<Integer, Class<? extends PacketExecutor>> getExecutors() {
|
||||
public HashMap<Integer, PacketExecutor> getExecutors() {
|
||||
return this.executors;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class PacketManager {
|
||||
* @param packetId ID пакета
|
||||
* @param executor Обработчик пакета
|
||||
*/
|
||||
public void registerExecutor(int packetId, Class <? extends PacketExecutor> executor) {
|
||||
public void registerExecutor(int packetId, PacketExecutor executor) {
|
||||
if (this.executors == null) {
|
||||
this.executors = new HashMap<>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user