1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.websocket.common.extensions.mux.op;
20
21 import java.nio.ByteBuffer;
22
23 import org.eclipse.jetty.util.BufferUtil;
24 import org.eclipse.jetty.util.StringUtil;
25 import org.eclipse.jetty.websocket.common.extensions.mux.MuxControlBlock;
26 import org.eclipse.jetty.websocket.common.extensions.mux.MuxOp;
27
28 public class MuxAddChannelRequest implements MuxControlBlock
29 {
30 public static final byte IDENTITY_ENCODING = (byte)0x00;
31 public static final byte DELTA_ENCODING = (byte)0x01;
32
33 private long channelId = -1;
34 private byte encoding;
35 private ByteBuffer handshake;
36 private byte rsv;
37
38 public long getChannelId()
39 {
40 return channelId;
41 }
42
43 public byte getEncoding()
44 {
45 return encoding;
46 }
47
48 public ByteBuffer getHandshake()
49 {
50 return handshake;
51 }
52
53 public long getHandshakeSize()
54 {
55 if (handshake == null)
56 {
57 return 0;
58 }
59 return handshake.remaining();
60 }
61
62 @Override
63 public int getOpCode()
64 {
65 return MuxOp.ADD_CHANNEL_REQUEST;
66 }
67
68 public byte getRsv()
69 {
70 return rsv;
71 }
72
73 public boolean isDeltaEncoded()
74 {
75 return (encoding == DELTA_ENCODING);
76 }
77
78 public boolean isIdentityEncoded()
79 {
80 return (encoding == IDENTITY_ENCODING);
81 }
82
83 public void setChannelId(long channelId)
84 {
85 this.channelId = channelId;
86 }
87
88 public void setEncoding(byte enc)
89 {
90 this.encoding = enc;
91 }
92
93 public void setHandshake(ByteBuffer handshake)
94 {
95 if (handshake == null)
96 {
97 this.handshake = null;
98 }
99 else
100 {
101 this.handshake = handshake.slice();
102 }
103 }
104
105 public void setHandshake(String rawstring)
106 {
107 setHandshake(BufferUtil.toBuffer(rawstring,StringUtil.__UTF8_CHARSET));
108 }
109
110 public void setRsv(byte rsv)
111 {
112 this.rsv = rsv;
113 }
114 }