From Ape Wiki

Jump to: navigation, search

Contents

[edit] Use different transport methods

APE supports different transport methods:

  • Long Polling: default transport method
  • JSONP: for cross domain push
  • XHRStreaming: for better performance and low latency
  • WebSockets : Best performances. (FF4, Chrome, Safari 5)
Don't forget to clear your cookies if you change the transport method!

[edit] Long Polling

With long polling, the client requests information from the server in a similar way to a normal poll. However, if the server does not have any information available for the client, instead of sending an empty response, the server holds the request and waits for some information to be available. Once the information becomes available (or after a suitable timeout), a complete response is sent to the client. The client then immediately re-request information from the server.

Note: this text is taken from wikipedia

[edit] JSONP

This transport method allows APE to work cross domain. For example your APE Server runs on http://ape.yourdomain.com but you also want it to be accessible on any other domain. This can be done using JSONP. To activate JSONP edit your APE JSF config file and add :

APE.Config.transport = 2;  // 2 is JSONP

[edit] XHRStreaming

This transport method is similar to long polling, but instead of closing connection when new data arrives, the server keeps the connection open. This only works in browsers based on Gecko or Webkit (e.g. Safari, Chrome, Firefox).

To activate XHRStreaming, edit your APE JSF config file and add:

APE.Config.transport = 1;  // 1 is XHRStreaming
If the browser doesn't support XHRStreaming, APE JSF falls back to long polling.

[edit] WebSocket

If you are using a recent APE version (git version for APE Server and APE JSF) you can use WebSocket. It's the transport method 6. If you want to use websocket your APE Server must run on port 443 or 80. (efyx says port restriction untrue, recent revisions seem to have eased this restriction.)

APE supports the WebSockets protocol as it's defined on this page :

http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-76



But also provides a support for prior version (< 76)