Skip to content

Instantly share code, notes, and snippets.

@Jire
Created June 16, 2011 17:31
Show Gist options
  • Save Jire/1029754 to your computer and use it in GitHub Desktop.
Save Jire/1029754 to your computer and use it in GitHub Desktop.
The application will deploy a new RuneScape server module.
package us.rsdk;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Logger;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import us.rsdk.network.PipelineFactory;
/**
* <b>Application entry point.</b>
*
* <p>The application will deploy a new RuneScape server module.</p>
*
* @author Thomas Nappo
*/
public class Server {
private static final Logger logger = Logger.getLogger(Server.class.getName());
private final ExecutorService executor = Executors.newCachedThreadPool();
private final ServerBootstrap bootstrap = new ServerBootstrap();
public static void main(String[] args) {
Server server = new Server(); // instantize a new server
// which will then be binded to a socket
// and finish.
server.bind("localhost", 43594);
server.finish();
}
public Server() {
bootstrap.setFactory(new NioServerSocketChannelFactory(executor, executor));
bootstrap.setPipelineFactory(new PipelineFactory());
}
private void bind(String host, int port) {
bootstrap.bind(new InetSocketAddress(host, port));
logger.info("Binded (" + host + "," + port + ")");
}
private void finish() {
logger.info("Accepting connections.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment