private void write(final SipMessage message, final IoSession io, final boolean listen) { final WriteFuture wf = io.write(message); if (listen) { wf.addListener(this); } }
public void run() { // Note there is no Via handling here. This is for UASes // sending responses, so we don't need to strip any Vias. try { final WriteFuture wf = m_ioSession.write(message); wf.addListener(SipClientImpl.this); } catch (final Throwable t) { m_log.error("Unexpected throwable", t); } } };
public void sendConnectRequest(final InetSocketAddress remoteAddress) { final ConnectRequest request = new ConnectRequest(remoteAddress); this.m_ioSession.write(request); }
private synchronized void write(ByteBuffer buf) throws IOException { checkClosed(); lastWriteFuture = session.write(buf); }
public void messageReceived(final IoSession session, final Object message) { m_log.debug("Received message on TCP frame: {}", message); final TcpFrame frame = (TcpFrame) message; final byte[] data = frame.getData(); final IoSession localSession = m_remoteToLocalSessions.get(session); m_log.debug("Writing raw data to local session"); localSession.write(ByteBuffer.wrap(data)); }
public WriteFuture writeCrlfKeepAlive(final IoSession io) { if (LOG.isDebugEnabled()) { LOG.debug("Writing double CRLF"); } final String doubleCrlf = "\r\n\r\n"; final ByteBuffer buf; try { buf = ByteBuffer.wrap(doubleCrlf.getBytes("US-ASCII")); } catch (final UnsupportedEncodingException e) { LOG.error("Bad encoding??", e); return null; } return io.write(buf); }
protected synchronized void write(final T message) throws IOException { m_log.debug("Writing message: {}", message); checkClosed(); m_lastWriteFuture = m_ioSession.write(message); m_lastWriteFuture.join(m_ioSession.getWriteTimeoutInMillis()); m_log.debug("Finshing writing message..."); }
public void onData(final InetSocketAddress remoteAddress, final IoSession session, final byte[] data) { m_log.debug("Received data message"); final IoSession localSession = onRemoteAddressOpened(remoteAddress, session); final ByteBuffer dataBuf = ByteBuffer.wrap(data); localSession.write(dataBuf); m_log.debug("Local bytes written: {}", localSession.getWrittenBytes()); }
/** * Splits the main read buffer into smaller buffers that will * fit in TCP frame messages. * * @param buffer The main read buffer to split. */ private void sendSplitBuffers(final ByteBuffer buffer) { // Break up the data into smaller chunks. final Collection<byte[]> buffers = MinaUtils.splitToByteArrays(buffer, LENGTH_LIMIT); m_log.debug("Split single buffer into {}", buffers.size()); for (final byte[] data : buffers) { m_log.debug("Sending buffer with capacity: {}", data.length); final TcpFrame frame = new TcpFrame(data); m_ioSession.write(frame); } } }
/** * Splits the main read buffer into smaller buffers that will * fit in TURN messages. * * @param remoteHost The host the data came from. * @param buffer The main read buffer to split. * @param session The session for reading and writing data. * @param nextFilter The next class for processing the message. */ private void sendSplitBuffers(final ByteBuffer buffer) { // Break up the data into smaller chunks. final Collection<byte[]> buffers = MinaUtils.splitToByteArrays(buffer, LENGTH_LIMIT); m_log.debug("Split single buffer into {}", buffers.size()); for (final byte[] data : buffers) { m_log.debug("Sending buffer with capacity: {}", data.length); //m_log.info("Sending bytes: {}", data); final SendIndication indication = new SendIndication(m_remoteAddress, data); m_ioSession.write(indication); } } }
public Object visitBindingRequest(final BindingRequest binding) { LOG.debug("STUN server visiting binding request..."); final InetSocketAddress address = (InetSocketAddress) m_session.getRemoteAddress(); final UUID transactionId = binding.getTransactionId(); final StunMessage response = new BindingSuccessResponse(transactionId.getRawBytes(), address); this.m_session.write(response); return null; } }
public void operationComplete(final IoFuture ioFuture) { if (!ioFuture.isReady()) { m_log.warn("Future not ready?"); return; } try { m_ioSession = ioFuture.getSession(); } catch (final RuntimeIOException e) { // This seems to get thrown when we can't connect at all. m_log.warn("Could not connect to TURN server at: " + stunServerAddress, e); // m_connectionListener.connectionFailed(); return; } if (m_ioSession == null || !m_ioSession.isConnected()) { m_log.error("Could not create session"); throw new RuntimeIoException("Could not get session"); } // TODO: We should not need this. final TurnStunMessageMapper mapper = new TurnStunMessageMapperImpl(); m_ioSession.setAttribute("REMOTE_ADDRESS_MAP", mapper); final AllocateRequest msg = new AllocateRequest(); m_log.debug("Sending allocate request to write handler..."); m_ioSession.write(msg); } };
session.write(request);
LOG.info("Writing binding request: {} on {}", bindingRequest, this.m_ioSession); this.m_ioSession.write(bindingRequest);
this.m_ioSession.write(response);