Fix real-time updates
This commit is contained in:
+6
@@ -10,6 +10,7 @@ import com.seibel.distanthorizons.core.network.event.ScopedNetworkEventSource;
|
||||
import com.seibel.distanthorizons.core.network.event.CloseEvent;
|
||||
import com.seibel.distanthorizons.core.network.messages.base.RemotePlayerConfigMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.fullData.FullDataChunkMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.fullData.FullDataPartialUpdateMessage;
|
||||
import com.seibel.distanthorizons.core.network.messages.fullData.FullDataPayload;
|
||||
import com.seibel.distanthorizons.core.network.session.Session;
|
||||
import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO;
|
||||
@@ -84,6 +85,11 @@ public class ClientNetworkState implements Closeable
|
||||
composite.addComponent(true, msg.buffer);
|
||||
LOGGER.debug("Full data buffer {}: {}", msg.bufferId, composite);
|
||||
});
|
||||
|
||||
this.session.registerHandler(FullDataPartialUpdateMessage.class, msg ->
|
||||
{
|
||||
// Dummy handler to prevent unhandled message warnings
|
||||
});
|
||||
}
|
||||
|
||||
public FullDataSourceV2DTO decodeDataSourceAndReleaseBuffer(FullDataPayload msg)
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public abstract class NetworkEventSource
|
||||
}
|
||||
}
|
||||
|
||||
if (!handled && ModInfo.IS_DEV_BUILD && message.warnWhenUnhandled())
|
||||
if (!handled && ModInfo.IS_DEV_BUILD)
|
||||
{
|
||||
LOGGER.warn("Unhandled message: " + message);
|
||||
}
|
||||
|
||||
+9
-1
@@ -29,11 +29,15 @@ public final class ScopedNetworkEventSource extends NetworkEventSource
|
||||
public final NetworkEventSource parent;
|
||||
private boolean isClosed = false;
|
||||
|
||||
private final Consumer<NetworkMessage> actualHandleMessageStable = this::handleMessage;
|
||||
|
||||
|
||||
public ScopedNetworkEventSource(NetworkEventSource parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T extends NetworkMessage> void registerHandler(Class<T> handlerClass, Consumer<T> handlerImplementation)
|
||||
{
|
||||
@@ -42,9 +46,13 @@ public final class ScopedNetworkEventSource extends NetworkEventSource
|
||||
return;
|
||||
}
|
||||
|
||||
this.parent.registerHandler(this, handlerClass, this::handleMessage);
|
||||
//noinspection unchecked
|
||||
this.parent.registerHandler(this, handlerClass, (Consumer<T>) this.actualHandleMessageStable);
|
||||
|
||||
super.registerHandler(this, handlerClass, handlerImplementation);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
|
||||
-2
@@ -10,8 +10,6 @@ public abstract class NetworkMessage implements INetworkObject
|
||||
public Session session = null;
|
||||
public IServerPlayerWrapper serverPlayer() { return this.session.serverPlayer; }
|
||||
|
||||
public boolean warnWhenUnhandled() { return true; }
|
||||
|
||||
public Session getConnection()
|
||||
{
|
||||
return this.session;
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@ public abstract class TrackableMessage extends NetworkMessage
|
||||
public long futureId = lastId.getAndIncrement()
|
||||
| ((Objects.requireNonNull(SharedApi.getEnvironment()) == EWorldEnvironment.Server_Only ? 1 : 0) << 31);
|
||||
|
||||
public void setSession(Session session)
|
||||
@Override
|
||||
public void setSession(Session session)
|
||||
{
|
||||
super.setSession(session);
|
||||
this.futureId |= (long) session.id << 32;
|
||||
|
||||
-3
@@ -39,9 +39,6 @@ public class FullDataChunkMessage extends NetworkMessage
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean warnWhenUnhandled() { return false; }
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf out)
|
||||
{
|
||||
|
||||
-2
@@ -42,8 +42,6 @@ public class FullDataPartialUpdateMessage extends NetworkMessage implements ILev
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnWhenUnhandled() { return false; }
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf out)
|
||||
|
||||
Reference in New Issue
Block a user