Examples of TextLineCodecFactory


Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

        try {
            IoFilter LOGGING_FILTER = new LoggingFilter();

            IoFilter CODEC_FILTER = new ProtocolCodecFilter(
                    new TextLineCodecFactory());
           
            connector.getFilterChain().addLast("mdc", new MdcInjectionFilter());
            connector.getFilterChain().addLast("codec", CODEC_FILTER);
            connector.getFilterChain().addLast("logger", LOGGING_FILTER);
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

        // Create the acceptor
        IoAcceptor acceptor = new NioSocketAcceptor();
       
        // Add two filters : a logger and a codec
        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
        acceptor.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" ))));
  
        // Attach the business logic to the server
        acceptor.setHandler( new TimeServerHandler() );

        // Configurate the buffer size and the iddle time
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

        // Prepare the configuration
        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
        acceptor.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                        .forName("UTF-8"))));

        // Bind
        acceptor.setHandler(new ReverseProtocolHandler());
        acceptor.bind(new InetSocketAddress(PORT));
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

        cfg.setReuseAddress( true );
        cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
        cfg.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(
                        new TextLineCodecFactory( Charset.forName( "UTF-8" ) ) ) );

        // Bind
        acceptor.bind(
                new InetSocketAddress( PORT ),
                new ReverseProtocolHandler(), cfg );
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

*/
public class ChatServer {
  public static void main(String [] args) {
    NioSocketAcceptor m_tcpAcceptor = new NioSocketAcceptor();
    m_tcpAcceptor.getFilterChain().addLast("codec",
        new ProtocolCodecFilter(new TextLineCodecFactory(
        Charset.forName("US-ASCII"))));
    m_tcpAcceptor.setHandler(new ChatProtocolHandler());
    try {
      m_tcpAcceptor.bind(new InetSocketAddress(7001));
      System.out.println("INFO: Chat server started.");
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

     * Connect via TCP to game server
     */
    NioSocketConnector connector = new NioSocketConnector();
    connector.getFilterChain().addLast("codec",
        new ProtocolCodecFilter(
            new TextLineCodecFactory(Charset.forName("US-ASCII"))));
    connector.setHandler(new TcpProtocolHandler(this));
    ConnectFuture cf = connector.connect(new InetSocketAddress(HOST, 7002));
    cf.addListener(new IoFutureListener() {
      public void operationComplete(IoFuture s) {
        try {
          if(s.getSession() != null && s.getSession().isConnected()) {
            m_packetGen.setTcpSession(s.getSession());
          } else {
            messageDialog("Connection timed out.\n"
                + "The server may be offline.\n"
                + "Contact an administrator for assistance.", getDisplay());
            HOST = "";
            m_packetGen = null;
          }
        }catch(RuntimeIoException e){
          messageDialog("Connection timed out.\n"
              + "The server may be offline.\n"
              + "Contact an administrator for assistance.", getDisplay());
          HOST = "";
          m_packetGen = null;
        }catch (Exception e) {
          e.printStackTrace();
          messageDialog("Connection timed out.\n"
              + "The server may be offline.\n"
              + "Contact an administrator for assistance.", getDisplay());
          HOST = "";
          m_packetGen = null;
        }
      }
    });
    /*
     * Connect via UDP to game server
     */
    NioDatagramConnector udp = new NioDatagramConnector();
    udp.getFilterChain().addLast("codec",
        new ProtocolCodecFilter(
            new TextLineCodecFactory(Charset.forName("US-ASCII"))));
    udp.setHandler(new UdpProtocolHandler(this));
    cf = udp.connect(new InetSocketAddress(HOST, 7005));
    cf.addListener(new IoFutureListener() {
      public void operationComplete(IoFuture s) {
        try {
          if(s.getSession().isConnected()) {
            m_packetGen.setUdpSession(s.getSession());
          } else {
            messageDialog("Connection timed out.\n"
                + "The server may be offline.\n"
                + "Contact an administrator for assistance.", getDisplay());
            HOST = "";
            m_packetGen = null;
          }
        }catch(RuntimeIoException e){
          messageDialog("Connection timed out.\n"
              + "The server may be offline.\n"
              + "Contact an administrator for assistance.", getDisplay());
          HOST = "";
          m_packetGen = null;
        } catch (Exception e) {
          e.printStackTrace();
          messageDialog("Connection timed out.\n"
              + "The server may be offline.\n"
              + "Contact an administrator for assistance.", getDisplay());
          HOST = "";
          m_packetGen = null;
        }
      }
    });
    /*
     * Connect via TCP to chat server
     */
    NioSocketConnector chat = new NioSocketConnector();
    chat.getFilterChain().addLast("codec",
        new ProtocolCodecFilter(
            new TextLineCodecFactory(Charset.forName("US-ASCII"))));
    chat.setHandler(new ChatProtocolHandler());
    ConnectFuture cf2 = connector.connect(new InetSocketAddress(CHATHOST, 7001));
    cf2.addListener(new IoFutureListener() {
      public void operationComplete(IoFuture s) {
        try {
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

        connector.setProxyIoSession(proxyIoSession);

        LineDelimiter delim = new LineDelimiter("\r\n");
        targetConnector.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                        .forName("UTF-8"), delim, delim)));

        connector.setHandler(new TelnetSessionHandler());

        IoSession session;
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

            sslFilter = new SslFilter(BogusSslContextFactory.getInstance(true));
            acceptor.getFilterChain().addLast("sslFilter", sslFilter);
        }
        acceptor.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                        .forName("UTF-8"))));

        EchoHandler handler = new EchoHandler();
        acceptor.setHandler(handler);
        acceptor.bind(new InetSocketAddress(0));
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

                    .getInstance(true));
            acceptor.getFilterChain().addLast("sslFilter", sslFilter);
        }
        acceptor.getFilterChain().addLast(
                "codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(Charset
                        .forName("UTF-8"))));

        EchoHandler handler = new EchoHandler();
        acceptor.bind(socketAddress, handler);
        System.out.println("MINA server started.");
View Full Code Here

Examples of org.apache.mina.filter.codec.textline.TextLineCodecFactory

        // Prepare the configuration
        SocketAcceptorConfig cfg = new SocketAcceptorConfig();
        cfg.setReuseAddress(true);
        Charset charset = Charset.forName("UTF-8");
        cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));

        // Bind
        acceptor.bind(new InetSocketAddress(port), new ReverseProtocolHandler(), cfg);
    }
View Full Code Here
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.