@Override
	public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {

		try {
			// Cast to a String first.
			// We know it is a String because we put some codec in
			// TelnetPipelineFactory.
			String request = ((String) e.getMessage()).trim();

			if (!authendicate) {
				if (AUTH.equals(request)) {
					authendicate = true;
					e.getChannel().write(WELCOME);
				} else {
					ChannelFuture future = e.getChannel().write(BAD);
					future.addListener(ChannelFutureListener.CLOSE);
				}
			} else {
				TelnetCommandDecoder decoder = new TelnetCommandDecoder(request);

				Configration conf = Configration.getInstance();

				switch (decoder.getCommand()) {
				case DUMP:
					String mesge = conf.dump();
					e.getChannel().write(mesge + PROPMT);
					break;
				case DEL:
					ProxyItem item = decoder.getRemoveProxy();
					conf.removeProxyItem(item.host, item.port);
					e.getChannel().write(conf.dump() + PROPMT);
					break;
				case ADD:
					ProxyItem proxyitem = decoder.getAddProxy();
					conf.addProxyItem(proxyitem);
					e.getChannel().write(conf.dump() + PROPMT);
					break;
				case HELP:
					e.getChannel().write(HELP);
					break;
				case CLOSE:
					e.getChannel().write(CLOSEING);
					e.getChannel().close();
					break;
				case EMPTY:
					e.getChannel().write(PROPMT);
					break;
				default:
					e.getChannel().write(UNKNOWNCOMMAND);
					break;
				}
			}
		} catch (Exception ex) {
			e.getChannel().write("Error: " + ex.getMessage() + "\n" + PROPMT);
		}

	}