public StompFrame receive(long timeOut) throws Exception { stompSocket.setSoTimeout((int)timeOut); InputStream is = stompSocket.getInputStream(); StompWireFormat wf = new StompWireFormat(); wf.setStompVersion(version); DataInputStream dis = new DataInputStream(is); return (StompFrame)wf.unmarshal(dis); }
protected String parseAction(DataInput in) throws IOException { String action = null; // skip white space to next real action line while (true) { action = readLine(in, MAX_COMMAND_LENGTH, "The maximum command length was exceeded"); if (action == null) { throw new IOException("connection was closed"); } else { action = action.trim(); if (action.length() > 0) { break; } } } return action; }
private StringBuilder marshalHeaders(StompFrame stomp, StringBuilder buffer) throws IOException { buffer.append(stomp.getAction()); buffer.append(Stomp.NEWLINE); // Output the headers. for (Map.Entry<String, String> entry : stomp.getHeaders().entrySet()) { buffer.append(entry.getKey()); buffer.append(Stomp.Headers.SEPERATOR); buffer.append(encodeHeader(entry.getValue())); buffer.append(Stomp.NEWLINE); } // Add a newline to separate the headers from the content. buffer.append(Stomp.NEWLINE); return buffer; }
public StompFrame receive(long timeOut) throws Exception { stompSocket.setSoTimeout((int)timeOut); InputStream is = stompSocket.getInputStream(); StompWireFormat wf = new StompWireFormat(); DataInputStream dis = new DataInputStream(is); return (StompFrame)wf.unmarshal(dis); }
@Override public WireFormat createWireFormat() { StompWireFormat wireFormat = new StompWireFormat(); wireFormat.setMaxDataLength(getMaxDataLength()); wireFormat.setMaxFrameSize(getMaxFrameSize()); return wireFormat; }
try { String action = parseAction(in, frameSize); HashMap<String, String> headers = parseHeaders(in, frameSize); int length = parseContentLength(contentLength, frameSize); if (baos == null) { baos = new ByteArrayOutputStream(); } else if (baos.size() > getMaxDataLength()) { throw new ProtocolException("The maximum data length was exceeded", true); } else { if (frameSize.incrementAndGet() > getMaxFrameSize()) { throw new ProtocolException("The maximum frame size was exceeded", true);
public Object unmarshal(ByteSequence packet) throws IOException { ByteArrayInputStream stream = new ByteArrayInputStream(packet); DataInputStream dis = new DataInputStream(stream); return unmarshal(dis); }
String action = parseAction(in); HashMap<String, String> headers = parseHeaders(in); int length = parseContentLength(contentLength);
protected HashMap<String, String> parseHeaders(DataInput in, AtomicLong frameSize) throws IOException { HashMap<String, String> headers = new HashMap<>(25); while (true) { ByteSequence line = readHeaderLine(in, MAX_HEADER_LENGTH, "The maximum header length was exceeded"); if (line != null && line.length > 1) { String value = decodeHeader(headerLine); if (stompVersion.equals(Stomp.V1_0)) { value = value.trim();
@Override public ByteSequence marshal(Object command) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); marshal(command, dos); dos.close(); return baos.toByteSequence(); }
public WireFormat createWireFormat() { return new StompWireFormat(); } }
public long getConnectAttemptTimeout() { return wireFormat.getConnectionAttemptTimeout(); }
try { String action = parseAction(in, frameSize); HashMap<String, String> headers = parseHeaders(in, frameSize); int length = parseContentLength(contentLength, frameSize); if (baos == null) { baos = new ByteArrayOutputStream(); } else if (baos.size() > getMaxDataLength()) { throw new ProtocolException("The maximum data length was exceeded", true); } else { if (frameSize.incrementAndGet() > getMaxFrameSize()) { throw new ProtocolException("The maximum frame size was exceeded", true);
@Override public WireFormat createWireFormat() { StompWireFormat wireFormat = new StompWireFormat(); wireFormat.setMaxDataLength(getMaxDataLength()); wireFormat.setMaxFrameSize(getMaxFrameSize()); return wireFormat; }
@Override public Object unmarshal(ByteSequence packet) throws IOException { ByteArrayInputStream stream = new ByteArrayInputStream(packet); DataInputStream dis = new DataInputStream(stream); return unmarshal(dis); }
if (wireFormat instanceof StompWireFormat) { DataByteArrayInputStream data = new DataByteArrayInputStream(currentCommand.toByteArray()); action = ((StompWireFormat)wireFormat).parseAction(data); headers = ((StompWireFormat)wireFormat).parseHeaders(data); String contentLengthHeader = headers.get(Stomp.Headers.CONTENT_LENGTH); if (contentLengthHeader != null) { contentLength = ((StompWireFormat)wireFormat).parseContentLength(contentLengthHeader); } else { contentLength = -1;
protected HashMap<String, String> parseHeaders(DataInput in, AtomicLong frameSize) throws IOException { HashMap<String, String> headers = new HashMap<>(25); while (true) { ByteSequence line = readHeaderLine(in, MAX_HEADER_LENGTH, "The maximum header length was exceeded"); if (line != null && line.length > 1) { String value = decodeHeader(headerLine); if (stompVersion.equals(Stomp.V1_0)) { value = value.trim();
@Override public ByteSequence marshal(Object command) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); marshal(command, dos); dos.close(); return baos.toByteSequence(); }
public long getConnectAttemptTimeout() { return wireFormat.getConnectionAttemptTimeout(); }
try { String action = parseAction(in, frameSize); HashMap<String, String> headers = parseHeaders(in, frameSize); int length = parseContentLength(contentLength, frameSize); if (baos == null) { baos = new ByteArrayOutputStream(); } else if (baos.size() > getMaxDataLength()) { throw new ProtocolException("The maximum data length was exceeded", true); } else { if (frameSize.incrementAndGet() > getMaxFrameSize()) { throw new ProtocolException("The maximum frame size was exceeded", true);