atmosphere icon indicating copy to clipboard operation
atmosphere copied to clipboard

TrackMessageSizeInterceptor: Allow for delimiter character in message content

Open nite23 opened this issue 13 years ago • 7 comments

Currently , if the message contains a character that's set as a message delimiter, it breaks the delivery.

A possible solution would be to encode the payload in the interceptor, for example to Base64, and then decode it in the client.

nite23 avatar Dec 07 '12 05:12 nite23

@nite23 Would that perform well in terms of speed? You are aware you can change the delimiter default char right? At work we came with a list of char for wsj.com and so far it always worked.

jfarcand avatar Dec 07 '12 14:12 jfarcand

Not too much slower, I guess, since we were already decoding the message to utf-8 to figure out it's length in characters and then re-encoding it again. There will be some overhead on messsage size, though (that could be fixed by using a more efficient encoding scheme).

But it might be worth it for people who don't want to bother with validating input data for delimiters.

https://gist.github.com/4238566 Here's an interceptor to test the concept. Client-side decoding is done in onMessage callback.

nite23 avatar Dec 08 '12 04:12 nite23

Base64 encoding will increase the size of the encoded string by 30%

staabm avatar Dec 08 '12 09:12 staabm

@staabm I like it. Can you do a request so I can add it to the distribution?

jfarcand avatar Dec 10 '12 13:12 jfarcand

@nite23 Do me a favor and do a pull request with your implementation. I will take care of documenting it. Thanks!

jfarcand avatar Jan 16 '13 21:01 jfarcand

@jfarcand done!

nite23 avatar Jan 17 '13 03:01 nite23

@nite23 Do you use TrackMessageSizeB64Interceptor with the atmosphere-javascript client? I'm having problems with WebSocket and SSE when I use it. The initial message with [tracking ID]|[timestamp] is also base64 encoded, and therefore the js client doesn't understand it. It thinks the length before the | character is the tracking ID and the base64 part after | is the timestamp. Any suggestions? Using Atmosphere 2.0.2 at the moment.

slovdahl avatar Oct 29 '13 14:10 slovdahl