Initial Netty implementation for networking
Split into 1 LoginServer and 1 ChannelServer per channel. There is still a lot of cleanup and refactoring to be done. Currently, the reliance on IoSession holding client state is the most pressing issue to be addressed.
This commit is contained in:
22
src/main/java/net/netty/ServerChannelInitializer.java
Normal file
22
src/main/java/net/netty/ServerChannelInitializer.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.netty;
|
||||
|
||||
import client.MapleClient;
|
||||
import constants.net.ServerConstants;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public abstract class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {
|
||||
static final AtomicLong sessionId = new AtomicLong(7777);
|
||||
|
||||
void initPipeline(SocketChannel socketChannel, MapleClient client) {
|
||||
final InitializationVector sendIv = InitializationVector.generateSend();
|
||||
final InitializationVector recvIv = InitializationVector.generateReceive();
|
||||
socketChannel.writeAndFlush(Unpooled.wrappedBuffer(MaplePacketCreator.getHello(ServerConstants.VERSION, sendIv, recvIv)));
|
||||
socketChannel.pipeline().addLast("PacketCodec", new PacketCodec(ClientCyphers.of(sendIv, recvIv)));
|
||||
socketChannel.pipeline().addLast("MapleClient", client);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user