/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.github.nettybook.ch4;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import java.net.SocketAddress;
/**
* Handler implementation for the echo client. It initiates the ping-pong
* traffic between the echo client and server by sending the first message to
* the server.
*/
public class EchoClientHandler1 extends ChannelOutboundHandlerAdapter {
@Override
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception {
System.out.println("connect 됨." + remoteAddress + "" + localAddress);
super.connect(ctx, remoteAddress, localAddress, promise);
};
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
System.out.println("close 됨.");
super.close(ctx, promise);
}
public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
System.out.println("deregister 됨.");
super.deregister(ctx, promise);
}
public void read(ChannelHandlerContext ctx) throws Exception {
System.out.println("read 됨.");
super.read(ctx);
}
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
System.out.println("write 됨.");
super.write(ctx, msg, promise);
}
public void flush(ChannelHandlerContext ctx) throws Exception {
System.out.println("flush 됨.");
super.flush(ctx);
}
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
System.out.println("disconnect 됨.");
super.disconnect(ctx, promise);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
}