use of org.lanternpowered.server.network.NetworkSession in project LanternServer by LanternPowered.
the class HandlerPlayInRequestStatistics method handle.
@Override
public void handle(NetworkContext context, MessagePlayInRequestStatistics message) {
final NetworkSession session = context.getSession();
session.send(session.getPlayer().getStatisticMap().createStatisticsMessage());
}
use of org.lanternpowered.server.network.NetworkSession in project LanternServer by LanternPowered.
the class LanternChannelRegistrar method sendPayload.
void sendPayload(Player player, String channel, Consumer<ByteBuffer> payload) {
checkNotNull(player, "player");
checkNotNull(payload, "payload");
final NetworkSession session = ((LanternPlayer) player).getConnection();
if (session.getRegisteredChannels().contains(channel)) {
final ByteBuffer buf = ByteBufferAllocator.unpooled().buffer();
payload.accept(buf);
session.send(new MessagePlayInOutChannelPayload(channel, buf));
}
}
use of org.lanternpowered.server.network.NetworkSession in project LanternServer by LanternPowered.
the class LanternChannelRegistrar method unbindChannel.
@Override
public void unbindChannel(ChannelBinding channel) {
final LanternChannelBinding binding = (LanternChannelBinding) checkNotNull(channel, "channel");
if (binding.bound) {
binding.bound = false;
this.bindings.remove(channel.getName());
final MessagePlayInOutUnregisterChannels message = new MessagePlayInOutUnregisterChannels(Collections.singleton(channel.getName()));
for (Player player : this.server.getOnlinePlayers()) {
((NetworkSession) player.getConnection()).send(message);
}
}
}
use of org.lanternpowered.server.network.NetworkSession in project LanternServer by LanternPowered.
the class HandlerForgeHandshakeInModList method handle.
@Override
public void handle(NetworkContext context, MessageForgeHandshakeInOutModList message) {
final NetworkSession session = context.getSession();
final Attribute<ForgeServerHandshakePhase> phase = context.getChannel().attr(ForgeHandshakePhase.PHASE);
if (phase.get() != ForgeServerHandshakePhase.HELLO) {
session.disconnect(t("Retrieved unexpected forge handshake modList message."));
return;
}
// We don't need to validate the mods for now, maybe in the future, just poke back
session.getInstalledMods().addAll(message.getEntries().keySet());
// Just use a empty map for now
session.send(new MessageForgeHandshakeInOutModList(new HashMap<>()));
phase.set(ForgeServerHandshakePhase.WAITING_ACK);
Lantern.getLogger().info("{}: Forge handshake -> Received modList message.", session.getGameProfile().getName().get());
}
Aggregations