API Docs for:
Show:

ClientConnection Class

Module: env.sandbox
Parent Module: env

A client connection for interacting with a sandbox environment.

Methods

ASYNC_OP

(
  • context
  • rpcName
  • args
)
Undefined

with a callback. Returns a method with a callback wired in to continue the operation when done. The returned method should be passed the data mapping to invoke.

Parameters:

  • context Object

    PyJujuAPI Instance.

  • rpcName String

    Name of method on fakebackend.

  • args Array

    String list of arguments to extract from passed data. Used in order listed as arguments to the RPC call.

Returns:

Undefined: sends to client implicitly.

close

() Undefined

Close the connection. This is responsible for changing the "connected" state, for calling the onclosed hook, and for calling the sandbox juju.close.

Returns:

Undefined: Nothing.

initializer

() Undefined

Initialize.

Returns:

Undefined: Nothing.

onclose

() Undefined

React to a closing connection. You are expected to monkeypatch this method, as with websockets.

Returns:

Undefined: Nothing.

onmessage

(
  • event
)
Undefined

React to a new message from Juju. You are expected to monkeypatch this method, as with websockets.

Parameters:

  • event Object

    An object with a JSON string on the "data" attribute.

Returns:

Undefined: Nothing.

onopen

() Undefined

React to an opening connection. You are expected to monkeypatch this method, as with websockets.

Returns:

Undefined: Nothing.

OP

(
  • context
  • rpcName
  • args
  • data
)
Object

around sync operations with the fakebackend. Returned method can directly return to the caller.

Parameters:

  • context Object

    PyJujuAPI instance.

  • rpcName String

    name of method on fakebackend to invoke.

  • args Array

    String Array of arguments to pass from data to fakebackend.

  • data Object

    Operational data to be munged into a fakebackend call.

Returns:

Object: result depends on underlying rpc method.

open

() Undefined

Explicitly open the connection. This does not have an analog with websockets, but requiring an explicit "open" means less magic is necessary. It is responsible for changing the "connected" state, for calling the onopen hook, and for calling the sandbox juju.open with itself.

Returns:

Undefined: Nothing.

receive

(
  • data
)
Undefined

Give message to listener asynchronously (contrast with receiveNow). Uses onmessage to deliver message, as with websockets.

Parameters:

  • data Object

    An object to be sent as JSON to the listener.

Returns:

Undefined: Nothing.

receiveNow

(
  • data
  • failSilently
)
Undefined

Immediately give message to listener (contrast with receive). Uses onmessage to deliver message, as with websockets.

Parameters:

  • data Object

    An object to be sent as JSON to the listener.

  • failSilently Boolean

    A flag to turn off the error when the connection is closed. This exists to handle a race condition between receiveNow and receive, when the connection closes between the two.

Returns:

Undefined: Nothing.

send

(
  • data
)
Undefined

Send a JSON string to the API.

Parameters:

  • data String

    A JSON string of the data to be sent.

Returns:

Undefined: Nothing.