-
-
Notifications
You must be signed in to change notification settings - Fork 750
How to discover supported transport between browsers and server
jfarcand edited this page Jun 27, 2012
·
1 revision
The following code describes how to discover what the browser and server supports. On the client side:
var transports = new Array();
transports[0] = "websocket";
transports[1] = "sse";
transports[2] = "jsonp";
transports[3] = "long-polling";
transports[4] = "streaming";
transports[5] = "ajax";
$.each(transports, function (index, transport) {
var req = new $.atmosphere.AtmosphereRequest();
req.url = document.location.toString() + 'chat';
req.contentType = "application/json";
req.transport = transport;
req.headers = { "negotiating" : "true" };
req.onOpen = function(response) {
detect.append('<p><span style="color:blue">' + transport
+ ' supported: ' + '</span>' + (response.transport == transport));
}
req.onReconnect = function(request) {
request.close();
}
socket.subscribe(req)
});
On the server side,
public class DetectAtmosphereHandler implements AtmosphereHandler {
@Override
public void onRequest(AtmosphereResource r) throws IOException {
r.getResponse().getWriter().write("OK");
}
Download the atmosphere-chat to demo live.
- Understanding Atmosphere
- Understanding @ManagedService
- Using javax.inject.Inject and javax.inject.PostConstruct annotation
- Understanding Atmosphere's Annotation
- Understanding AtmosphereResource
- Understanding AtmosphereHandler
- Understanding WebSocketHandler
- Understanding Broadcaster
- Understanding BroadcasterCache
- Understanding Meteor
- Understanding BroadcastFilter
- Understanding Atmosphere's Events Listeners
- Understanding AtmosphereInterceptor
- Configuring Atmosphere for Performance
- Understanding JavaScript functions
- Understanding AtmosphereResourceSession
- Improving Performance by using the PoolableBroadcasterFactory
- Using Atmosphere Jersey API
- Using Meteor API
- Using AtmosphereHandler API
- Using Socket.IO
- Using GWT
- Writing HTML5 Server-Sent Events
- Using STOMP protocol
- Streaming WebSocket messages
- Configuring Atmosphere's Classes Creation and Injection
- Using AtmosphereInterceptor to customize Atmosphere Framework
- Writing WebSocket sub protocol
- Configuring Atmosphere for the Cloud
- Injecting Atmosphere's Components in Jersey
- Sharing connection between Browser's windows and tabs
- Understanding AtmosphereResourceSession
- Manage installed services
- Server Side: javadoc API
- Server Side: atmosphere.xml and web.xml configuration
- Client Side: atmosphere.js API