Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2012 Red Hat, Inc., and individual contributors
   * as indicated by the @author tags.
   *
   * Licensed 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 io.undertow.websockets.core;
 
 
Base class for processes Frame bases StreamSourceChannels.

Author(s):
Norman Maurer
 
 
     protected final WebSocketFrameType type;
 
     private boolean finalFragment;
     private final int rsv;
     private final long payloadSize;
 
     protected StreamSourceFrameChannel(WebSocketChannel wsChannelWebSocketFrameType typelong payloadSizePooled<ByteBufferpooledlong frameLength) {
         this(wsChanneltypepayloadSize, 0, truepooledframeLength);
     }
 
     protected StreamSourceFrameChannel(WebSocketChannel wsChannelWebSocketFrameType typelong payloadSizeint rsvboolean finalFragmentPooled<ByteBufferpooledlong frameLength) {
         super(wsChannelpooledframeLength);
         this. = type;
         this. = finalFragment;
         this. = rsv;
         this. = payloadSize;
     }

    
Return the WebSocketFrameType or null if its not known at the calling time.
 
     public WebSocketFrameType getType() {
         return ;
     }

    
Flag to indicate if this frame is the final fragment in a message. The first fragment (frame) may also be the final fragment.
 
     public boolean isFinalFragment() {
         return ;
     }

    
Return the rsv which is used for extensions.
 
     public int getRsv() {
         return ;
     }
 
     int getWebSocketFrameCount() {
         return getReadFrameCount();
     }

    
Discard the frame, which means all data that would be part of the frame will be discarded.

Once all is discarded it will call io.undertow.server.protocol.framed.AbstractFramedStreamSourceChannel.close()

 
     public void discard() throws IOException {
         if (isOpen()) {
             ChannelListener<StreamSourceChanneldrainListener = ChannelListeners.drainListener(.,
                     new ChannelListener<StreamSourceChannel>() {
                         @Override
                         public void handleEvent(StreamSourceChannel channel) {
                             IoUtils.safeClose(StreamSourceFrameChannel.this);
                         }
                     }, new ChannelExceptionHandler<StreamSourceChannel>() {
                         @Override
                         public void handleException(StreamSourceChannel channelIOException exception) {
                             getFramedChannel().markReadsBroken(exception);
                        }
                    }
            );
            getReadSetter().set(drainListener);
            resumeReads();
        } else {
            close();
        }
    }
    @Override
    protected WebSocketChannel getFramedChannel() {
        return (WebSocketChannelsuper.getFramedChannel();
    }
        return getFramedChannel();
    }
    public void finalFrame() {
        this.lastFrame();
        this. = true;
    }
New to GrepCode? Check out our FAQ X