-
-
Notifications
You must be signed in to change notification settings - Fork 751
Using SwaggerSocket in Atmosphere
The Atmosphere Framework includes [SimpleRestInterceptor] (http://async-io.org/apidocs/org/atmosphere/interceptor/SimpleRestInterceptor.html) which enables the existing REST services to be transparently invoked over Websocket.
This binding describes how REST requests and responses are represented in Websocket messages. It is originated from SwaggerSocket and has been simplified and enhanced from its initial version.
This binding has the following characteristics.
-
Each request contains the method, path, and optional type and data.
-
Each request may be sent with a unique-ID for the client to correlate responses to its requests.
-
The content-type header can be optionally supplied if the content is present.
-
The accept header can be optionally supplied if the response is expected.
-
Arbitrary Http headers are supported, but they may be omitted if thet are not part of the application semantics.
-
The content entity can be optionally supplied following the envelope.
-
A large message can be transported as a series of messages that can be reassembled at the receiving end.
-
The server can periodically send a heartbeat message to the connected clients to keep the connections alive.
The following message format is used for this binding. Each message is represented as a text or binary Websocket message. It consists of the headers part encoded in json and the optional content part which follows the headers part.
{"id": "identifier", "code": status_code, "method": "method", "path": "path", "type": "type_value", "accept": "accept_value", "headers": headers_map, "continue": continue} content
where
-
identifier represents an identifier for the request message which is used in any response message to refer to the original request message,
-
status_code represents the status code of the response message.
-
method represents the request method,
-
path represents the request path,
-
type and accept represent the optional content-type and accept header values.
-
headers_map represents the optional headers other than content-type and accept headers.
-
content represents the optional content entity.
-
continue represents the optional boolean value which indicates the message continues, in other words, followed by another message.
Atmosphere's samples include cxf-greeter-swaggersocket. This sample demonstrates how this interceptor is used to enable DefaultApi to support SwaggerSocket. Some operations perform plain request-response operations, and some utilize an underlining WebSocket connection to publish and deliver responses asynchronous.
- 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