I was using the trackMessageSize setting on my atmosphere client, and found that if the user sent the message delimiter "|" or a double underscore "__" inside of their message, the decoder failed to split the received collection of messages. I have written a couple of test cases based on those already available for the TrackMessageSizeDecoder for the situation.
I am unable to restrict things so that the user cannot use those character sequences. I am using wAsync 1.4.0 connected on websockets.
@Test
public void testDelimiterInMessage() {
decoder = new TrackMessageSizeDecoder("|", false);
String messages = "38|{\"message\":\"a|b\",\"time\":1373900488807}37|{\"message\":\"ab\",\"time\":1373900488808}38|{\"message\":\"a|b\",\"time\":1373900488810}";
List<String> expected = new ArrayList<String>() {
{
add("{\"message\":\"a|b\",\"time\":1373900488807}");
add("{\"message\":\"ab\",\"time\":1373900488808}");
add("{\"message\":\"a|b\",\"time\":1373900488810}");
}
};
List<String> result = decoder.decode(Event.MESSAGE, messages);
assertEquals(result, expected);
}
@Test
public void testDoubleUnderscoreInMessage()
{
decoder = new TrackMessageSizeDecoder("|", false);
String messages = "39|{\"message\":\"a__b\",\"time\":1373900488807}37|{\"message\":\"ab\",\"time\":1373900488808}39|{\"message\":\"a__b\",\"time\":1373900488810}";
List<String> expected = new ArrayList<String>() {
{
add("{\"message\":\"a__b\",\"time\":1373900488807}");
add("{\"message\":\"ab\",\"time\":1373900488808}");
add("{\"message\":\"a__b\",\"time\":1373900488810}");
}
};
List<String> result = decoder.decode(Event.MESSAGE, messages);
assertEquals(result, expected);
}
@phemphill This is an inherent problem (with text-encoded) delimiter-based protocols that some character or character sequences are not allowed in the payload.
I was using the trackMessageSize setting on my atmosphere client, and found that if the user sent the message delimiter "|" or a double underscore "__" inside of their message, the decoder failed to split the received collection of messages. I have written a couple of test cases based on those already available for the TrackMessageSizeDecoder for the situation.
I am unable to restrict things so that the user cannot use those character sequences. I am using wAsync 1.4.0 connected on websockets.