Java Code Examples for org.jboss.netty.channel.Channel#getAttachment()

The following examples show how to use org.jboss.netty.channel.Channel#getAttachment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HealthCheckManager.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private PinpointServer getPinpointServer(Channel channel) {
    if (channel == null) {
        return null;
    }
    if (!channel.isConnected()) {
        return null;
    }

    Object attachment = channel.getAttachment();
    if (attachment instanceof PinpointServer) {
        return (PinpointServer) attachment;
    } else {
        return null;
    }
}
 
Example 2
Source File: PinpointServerAcceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private void closePinpointServer() {
    for (Channel channel : channelGroup) {
        DefaultPinpointServer pinpointServer = (DefaultPinpointServer) channel.getAttachment();

        if (pinpointServer != null) {
            pinpointServer.sendClosePacket();
        }
    }
}
 
Example 3
Source File: PinpointServerAcceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public List<PinpointSocket> getWritableSocketList() {
    List<PinpointSocket> pinpointServerList = new ArrayList<PinpointSocket>();

    for (Channel channel : channelGroup) {
        DefaultPinpointServer pinpointServer = (DefaultPinpointServer) channel.getAttachment();
        if (pinpointServer != null && pinpointServer.isEnableDuplexCommunication()) {
            pinpointServerList.add(pinpointServer);
        }
    }

    return pinpointServerList;
}
 
Example 4
Source File: PinpointServerAcceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
    final Channel channel = e.getChannel();

    DefaultPinpointServer pinpointServer = (DefaultPinpointServer) channel.getAttachment();
    if (pinpointServer != null) {
        pinpointServer.stop(released);
    }

    super.channelDisconnected(ctx, e);
}
 
Example 5
Source File: PinpointServerAcceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    final Channel channel = e.getChannel();

    DefaultPinpointServer pinpointServer = (DefaultPinpointServer) channel.getAttachment();
    if (pinpointServer != null) {
        Object message = e.getMessage();

        pinpointServer.messageReceived(message);
    }

    super.messageReceived(ctx, e);
}
 
Example 6
Source File: DefaultPinpointClientHandler.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private PinpointClientHandlerContext getChannelContext(Channel channel) {
    if (channel == null) {
        throw new NullPointerException("channel");
    }
    return (PinpointClientHandlerContext) channel.getAttachment();
}