View Javadoc
1   /*
2    * Copyright 2016 The Lannister Project
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package net.anyflow.lannister.http;
18  
19  import java.util.List;
20  
21  import io.netty.channel.ChannelHandlerContext;
22  import io.netty.handler.codec.MessageToMessageDecoder;
23  import io.netty.handler.codec.http.websocketx.WebSocketFrame;
24  
25  public abstract class WebsocketFrameHandler extends MessageToMessageDecoder<WebSocketFrame> {
26  	public static final List<String> DEFAULT_SUBPROTOCOLS = null;
27  	public static final boolean ALLOW_EXTENSIONS = false;
28  	public static final int MAX_FRAME_SIZE = 65536;
29  
30  	public abstract String subprotocols();
31  
32  	public abstract String websocketPath();
33  
34  	public abstract boolean allowExtensions();
35  
36  	public abstract int maxFrameSize();
37  
38  	public abstract void websocketFrameReceived(ChannelHandlerContext ctx, WebSocketFrame wsframe);
39  
40  	@Override
41  	protected void decode(ChannelHandlerContext ctx, WebSocketFrame msg, List<Object> out) throws Exception {
42  		websocketFrameReceived(ctx, msg);
43  	}
44  }