@Override public boolean isConnected() { return channel != null && channel.isConnected(); }
public boolean isConnected() { return channel.isConnected(); }
@Override public boolean isConnected() { return javaChannel().isConnected(); }
@Override public boolean isConnected() { return javaChannel().isConnected(); }
@Override public boolean isConnected() { return javaChannel().isConnected(); }
public InetSocketAddress readFromAddress () throws IOException { DatagramChannel datagramChannel = this.datagramChannel; if (datagramChannel == null) throw new SocketException("Connection is closed."); lastCommunicationTime = System.currentTimeMillis(); if(!datagramChannel.isConnected()) return (InetSocketAddress)datagramChannel.receive(readBuffer); // always null on Android >= 5.0 datagramChannel.read(readBuffer); return connectedAddress; }
@Override public void open() throws IOException { if (channel == null) { channel = DatagramChannel.open(); if (maxSendBufferSize > 0) { channel.setOption(StandardSocketOptions.SO_SNDBUF, maxSendBufferSize); final int actualSendBufSize = channel.getOption(StandardSocketOptions.SO_SNDBUF); if (actualSendBufSize < maxSendBufferSize) { logger.warn("Attempted to set Socket Send Buffer Size to " + maxSendBufferSize + " bytes but could only set to " + actualSendBufSize + "bytes. You may want to " + "consider changing the Operating System's maximum receive buffer"); } } } if (!channel.isConnected()) { channel.connect(new InetSocketAddress(InetAddress.getByName(host), port)); } }
@Override public boolean hasExpired(SlotInfo<? extends DatagramChannelPoolable> info) throws Exception { DatagramChannel channel = info.getPoolable().getChannel(); return !channel.isConnected() || !channel.isOpen(); } }
if (sendDatagramChannel.isConnected())
/** * {@inheritDoc} */ @Override protected int writeDirect(Object message) { try { // Check that we can write into the channel if (!isRegisteredForWrite()) { // We don't have pending writes // First, connect if we aren't already connected if (!((DatagramChannel) channel).isConnected()) { ((DatagramChannel) channel).connect(remoteAddress); } // And try to write the data. We will either write them all, // or none return ((DatagramChannel) channel).write((ByteBuffer) message); } else { LOG.debug("Cannot write"); return -1; } } catch (final IOException e) { LOG.error("Exception while reading : ", e); processException(e); return -1; } }
@Override protected boolean isConnected(DatagramChannel channel) { return channel.isConnected(); } }
public int getRemotePort() { if(this.dataChannel != null && this.dataChannel.isConnected()) { try { return ((InetSocketAddress) this.dataChannel.getRemoteAddress()).getPort(); } catch (IOException e) { logger.error("Could not lookup the remote peer port", e); } } return 0; }
public boolean isAvailable() { // The channel is available is is connected boolean available = this.dataChannel != null && this.dataChannel.isConnected(); // In case of WebRTC calls the DTLS handshake must be completed if (this.secure) { available = available && this.dtlsHandler.isHandshakeComplete(); } return available; }
public boolean isAvailable() { // The channel is available is is connected boolean available = this.dataChannel != null && this.dataChannel.isConnected(); // In case of WebRTC calls the DTLS handshake must be completed if (this.secure) { available = available && this.dtlsHandler.isHandshakeComplete(); } return available; }
public int getRemotePort() { if(this.dataChannel != null && this.dataChannel.isConnected()) { try { return ((InetSocketAddress) this.dataChannel.getRemoteAddress()).getPort(); } catch (IOException e) { logger.error("Could not lookup the remote peer port", e); } } return 0; }
@Override public boolean isConnected() { return javaChannel().isConnected(); }
protected void send(Frame frame) { ///XXX WebRTC hack - dataChannel only available after ICE negotiation! if (rtpChannel != null && rtpChannel.isConnected()) tx.perform(frame); }
public String getRemoteHost() { if(this.dataChannel != null && this.dataChannel.isConnected()) { try { return ((InetSocketAddress) this.dataChannel.getRemoteAddress()).getHostString(); } catch (IOException e) { logger.error("Could not lookup the remote peer address", e); } } return ""; }
public int getRemotePort() { if(this.dataChannel != null && this.dataChannel.isConnected()) { try { return ((InetSocketAddress) this.dataChannel.getRemoteAddress()).getPort(); } catch (IOException e) { logger.error("Could not lookup the remote peer port", e); } } return 0; }
@Override public void send(byte[] buf, int off, int len) throws IOException { if (!hasTimeout()) { if (this.channel != null && this.channel.isOpen() && this.channel.isConnected()) { this.channel.send(ByteBuffer.wrap(buf, off, len), channel.getRemoteAddress()); } else { logger.warn("Handler skipped send operation because channel is not open or connected."); } } else { logger.warn("Handler has timed out so send operation will be skipped."); } }