public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception { s_encodeAttempts++; if (LOG.isDebugEnabled()) { LOG.debug("Attempted encodes: "+s_encodeAttempts); } final ByteBuffer buffer = this.m_encoder.encode((SipMessage) message); //LOG.debug("Writing buffer: \n{}", MinaUtils.toAsciiString(buffer)); out.write(buffer); }
public void encode(final IoSession session, final Object message, final ProtocolEncoderOutput out) throws Exception { LOG.debug("{} encoding message: {}", this, message); final StunMessageEncoder encoder = new StunMessageEncoder(); final StunMessage stunMessage = (StunMessage) message; final ByteBuffer buf = encoder.encode(stunMessage); out.write(buf); }
private void noWrap(final StunMessage msg) { final StunMessageEncoder encoder = new StunMessageEncoder(); final ByteBuffer buf = encoder.encode(msg); if (buf == null) { m_log.error("Null buffer for message: {}", msg); } else { m_out.write(buf); } }
public void encode(final IoSession session, final Object message, ProtocolEncoderOutput out) throws Exception { final TcpFrameEncoder encoder = new TcpFrameEncoder(); final TcpFrame frame = (TcpFrame) message; final ByteBuffer buf = encoder.encode(frame); out.write(buf); }
private void wrapInSendIndication(final StunMessage msg) { final StunMessageEncoder encoder = new StunMessageEncoder(); final ByteBuffer buf = encoder.encode(msg); final InetSocketAddress remoteAddress = m_mapper.get(msg); if (remoteAddress == null) { m_log.warn("No matching transaction ID for: {} in {}", msg, m_mapper); return; } final byte[] bytes = MinaUtils.toByteArray(buf); m_log.debug("Sending TCP framed data of length: {}", bytes.length); final SendIndication indication = new SendIndication(remoteAddress, bytes); final ByteBuffer indicationBuf = encoder.encode(indication); m_out.write(indicationBuf); }
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER); if (encoder == null) { encoder = charset.newEncoder(); session.setAttribute(ENCODER, encoder); } String value = message.toString(); ByteBuffer buf = ByteBuffer.allocate(value.length()) .setAutoExpand(true); buf.putString(value, encoder); if (buf.position() > maxLineLength) { throw new IllegalArgumentException("Line length: " + buf.position()); } buf.putString(delimiter.getValue(), encoder); buf.flip(); out.write(buf); }
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { if (!(message instanceof Serializable)) { throw new NotSerializableException(); } ByteBuffer buf = ByteBuffer.allocate(64); buf.setAutoExpand(true); buf.putObject(message); int objectSize = buf.position() - 4; if (objectSize > maxObjectSize) { buf.release(); throw new IllegalArgumentException( "The encoded object is too big: " + objectSize + " (> " + maxObjectSize + ')'); } buf.flip(); out.write(buf); } }