-
-
Notifications
You must be signed in to change notification settings - Fork 753
Understanding JavaScript functions
Functions definitions see for more information
When using the jQuery.atmosphere.js Javascript client, you have several functions you can set in order to get notified when events occurs:
-
onOpen:
- atmosphere 1.0.x: For WebSocket and SSE, the onOpen will be called when the connection is fully established. For others transports like http-streaming, long-polling and jsonp, onOpen will be called 500 milliseconds after the connection has been sent to the server. When request.enableProtocol is set to true, onOpen will be called only when the connection is fully established.
- atmosphere 1.1.x: onOpen will be called for all transports when the connection is fully established.
-
onClose: The onClose is called when:
- an error occurs.
- when the server or a proxy closes the connection.
- when an expected exception occurs.
- when the specified transport is not supported or fail to connect.
-
onMessage: Everytime a new message is received
-
onError: The onError is called when:
- the request.maxReconnectOnClose re-connect try has failed
- an unexpected error occured.
-
onTransportFailure: if the specified transport fails to connect, this method will be called before the reconnect, with the fallbackTransport.
-
onReconnect:
- atmosphere 1.0.x: Every time a reconnection happens. For long-polling, this method will be called everytime a response is received.
- atmosphere 1.1.x: Everytime an error happens and a reconnect needs to happens. This works for all transport, e.g for long-polling, onReconnect will only be called if an error happens and never before reconnecting.
-
onReopen: Only in atmosphere-1.1.x, this function is called every time a re-connection successfully reconnected.
-
onMessagePublished: Except for websockets, the onMessagePublished will be invoked when a POST is made and the server side is sending a response using the 'polling' connection.
onOpen -> onMessage -> onClose // Normal onTransportFailure -> onOpen -> onMessage -> onClose // transport not supported onOpen -> onMessage -> [connection closed] -> onReconnect -> onClose -> onError // maxReconnectOnClose onOpen -> onMessage -> [connection closed] -> onReconnect -> onMessage
- 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