ClientConnection Class
A client connection for interacting with a sandbox environment.
Item Index
Methods
ASYNC_OP
-
context -
rpcName -
args
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:
-
contextObjectPyJujuAPI Instance.
-
rpcNameStringName of method on fakebackend.
-
argsArrayString list of arguments to extract from passed data. Used in order listed as arguments to the RPC call.
Returns:
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:
initializer
()
Undefined
Initialize.
Returns:
onclose
()
Undefined
React to a closing connection. You are expected to monkeypatch this method, as with websockets.
Returns:
onmessage
-
event
React to a new message from Juju. You are expected to monkeypatch this method, as with websockets.
Parameters:
-
eventObjectAn object with a JSON string on the "data" attribute.
Returns:
onopen
()
Undefined
React to an opening connection. You are expected to monkeypatch this method, as with websockets.
Returns:
OP
-
context -
rpcName -
args -
data
around sync operations with the fakebackend. Returned method can directly return to the caller.
Parameters:
-
contextObjectPyJujuAPI instance.
-
rpcNameStringname of method on fakebackend to invoke.
-
argsArrayString Array of arguments to pass from data to fakebackend.
-
dataObjectOperational data to be munged into a fakebackend call.
Returns:
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:
receive
-
data
Give message to listener asynchronously (contrast with receiveNow). Uses onmessage to deliver message, as with websockets.
Parameters:
-
dataObjectAn object to be sent as JSON to the listener.
Returns:
receiveNow
-
data -
failSilently
Immediately give message to listener (contrast with receive). Uses onmessage to deliver message, as with websockets.
Parameters:
-
dataObjectAn object to be sent as JSON to the listener.
-
failSilentlyBooleanA 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:
send
-
data
Send a JSON string to the API.
Parameters:
-
dataStringA JSON string of the data to be sent.
