Create versioned instead of generic frames from STOMP decoder
This commit is contained in:
parent
f17991e58c
commit
3deb20f049
|
@ -162,8 +162,11 @@ public class StompDecoder
|
||||||
//max len of EOL (default is 1 for '\n')
|
//max len of EOL (default is 1 for '\n')
|
||||||
protected int eolLen = 1;
|
protected int eolLen = 1;
|
||||||
|
|
||||||
public StompDecoder()
|
private final VersionedStompFrameHandler handler;
|
||||||
|
|
||||||
|
public StompDecoder(VersionedStompFrameHandler handler)
|
||||||
{
|
{
|
||||||
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBytes()
|
public boolean hasBytes()
|
||||||
|
@ -276,7 +279,9 @@ public class StompDecoder
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
|
|
||||||
StompFrame ret = new StompFrame(command, headers, content);
|
StompFrame ret = handler.createStompFrame(command);
|
||||||
|
ret.headers = headers;
|
||||||
|
ret.setByteBody(content);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class StompFrame
|
||||||
|
|
||||||
protected final String command;
|
protected final String command;
|
||||||
|
|
||||||
protected final Map<String, String> headers;
|
protected Map<String, String> headers;
|
||||||
|
|
||||||
private String body;
|
private String body;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class StompFrameHandlerV10 extends VersionedStompFrameHandler implements
|
||||||
public StompFrameHandlerV10(StompConnection connection)
|
public StompFrameHandlerV10(StompConnection connection)
|
||||||
{
|
{
|
||||||
super(connection);
|
super(connection);
|
||||||
decoder = new StompDecoder();
|
decoder = new StompDecoder(this);
|
||||||
decoder.init();
|
decoder.init();
|
||||||
connection.addStompEventListener(this);
|
connection.addStompEventListener(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements
|
||||||
{
|
{
|
||||||
super(connection);
|
super(connection);
|
||||||
connection.addStompEventListener(this);
|
connection.addStompEventListener(this);
|
||||||
decoder = new StompDecoderV11();
|
decoder = new StompDecoderV11(this);
|
||||||
decoder.init();
|
decoder.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +428,11 @@ public class StompFrameHandlerV11 extends VersionedStompFrameHandler implements
|
||||||
protected boolean isEscaping = false;
|
protected boolean isEscaping = false;
|
||||||
protected SimpleBytes holder = new SimpleBytes(1024);
|
protected SimpleBytes holder = new SimpleBytes(1024);
|
||||||
|
|
||||||
|
public StompDecoderV11(StompFrameHandlerV11 handler)
|
||||||
|
{
|
||||||
|
super(handler);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(StompDecoder decoder)
|
public void init(StompDecoder decoder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 implements FrameE
|
||||||
public StompFrameHandlerV12(StompConnection connection)
|
public StompFrameHandlerV12(StompConnection connection)
|
||||||
{
|
{
|
||||||
super(connection);
|
super(connection);
|
||||||
decoder = new StompDecoderV12();
|
decoder = new StompDecoderV12(this);
|
||||||
decoder.init();
|
decoder.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,9 +99,11 @@ public class StompFrameHandlerV12 extends StompFrameHandlerV11 implements FrameE
|
||||||
{
|
{
|
||||||
protected boolean nextEOLChar = false;
|
protected boolean nextEOLChar = false;
|
||||||
|
|
||||||
public StompDecoderV12()
|
public StompDecoderV12(StompFrameHandlerV12 handler)
|
||||||
{
|
{
|
||||||
//1.2 allow '\r\n'
|
super(handler);
|
||||||
|
|
||||||
|
//1.2 allows '\r\n'
|
||||||
eolLen = 2;
|
eolLen = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue