1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Change-Id: Ifa069a09d1b603781a2c9255d89b77cd6f25a359

This commit is contained in:
rogiel
2011-04-28 22:53:11 -03:00
parent 05e8355aaf
commit 54ef3c7fa2
38 changed files with 962 additions and 99 deletions

View File

@@ -1,10 +1,18 @@
package com.l2jserver.service.network;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ServerChannel;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import com.google.inject.Inject;
import com.l2jserver.service.configuration.ConfigurationService;
public class NettyNetworkService implements NetworkService {
private final NetworkConfiguration config;
private ServerBootstrap server;
private ServerChannel channel;
@Inject
public NettyNetworkService(ConfigurationService configService) {
@@ -13,11 +21,19 @@ public class NettyNetworkService implements NetworkService {
@Override
public void start() {
server = new ServerBootstrap(new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
channel = (ServerChannel) server.bind(config.getListenAddress());
}
@Override
public void stop() {
try {
channel.close().awaitUninterruptibly();
} finally {
server = null;
channel = null;
}
}
}