JSONMessage

Overview

Implements JSON-RPC protocol. Data values are encoded in JSON format, binary streams are base64-encoded. Requires WrapResult option set to true at the server side.

Usage example

var channel = new RemObjects.SDK.HTTPClientChannel("http://" + window.location.host + "/JSON");
var message = new RemObjects.SDK.JSONMessage();
var service = new RemObjects.SDK.RemoteService(channel, message, "DASampleService");

Location

RemObjectsSDK.js

Instance Methods


constructor JSONMessage

Creates an instance.

function constructor JSONMessage(aWrapResult)

Parameters:

  • aWrapResult: If set to true, this property instructs the object to wrap the remote method execution results into a result object before passing them back as required by the JSON-RPC specification. Required for var or out parameters.

constructor Message    (declared in Message)

No need to create an instance of abstract class.

function constructor Message()

clone

Returns new message object with the same ClienID.

function clone()

finalize

Finishes writing the data. Usually called by auto-generated code.

function finalize()

getClientID

Returns client id that identifies session on the server. Client id could be stored in some kind of persistent storage (like browser cookies) to be used after page reload.

function getClientID()

getErrorMessage

Returns error message as a string. Use it in the service methods error handler. See ClientChannel.dispatch.

function getErrorMessage()

getWrapResult

Returns WrapResult state

function getWrapResult()

initialize

Starts writing the data. Usually called by auto-generated code.

function initialize(aServiceName, aMethodName, aMessageType)

Parameters:

  • aServiceName: string
  • aMethodName: string
  • aMessageType: number (RemObjects.SDK.Enum.MessageType)

read

Reads value from the data stream.

function read(aName, aType)

Parameters:

  • aName: string
  • aType: string

requestStream

Data stream to be sent to the server.

function requestStream()

setClientID

Sets ClientID.

var message = new RemObjects.SDK.JSONMessage();
message.setClientID(getCookie("MyAppClientID"));
function setClientID(aValue)

Parameters:

  • aValue: string

setWrapResult

Sets WrapResult state

If set to true, this property instructs the object to wrap the remote method execution results into a result object before passing them back as required by the JSON-RPC specification.

Required for var or out parameters.

This property should be set to true if it is intended to allow Remoting SDK for JavaScript-based clients to communicate with the server.

Note: Client- and server-side should use the same value.

function setWrapResult(aValue)

Parameters:

  • aValue: boolean value

write

Writes a value to the data stream.

function write(aName, aType, aValue)

Parameters:

  • aName: string
  • aType: string
  • aValue: object