View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.websocket.common.extensions.mux;
20  
21  import org.eclipse.jetty.websocket.common.OpCode;
22  import org.eclipse.jetty.websocket.common.WebSocketFrame;
23  
24  public class MuxedFrame extends WebSocketFrame
25  {
26      private long channelId = -1;
27  
28      public MuxedFrame()
29      {
30          super();
31      }
32  
33      public MuxedFrame(MuxedFrame frame)
34      {
35          super(frame);
36          this.channelId = frame.channelId;
37      }
38  
39      public long getChannelId()
40      {
41          return channelId;
42      }
43  
44      @Override
45      public void reset()
46      {
47          super.reset();
48          this.channelId = -1;
49      }
50  
51      public void setChannelId(long channelId)
52      {
53          this.channelId = channelId;
54      }
55  
56      @Override
57      public String toString()
58      {
59          StringBuilder b = new StringBuilder();
60          b.append(OpCode.name(getOpCode()));
61          b.append('[');
62          b.append("channel=").append(channelId);
63          b.append(",len=").append(getPayloadLength());
64          b.append(",fin=").append(isFin());
65          b.append(",rsv=");
66          b.append(isRsv1()?'1':'.');
67          b.append(isRsv2()?'1':'.');
68          b.append(isRsv3()?'1':'.');
69          b.append(",continuation=").append(isContinuation());
70          b.append(']');
71          return b.toString();
72      }
73  }