1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17 package nginx.unit.websocket;
18 
19 import java.nio.ByteBuffer;
20 
21 import javax.websocket.SendHandler;
22 
23 class MessagePart {
24     private final boolean fin;
25     private final int rsv;
26     private final byte opCode;
27     private final ByteBuffer payload;
28     private final SendHandler intermediateHandler;
29     private volatile SendHandler endHandler;
30     private final long blockingWriteTimeoutExpiry;
31 
MessagePart( boolean fin, int rsv, byte opCode, ByteBuffer payload, SendHandler intermediateHandler, SendHandler endHandler, long blockingWriteTimeoutExpiry)32     public MessagePart( boolean fin, int rsv, byte opCode, ByteBuffer payload,
33             SendHandler intermediateHandler, SendHandler endHandler,
34             long blockingWriteTimeoutExpiry) {
35         this.fin = fin;
36         this.rsv = rsv;
37         this.opCode = opCode;
38         this.payload = payload;
39         this.intermediateHandler = intermediateHandler;
40         this.endHandler = endHandler;
41         this.blockingWriteTimeoutExpiry = blockingWriteTimeoutExpiry;
42     }
43 
44 
isFin()45     public boolean isFin() {
46         return fin;
47     }
48 
49 
getRsv()50     public int getRsv() {
51         return rsv;
52     }
53 
54 
getOpCode()55     public byte getOpCode() {
56         return opCode;
57     }
58 
59 
getPayload()60     public ByteBuffer getPayload() {
61         return payload;
62     }
63 
64 
getIntermediateHandler()65     public SendHandler getIntermediateHandler() {
66         return intermediateHandler;
67     }
68 
69 
getEndHandler()70     public SendHandler getEndHandler() {
71         return endHandler;
72     }
73 
setEndHandler(SendHandler endHandler)74     public void setEndHandler(SendHandler endHandler) {
75         this.endHandler = endHandler;
76     }
77 
getBlockingWriteTimeoutExpiry()78     public long getBlockingWriteTimeoutExpiry() {
79         return blockingWriteTimeoutExpiry;
80     }
81 }
82 
83 
84