public MuxPhysicalConnectionException(MuxDropChannel.Reason code, String phrase) { super(phrase); drop = new MuxDropChannel(0,code,phrase); }
/** * Drop with reason code and optional phrase * * @param channelId * the logical channel Id to perform drop against. * @param code * reason code * @param phrase * optional human readable phrase */ public MuxDropChannel(long channelId, int code, String phrase) { this(channelId, Reason.valueOf(code), phrase); }
public void setHandshake(String rawstring) { setHandshake(BufferUtil.toBuffer(rawstring,StringUtil.__UTF8_CHARSET)); }
byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (byte)((op.getRsv() & 0x07) << 2); // rsv b |= (op.getEncoding() & 0x03); // enc writeChannelId(payload,op.getChannelId()); write139Buffer(payload,op.getHandshake()); break; byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (op.isFailed()?0x10:0x00); // failure bit b |= (byte)((op.getRsv() & 0x03) << 2); // rsv b |= (op.getEncoding() & 0x03); // enc writeChannelId(payload,op.getChannelId()); if (op.getHandshake() != null) write139Buffer(payload,op.getHandshake()); byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (byte)(op.getRsv() & 0x1F); // rsv writeChannelId(payload,op.getChannelId()); write139Buffer(payload,op.asReasonBuffer()); break; byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (byte)(op.getRsv() & 0x1F); // rsv writeChannelId(payload,op.getChannelId());
MuxAddChannelRequest op = new MuxAddChannelRequest(); op.setRsv((byte)((b & 0x1C) >> 2)); op.setEncoding((byte)(b & 0x03)); op.setChannelId(readChannelId(buffer)); long handshakeSize = read139EncodedSize(buffer); op.setHandshake(readBlock(buffer,handshakeSize)); events.onMuxAddChannelRequest(op); break; MuxAddChannelResponse op = new MuxAddChannelResponse(); op.setFailed((b & 0x10) != 0); op.setRsv((byte)((byte)(b & 0x0C) >> 2)); op.setEncoding((byte)(b & 0x03)); op.setChannelId(readChannelId(buffer)); long handshakeSize = read139EncodedSize(buffer); op.setHandshake(readBlock(buffer,handshakeSize)); events.onMuxAddChannelResponse(op); break; long reasonSize = read139EncodedSize(buffer); ByteBuffer reasonBuf = readBlock(buffer,reasonSize); MuxDropChannel op = MuxDropChannel.parse(channelId,reasonBuf); op.setRsv(rsv); events.onMuxDropChannel(op); break; MuxFlowControl op = new MuxFlowControl(); op.setRsv((byte)(b & 0x1F)); op.setChannelId(readChannelId(buffer));
/** * Incoming mux control block, destined for the control channel (id 0) */ @Override public void onMuxNewChannelSlot(MuxNewChannelSlot slot) { if (policy.getBehavior() == WebSocketBehavior.SERVER) { throw new MuxPhysicalConnectionException(MuxDropChannel.Reason.UNKNOWN_MUX_CONTROL_BLOCK,"NewChannelSlot not allowed per spec"); } if (slot.isFallback()) { if (slot.getNumberOfSlots() == 0) { throw new MuxPhysicalConnectionException(MuxDropChannel.Reason.UNKNOWN_MUX_CONTROL_BLOCK,"Cannot have 0 number of slots during fallback"); } if (slot.getInitialSendQuota() == 0) { throw new MuxPhysicalConnectionException(MuxDropChannel.Reason.UNKNOWN_MUX_CONTROL_BLOCK,"Cannot have 0 initial send quota during fallback"); } } // TODO: handle channel slot }
if (response.getRsv() != 0) long channelId = response.getChannelId(); MuxChannel channel = getChannel(channelId,false);
public void setHandshake(String responseHandshake) { setHandshake(BufferUtil.toBuffer(responseHandshake,StringUtil.__UTF8_CHARSET)); }
/** * Incoming mux control block, destined for the control channel (id 0) */ @Override public void onMuxDropChannel(MuxDropChannel drop) { // Process channel long channelId = drop.getChannelId(); MuxChannel channel = getChannel(channelId,false); String reason = "Mux " + drop.toString(); reason = StringUtil.truncate(reason,(WebSocketFrame.MAX_CONTROL_PAYLOAD - 2)); channel.close(StatusCode.PROTOCOL,reason); // TODO: set channel to inactive? }
byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (byte)((op.getRsv() & 0x07) << 2); // rsv b |= (op.getEncoding() & 0x03); // enc writeChannelId(payload,op.getChannelId()); write139Buffer(payload,op.getHandshake()); break; byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (op.isFailed()?0x10:0x00); // failure bit b |= (byte)((op.getRsv() & 0x03) << 2); // rsv b |= (op.getEncoding() & 0x03); // enc writeChannelId(payload,op.getChannelId()); if (op.getHandshake() != null) write139Buffer(payload,op.getHandshake()); byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (byte)(op.getRsv() & 0x1F); // rsv writeChannelId(payload,op.getChannelId()); write139Buffer(payload,op.asReasonBuffer()); break; byte b = (byte)((op.getOpCode() & 0x07) << 5); // opcode b |= (byte)(op.getRsv() & 0x1F); // rsv writeChannelId(payload,op.getChannelId());
MuxAddChannelRequest op = new MuxAddChannelRequest(); op.setRsv((byte)((b & 0x1C) >> 2)); op.setEncoding((byte)(b & 0x03)); op.setChannelId(readChannelId(buffer)); long handshakeSize = read139EncodedSize(buffer); op.setHandshake(readBlock(buffer,handshakeSize)); events.onMuxAddChannelRequest(op); break; MuxAddChannelResponse op = new MuxAddChannelResponse(); op.setFailed((b & 0x10) != 0); op.setRsv((byte)((byte)(b & 0x0C) >> 2)); op.setEncoding((byte)(b & 0x03)); op.setChannelId(readChannelId(buffer)); long handshakeSize = read139EncodedSize(buffer); op.setHandshake(readBlock(buffer,handshakeSize)); events.onMuxAddChannelResponse(op); break; long reasonSize = read139EncodedSize(buffer); ByteBuffer reasonBuf = readBlock(buffer,reasonSize); MuxDropChannel op = MuxDropChannel.parse(channelId,reasonBuf); op.setRsv(rsv); events.onMuxDropChannel(op); break; MuxFlowControl op = new MuxFlowControl(); op.setRsv((byte)(b & 0x1F)); op.setChannelId(readChannelId(buffer));
/** * Incoming mux control block, destined for the control channel (id 0) */ @Override public void onMuxNewChannelSlot(MuxNewChannelSlot slot) { if (policy.getBehavior() == WebSocketBehavior.SERVER) { throw new MuxPhysicalConnectionException(MuxDropChannel.Reason.UNKNOWN_MUX_CONTROL_BLOCK,"NewChannelSlot not allowed per spec"); } if (slot.isFallback()) { if (slot.getNumberOfSlots() == 0) { throw new MuxPhysicalConnectionException(MuxDropChannel.Reason.UNKNOWN_MUX_CONTROL_BLOCK,"Cannot have 0 number of slots during fallback"); } if (slot.getInitialSendQuota() == 0) { throw new MuxPhysicalConnectionException(MuxDropChannel.Reason.UNKNOWN_MUX_CONTROL_BLOCK,"Cannot have 0 initial send quota during fallback"); } } // TODO: handle channel slot }
if (response.getRsv() != 0) long channelId = response.getChannelId(); MuxChannel channel = getChannel(channelId,false);
public MuxPhysicalConnectionException(MuxDropChannel.Reason code, String phrase) { super(phrase); drop = new MuxDropChannel(0,code,phrase); }
/** * Drop with reason code and optional phrase * * @param channelId * the logical channel Id to perform drop against. * @param code * reason code * @param phrase * optional human readable phrase */ public MuxDropChannel(long channelId, int code, String phrase) { this(channelId, Reason.valueOf(code), phrase); }
public void setHandshake(String rawstring) { setHandshake(BufferUtil.toBuffer(rawstring,StringUtil.__UTF8_CHARSET)); }
public void setHandshake(String responseHandshake) { setHandshake(BufferUtil.toBuffer(responseHandshake,StringUtil.__UTF8_CHARSET)); }
/** * Incoming mux control block, destined for the control channel (id 0) */ @Override public void onMuxDropChannel(MuxDropChannel drop) { // Process channel long channelId = drop.getChannelId(); MuxChannel channel = getChannel(channelId,false); String reason = "Mux " + drop.toString(); reason = StringUtil.truncate(reason,(WebSocketFrame.MAX_CONTROL_PAYLOAD - 2)); channel.close(StatusCode.PROTOCOL,reason); // TODO: set channel to inactive? }
public MuxPhysicalConnectionException(MuxDropChannel.Reason code, String phrase, Throwable t) { super(phrase,t); drop = new MuxDropChannel(0,code,phrase); }
public MuxPhysicalConnectionException(MuxDropChannel.Reason code, String phrase, Throwable t) { super(phrase,t); drop = new MuxDropChannel(0,code,phrase); }