-
Notifications
You must be signed in to change notification settings - Fork 11
Javascript API
Ignacio del Valle Alles edited this page Mar 12, 2016
·
12 revisions
Brutusin-RPC offers a Javascript-API that facilitates client-side integration.
Main features:
- Avoids specifying HTTP method.
- Sends keepalives to maintain HttpSession and Websocket connections open
- Handles connection errors
- Includes Spring security CRSF headers obtained from HTML meta tags
- Eases and optimizes file uploads.
- Offers high level topic (un)subscription.
Include in the header
section of the JSP rendering the client-side HTML:
<script src="rpc/brutusin-rpc.js"></script>
<script language='javascript'>
var http = brutusin["rpc"].initHttpEndpoint("<%=request.getContextPath() + org.brutusin.rpc.RpcConfig.getPath()+"/http"%>");
var wskt = brutusin["rpc"].initWebsocketEndpoint("<%=request.getContextPath() + org.brutusin.rpc.RpcConfig.getPath()+"/wskt"%>");
</script>
http://www.jsonrpc.org/specification#response_object
Executes a HTTP service via asynchronous AJAX.
Property | Type | Description |
---|---|---|
ajaxParam.service |
string |
HTTP service id to execute |
ajaxParam.input |
object |
HTTP service input object |
ajaxParam.files |
object |
Associative array. An entry for each property inside input corresponding to a string property with schema format equal to inputstram . The key must much the value of the corresponding input property, and the value is the File object. This API automatically sorts the file parts according to an ascending file length |
ajaxParam.load |
function(rpcResponse) |
Response callback |
ajaxParam.progress |
function(evt) |
Progress callback, being ´evt´ of type ProgressEvent
|
Executes a Websocket service.
execParam
has the same properties as ajaxParam
except progress
and files
.
Subscribes current session to the specified topic.
Property | Type | Description |
---|---|---|
topic |
string |
Id of the topic to subscribe |
callback |
function(message) |
Callback function to be executed on arrival of messages. Message structure depends on the topic |
Unsubscribes current session from the specified topic.
- Home
- Getting started
- Services
- HTTP services
- Messaging topics
- Spring
- Documenting
- Referencing source code
- Builtin components
- Configuration
- Deployment
- Client APIs
- Security
- Developer notes
- Architecture
- Examples