Closed solderain closed 9 years ago
You cannot remove. This is part of the module. Since you can receive multiple messages at once we always send them as an array. Imagine that you are connected and a message was published, your connection will be closed and reopened. In this mean time if two more messages were published, the server will send both on a single callback function. The pushstream.js already deal with that. If you are not using it your callback function should handle this. Probably you are having problems because you are not using a json message template like on examples.
Thanks wandenberg for your quickly reponse . So you mean the offline messages will be delievered automatically when using jsonp request ? I remember it have to set the following instructions ask for the past messages : push_stream_last_received_message_tag $arg_tag; push_stream_last_received_message_time $arg_time;
You have to set these directives in order to let the server know which was the last message you received, as a client. If there are messages published after that time/tag (and stored is 'on') they will be delivered to your client as an array.
Just a fix to my last answer, the message template could be other than a json, just has to produce a valid javascript code. So you can set the template like '\"~text~\"' producing a response like callback(["some text"]); But, to work with pushstream.js the message template must be a valid json properly configured.
Ok, i understand the purpose of that design . Thank you for your detailed explanation.
The client get the following response information when using jsonp request :
PushStreamManager_0_onmessage_1418199211102([Hello World!] )
But i just execute command : curl -s -v -X POST 'http://localhost/pub?id=my_channel_1' -d 'Hello World!' , the expected response doesn't include that redundant bracket mark as bold. My configuration is : location ~ /lp/(.*) {
activate long-polling mode for this location
I try to change the push_stream_message_template by different way ,but still cann't remove that brackets.
How to remove the bracket ?