@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void handleEvent(final StreamSourceChannel channel) {
final StreamSourceFrameChannel receiver = WebSocketChannel.this.receiver;
if (receiver != null) {
final ChannelListener listener = ((SimpleSetter) receiver.getReadSetter()).get();
if (listener != null) {
WebSocketLogger.REQUEST_LOGGER.debugf("Invoking read listener %s on %s", listener, receiver);
ChannelListeners.invokeChannelListener(receiver, listener);
} else {
WebSocketLogger.REQUEST_LOGGER.debugf("Suspending reads on channel %s due to no listener", receiver);
channel.suspendReads();
}
} else if (closeFrameReceived) {
channel.suspendReads();
} else {
final ChannelListener listener = receiveSetter.get();
if (listener != null) {
WebSocketLogger.REQUEST_LOGGER.debugf("Invoking receive listener", receiver);
ChannelListeners.invokeChannelListener(WebSocketChannel.this, listener);
} else {
channel.suspendReads();