private void assertTopMostVia( final SipMessage msg, final String host, final int port, final String transport) throws Exception { final ViaHeader via = this.headerFactory.createViaHeader(Buffers.wrap(host), port, Buffers.wrap(transport), null); msg.addHeaderFirst(via); final ViaHeader topMostVia = msg.getViaHeader(); assertThat(topMostVia.getBranch(), not((Buffer) null)); assertThat(topMostVia.getHost().toString(), is(host)); assertThat(topMostVia.getPort(), is(port)); assertThat(topMostVia.getTransport().toString(), is(transport)); }
@Override public ContactHeader clone() { final Buffer buffer = Buffers.createBuffer(1024); transferValue(buffer); try { return ContactHeader.frame(buffer); } catch (final SipParseException e) { throw new RuntimeException("Unable to clone the Contact-header", e); } }
static SipMessage frame(final byte[] buffer) throws SipParseException, IOException { assertNotNull(buffer, "Byte-array cannot be null"); return SipParser.frame(Buffers.wrap(buffer)); }
/** * @param buffer * @return * @throws IOException */ static SipMessage frame(final String buffer) throws SipParseException, IOException { assertNotEmpty(buffer, "Buffer cannot be null or the empty string"); return SipParser.frame(Buffers.wrap(buffer)); }
/* * (non-Javadoc) * * @see io.pkts.packet.Packet#write(java.io.OutputStream) */ @Override public void write(final OutputStream out, final Buffer payload) throws IOException { this.parent.write(out, Buffers.wrap(this.msg.toBuffer(), payload)); }
/** @author [email protected] */ public interface ContactHeader extends HeaderAddress, SipHeader, Parameters { Buffer NAME = Buffers.wrap("Contact"); ContactHeader clone(); }