MostafaNawara / jquery-stream

Automatically exported from code.google.com/p/jquery-stream
0 stars 0 forks source link

Generic response formatting #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This patch changes the code to accept alternative response formats:
 * alternative message separator
 * disable message length field

e.g.
      $.stream("...", {
           messageLength: false,
           messageSeparator: "\n\n",
      });

accepts a response format with no message length field. Messages are separated 
by an empty line:

<message1>

<message2>

...

Original issue reported on code.google.com by koe...@gmail.com on 9 Jun 2011 at 1:09

Attachments:

GoogleCodeExporter commented 9 years ago
The format without length field is nice but do not seem to ensure the perfect 
message reception when a message is so big or contains the message separator.

What do you think about that?

Original comment by flowersi...@gmail.com on 11 Jun 2011 at 10:54

GoogleCodeExporter commented 9 years ago
Hi,

I'm not sure about the reception of big messages. Which issues do you see there?

About the separator in the message: that's right. Probably I could provide an 
escape character mechanism? 

Side note: I made the change as we have no means to change the message format 
of the stream we are connecting to.

Thanks,

Koen

Original comment by koe...@gmail.com on 11 Jun 2011 at 11:13

GoogleCodeExporter commented 9 years ago
Hello,

I'm sorry about the very big message issue, there are no problem. In fact, I 
experienced that issue before the release of 1.0 and fixed it.

The issue about the message containing the separator require the server to 
escape message. Because I thought a kind of encoding and decoding process is 
slower and more complicated than adding length info to message, I added the 
length field to the message format.

Anyway, I think your problem is that the server's response is not modifiable. 
Instead of providing message format without length field, it will be better to 
provide the way of handling response.

For example,

$.stream("/event-stream", {
    handleOpen: function(text) {
        // ...
    },
    handleMessage: function() {
        // ...
    },
});

Donghwan

Original comment by flowersi...@gmail.com on 11 Jun 2011 at 1:07

GoogleCodeExporter commented 9 years ago

Original comment by flowersi...@gmail.com on 8 Jul 2011 at 9:03