mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-10 09:22:49 +00:00
Change-Id: Ifa069a09d1b603781a2c9255d89b77cd6f25a359
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user