Better example that does not use attachment
This commit is contained in:
parent
696b5a1f45
commit
ab1a598534
@ -42,19 +42,17 @@ package org.jboss.netty.channel;
|
||||
* public class MyHandler extends {@link SimpleChannelHandler}
|
||||
* implements {@link LifeCycleAwareChannelHandler} {
|
||||
*
|
||||
* private {@link ChannelHandlerContext} ctx;
|
||||
* <b>private {@link ChannelHandlerContext} ctx;</b>
|
||||
*
|
||||
* public void beforeAdd({@link ChannelHandlerContext} ctx) {
|
||||
* this.ctx = ctx;
|
||||
* <b>this.ctx = ctx;</b>
|
||||
* }
|
||||
*
|
||||
* {@code @Override}
|
||||
* public void messageReceived({@link ChannelHandlerContext} ctx, {@link MessageEvent} evt) {
|
||||
* ctx.setAttachment(evt.getMessage());
|
||||
* }
|
||||
*
|
||||
* public Object getLastReceivedMessage() {
|
||||
* return ctx.getAttachment();
|
||||
* public void login(String username, password) {
|
||||
* {@link Channels}.write(
|
||||
* <b>this.ctx</b>,
|
||||
* {@link Channels}.succeededFuture(<b>this.ctx</t>.getChannel()),
|
||||
* new LoginMessage(username, password));
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
|
Loading…
x
Reference in New Issue
Block a user