use of net.minecraftforge.fml.common.network.handshake.NetworkDispatcher in project MinecraftForge by MinecraftForge.
the class FMLNetworkHandler method fmlServerHandshake.
public static void fmlServerHandshake(PlayerList scm, NetworkManager manager, EntityPlayerMP player) {
NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(manager, scm);
dispatcher.serverToClientHandshake(player);
}
use of net.minecraftforge.fml.common.network.handshake.NetworkDispatcher in project MinecraftForge by MinecraftForge.
the class FMLNetworkHandler method fmlClientHandshake.
public static void fmlClientHandshake(NetworkManager networkManager) {
NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(networkManager);
dispatcher.clientToServerHandshake();
}
use of net.minecraftforge.fml.common.network.handshake.NetworkDispatcher in project MinecraftForge by MinecraftForge.
the class FMLOutboundHandler method write.
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (!(msg instanceof FMLProxyPacket)) {
return;
}
FMLProxyPacket pkt = (FMLProxyPacket) msg;
OutboundTarget outboundTarget;
Object args = null;
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
// INTERNAL message callback - let it pass out
if (dispatcher != null) {
ctx.write(msg, promise);
return;
}
outboundTarget = ctx.channel().attr(FML_MESSAGETARGET).get();
Side channelSide = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get();
if (outboundTarget != null && outboundTarget.allowed.contains(channelSide)) {
args = ctx.channel().attr(FML_MESSAGETARGETARGS).get();
outboundTarget.validateArgs(args);
} else if (channelSide == Side.CLIENT) {
outboundTarget = OutboundTarget.TOSERVER;
} else {
throw new FMLNetworkException("Packet arrived at the outbound handler without a valid target!");
}
List<NetworkDispatcher> dispatchers = outboundTarget.selectNetworks(args, ctx, pkt);
// This will drop the messages into the output queue at the embedded channel
if (dispatchers == null) {
ctx.write(msg, promise);
return;
}
for (NetworkDispatcher targetDispatcher : dispatchers) {
targetDispatcher.sendProxy((FMLProxyPacket) msg);
}
}
use of net.minecraftforge.fml.common.network.handshake.NetworkDispatcher in project MinecraftForge by MinecraftForge.
the class HandshakeCompletionHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, CompleteHandshake msg) throws Exception {
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove();
dispatcher.completeHandshake(msg.target);
}
Aggregations