@Override public InetSocketAddress getRemoteAddress() { return muxer.getRemoteAddress(); }
@Override public void incomingFrame(Frame frame) { this.muxer.incomingFrame(frame); }
@Override public boolean isOpen() { return isActive() && muxer.isOpen(); }
/** * 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? }
@Override public void onMuxException(MuxException e) { if (e instanceof MuxPhysicalConnectionException) { mustFailPhysicalConnection((MuxPhysicalConnectionException)e); } LOG.warn(e); // TODO: handle other (non physical) mux exceptions how? }
@Override public void configureMuxer(Muxer muxer) { muxer.setAddServer(new MuxAddHandler()); } }
@Override public void setConnection(LogicalConnection connection) { super.setConnection(connection); if (muxer != null) { throw new RuntimeException("Cannot reset muxer physical connection once established"); } this.muxer = new Muxer(connection); configureMuxer(this.muxer); } }
public MuxChannel(long channelId, Muxer muxer) { this.channelId = channelId; this.muxer = muxer; this.policy = muxer.getPolicy().clonePolicy(); this.suspendToken = new AtomicBoolean(false); this.ioState = new IOState(); ioState.setState(ConnectionState.CONNECTING); this.inputClosed = new AtomicBoolean(false); this.outputClosed = new AtomicBoolean(false); }
/** * Frames destined for the Muxer */ @Override public void outgoingFrame(Frame frame, WriteCallback callback) { muxer.output(channelId,frame,callback); }
@Override public void configureMuxer(Muxer muxer) { muxer.setAddClient(new MuxClientAddHandler()); } }
/** * 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? }
@Override public void onMuxException(MuxException e) { if (e instanceof MuxPhysicalConnectionException) { mustFailPhysicalConnection((MuxPhysicalConnectionException)e); } LOG.warn(e); // TODO: handle other (non physical) mux exceptions how? }
@Override public void configureMuxer(Muxer muxer) { muxer.setAddServer(new MuxAddHandler()); } }
@Override public void setConnection(LogicalConnection connection) { super.setConnection(connection); if (muxer != null) { throw new RuntimeException("Cannot reset muxer physical connection once established"); } this.muxer = new Muxer(connection); configureMuxer(this.muxer); } }
public MuxChannel(long channelId, Muxer muxer) { this.channelId = channelId; this.muxer = muxer; this.policy = muxer.getPolicy().clonePolicy(); this.suspendToken = new AtomicBoolean(false); this.ioState = new IOState(); ioState.setState(ConnectionState.CONNECTING); this.inputClosed = new AtomicBoolean(false); this.outputClosed = new AtomicBoolean(false); }
/** * Frames destined for the Muxer */ @Override public void outgoingFrame(Frame frame, WriteCallback callback) { muxer.output(channelId,frame,callback); }
@Override public void configureMuxer(Muxer muxer) { muxer.setAddClient(new MuxClientAddHandler()); } }
MuxChannel channel = getChannel(channelId,false);
/** * Incoming parser errors */ @Override public void incomingError(WebSocketException e) { MuxDropChannel.Reason reason = MuxDropChannel.Reason.PHYSICAL_CONNECTION_FAILED; String phrase = String.format("%s: %s", e.getClass().getName(), e.getMessage()); mustFailPhysicalConnection(new MuxPhysicalConnectionException(reason,phrase)); }
@Override public InetSocketAddress getRemoteAddress() { return muxer.getRemoteAddress(); }