Package muduo.rpc

Source Code of muduo.rpc.RpcServer

package muduo.rpc;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;

import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

public class RpcServer extends RpcPeer {

    ServerBootstrap bootstrap;

    public RpcServer() {
        ChannelFactory channelFactory = new NioServerSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool());
        bootstrap = new ServerBootstrap(channelFactory);
        bootstrap.setPipelineFactory(new RpcChannelPiplineFactory(this));
    }

    public void start(int port) {
        bootstrap.bind(new InetSocketAddress(port));
    }

    @Override
    public void channelConnected(Channel channel) {
        RpcChannel rpcChannel = new RpcChannel(channel);
        setupNewChannel(rpcChannel);
    }
}
TOP

Related Classes of muduo.rpc.RpcServer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.