@@ -306,6 +306,86 @@ Create a html page with the content on **Client** part, access it from browser a
* _push_stream_message_template_ should be exactly like as the example to be used with PushStream class
* EventSource and Forever iFrame may be combined setting _/sub_ and _/ev_ locations on same server and setting *modes: "eventsource|stream"* on client. With that if the browser supports Event Source, it will use it, if not it will use iFrame.
h2(#websocket). WebSocket
Using WebSocket to receive the messages.
*This example uses the PushStream class present in _misc/js/pushstream.js_ file, copy it to your server htdocs.*
Configure your server like suggested bellow. You should complete this configuration with other directives according with target application.
Create a html page with the content on **Client** part, access it from browser and try with the command *curl http://localhost/pub?id=ch1 -d "Some Text"*.
*Server:*
<pre>
location /pub {
# activate publisher (admin) mode for this location
* _push_stream_message_template_ should be exactly like as the example to be used with PushStream class
* WebSocket, EventSource and Forever iFrame may be combined setting _/ws_, _/sub_ and _/ev_ locations on same server and setting *modes: "websocket|eventsource|stream"* on client. With that if the browser supports Websocket or Event Source, it will use it, if not it will use iFrame, following the order on _modes_ attribute.
h2(#long-polling). Long Polling
Using jQuery to receive the messages.
...
...
@@ -533,6 +613,29 @@ The polling and long-polling modes could be set by the request header *X-Nginx-P
</pre>
h2(#push_stream_websocket). push_stream_websocket
*syntax:* _push_stream_websocket_
*default:* _none_
*context:* _location_
*release version:* _0.3.2_
Defines a location as a subscriber using WebSocket protocol. This location represents a subscriber's interface to a channel's message queue.
This location only supports GET http method to receive published messages.
*syntax:* _push_stream_websocket_allow_publish on | off_
*default:* _off_
*context:* _location_
*release version:* _0.3.2_
Enable a WebSocket subscriber send messages to the channel it is connected (the first, if connected in more than one) through the same connection it is receiving the messages, using _send_ method from WebSocket interface.
h1(#attention). Attention
This module controls everything needed to send the messages to subscribers.
staticconstngx_str_tNGX_HTTP_PUSH_STREAM_TOO_SUBSCRIBERS_PER_CHANNEL=ngx_string("Subscribers limit per channel has been exceeded.");
staticconstngx_str_tNGX_HTTP_PUSH_STREAM_CANNOT_CREATE_CHANNELS=ngx_string("Subscriber could not create channels.");
staticconstngx_str_tNGX_HTTP_PUSH_STREAM_NUMBER_OF_CHANNELS_EXCEEDED_MESSAGE=ngx_string("Number of channels were exceeded.");
staticconstngx_str_tNGX_HTTP_PUSH_STREAM_NO_MANDATORY_HEADERS_MESSAGE=ngx_string("Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version");
staticconstngx_str_tNGX_HTTP_PUSH_STREAM_WRONG_WEBSOCKET_VERSION_MESSAGE=ngx_string("Version not supported. Supported versions: 8, 13");