public void run() { if(!executed) { executed = true; requests.remove(requestId); if(heartBeatMonitor!=null) { heartBeatMonitor.stop(); heartBeatMonitor = null; } transport.stop(new Task() { @Override public void run() { listener.onDisconnected(); if (onComplete != null) { onComplete.onSuccess(null); } } }); } } };
public boolean full() { queue.assertExecuting(); return this.transport.full(); }
public void onSuccess(final Transport transport) { transport.setTransportListener(new DefaultTransportListener() { @Override public void onTransportFailure(IOException error) { transport.resumeRead(); if( mqtt.connect.clientId() == null ) { String id = hex(transport.getLocalAddress())+Long.toHexString(System.currentTimeMillis()/1000); if(id.length() > 23) { id = id.substring(0,23); boolean accepted = transport.offer(encoded); mqtt.tracer.onSend(encoded); mqtt.tracer.debug("Logging in");
mqtt.blockingExecutor = MQTT.getBlockingThreadPool(); transport.setBlockingExecutor(mqtt.blockingExecutor); transport.setDispatchQueue(queue); transport.setProtocolCodec(new MQTTProtocolCodec()); transport.setTransportListener(new DefaultTransportListener(){ @Override public void onTransportConnected() { transport.start(NOOP);
private void doPumpOut() { switch(state) { case CONNECTING: case CONNECTED: break; default: return; } int size = hawtdispatchTransport.getProtocolCodec().getWriteBufferSize(); byte data[] = new byte[size]; boolean done = false; int pumped = 0; while( !done && !hawtdispatchTransport.full() ) { int count = protonTransport.output(data, 0, size); if( count > 0 ) { pumped += count; boolean accepted = hawtdispatchTransport.offer(new Buffer(data, 0, count)); assert accepted: "Should be accepted since the transport was not full"; } else { done = true; } } if( pumped > 0 && !hawtdispatchTransport.full() ) { listener.processRefill(); } }
public void suspend() { suspendChanges.incrementAndGet(); if( suspendCount.incrementAndGet() == 1 && this.transport!=null ) { this.transport.suspendRead(); if(this.heartBeatMonitor!=null){ this.heartBeatMonitor.suspendRead(); } } }
public void onSessionEstablished(Transport transport) { this.transport = transport; if( suspendCount.get() > 0 ) { this.transport.suspendRead(); this.transport.setTransportListener(new DefaultTransportListener() { @Override public void onTransportCommand(Object command) {
public void onTransportConnected() { transport.resumeRead(); StompFrame frame = new StompFrame(CONNECT); if (version != null) { frame.addHeader(ACCEPT_VERSION, StompFrame.encodeHeader(version)); } if (host != null) { frame.addHeader(HOST, StompFrame.encodeHeader(host)); } if (login != null) { frame.addHeader(LOGIN, StompFrame.encodeHeader(login)); } if (passcode != null) { frame.addHeader(PASSCODE, StompFrame.encodeHeader(passcode)); } if (clientId != null) { frame.addHeader(CLIENT_ID, StompFrame.encodeHeader(clientId)); } if( customHeaders!=null ) { for (Object key : customHeaders.keySet()) { frame.addHeader(StompFrame.encodeHeader(key.toString()), StompFrame.encodeHeader(customHeaders.get(key).toString())); } } boolean accepted = transport.offer(frame); assert accepted: "First frame should always be accepted by the transport"; }
public void resume() { suspendChanges.incrementAndGet(); if( suspendCount.decrementAndGet() == 0 && this.transport!=null ) { this.transport.resumeRead(); if(this.heartBeatMonitor!=null){ this.heartBeatMonitor.resumeRead(); } } }
private void send(Request request) { if( failure !=null ) { if( request.cb!=null ) { request.cb.onFailure(failure); } } else { // Put the request in the map before sending it over the wire. if(request.id!=0) { this.requests.put(request.id, request); } if( overflow.isEmpty() && transport!=null && transport.offer(request.frame) ) { mqtt.tracer.onSend(request.frame); if(request.id==0) { if( request.cb!=null ) { ((Callback<Void>)request.cb).onSuccess(null); } } } else { // Remove it from the request. this.requests.remove(request.id); overflow.addLast(request); } } }
public ProtocolCodec getProtocolCodec() { return next.getProtocolCodec(); }
public void setTransportListener(TransportListener transportListener) { next.setTransportListener(transportListener); }
private void bind(final Transport transport) { this.hawtdispatchTransport = transport; this.protonTransport = (ProtonJTransport) org.apache.qpid.proton.engine.Transport.Factory.create(); this.protonTransport.bind(connection); if( transport.getProtocolCodec()==null ) { try { transport.setProtocolCodec(new AmqpProtocolCodec()); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override void process() { if (sasl != null) { sasl = listener.processSaslEvent(sasl); } if (sasl == null) { // once sasl handshake is done.. we need to read the protocol header again. ((AmqpProtocolCodec) hawtdispatchTransport.getProtocolCodec()).readProtocolHeader(); hawtdispatchTransport.setTransportListener(new AmqpTransportListener()); } } }
public void on_transport_connected() { codec = (MQTTProtocolCodec) connection().transport().getProtocolCodec(); AcceptingConnectorDTO connector_config = (AcceptingConnectorDTO) connection().connector().config(); config = find_config(connector_config); protocol_filters.addAll(ProtocolFilter3$.MODULE$.create_filters(config.protocol_filters, this)); security_context.local_address_$eq(connection().transport().getLocalAddress()); security_context.remote_address_$eq(connection().transport().getRemoteAddress()); security_context.connector_id_$eq(connection().connector().id()); security_context.certificates_$eq(connection().certificates());
public DispatchQueue getDispatchQueue() { return next.getDispatchQueue(); }
public void setProtocolCodec(ProtocolCodec protocolCodec) throws Exception { next.setProtocolCodec(protocolCodec); }
public SocketAddress getLocalAddress() { return next.getLocalAddress(); }