network.protocols.jsonrpc.client - Palamecia/mint GitHub Wiki

Module

load network.protocols.jsonrpc.client

This module provides the Network.JsonRpc.Client class which implement the client side of the JSON RPC protocol.

Packages

Classes

Network.JsonRpc.Client

This class provides an implementation of the client side of the JSON RPC protocol. It can be used with the Network.Scheduler class where a channel is expected.

Members

Modifiers Member Description
- final attributes Internal default attributes.
- final channel Internal channel.
+ const close Closes the communication with the peer if the context was connected using the...
+ const connect Attempts to make a connection to the remote device. This method calls the Net...
+ const getDefaultAttribute Returns the value for the attribute name used by default created messages o...
+ const getDefaultAttributes Returns the attributes used by default created messages of the contexte as a...
+ const getEndpoint Returns the underling end point object. This method calls the Network.Asynchr...
+ const getEvents Returns the events expected by the context as mask of values from the Network...
+ const getSocket Returns the context's socket as a number. This method calls the Network.Async...
+ const getState Returns the current state of the context as a value of Network.EndPoint.State...
+ const isNonBlocking Returns true if the channel performs I/O operations asynchronously (i.e. re...
+ const new Creates a new client context for the given endpoint server. The endpoint ...
+ const notifyClosed Notifies the channel that the connection was closed by the peer. This method ...
+ const notifyError Notifies the channel that the underling end point has received an error. This...
+ const notifyReadable Notifies the context that the underling channel is readable. This method call...
+ const notifyWritable Notifies the channel that the underling end point is writable. This method ca...
+ onClose This method can be rebinded to handle close events. The client parameter is...
+ onMessage This method can be rebinded to handle message events. The client parameter ...
+ onOpen This method can be rebinded to handle connection success events. The client...
+ onState This method can be rebinded to handle state change events. The client param...
+ const read Returns the next message object in the reply queue or none if no more messa...
+ const removeDefaultAttribute Removes the attribute name used by default created messages. The remaining ...
+ const setDefaultAttribute Sets the attribute name used by default created messages to value. The at...
+ const setDefaultAttributes Sets the attributes used by default created messages to attributes. The att...
+ const setNonBlocking Sets the non blocking mode of the channel to enabled. This method calls the...
+ const unwatch Removes the channel from the Network.Scheduler object. This method calls the ...
+ const watch Adds the channel to the Network.Scheduler object. This method calls the Netwo...
+ const write Pushes the message object described by data to the request queue. This meth...

Descriptions

Network.JsonRpc.Client.attributes

{}

Internal default attributes.

Network.JsonRpc.Client.channel

null

Internal channel.

Network.JsonRpc.Client.close

def (self)

Closes the communication with the peer if the context was connected using the connect. This method calls the Network.AsynchronousChannel.close method of the underling channel. If the socket was successfully closed, onClose is called; otherwise the socket will be closed later.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.connect

def (self)

Attempts to make a connection to the remote device. This method calls the Network.AsynchronousChannel.connect method of the underling channel.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.getDefaultAttribute

def (const self, name)

Returns the value for the attribute name used by default created messages of the contexte.

Network.JsonRpc.Client.getDefaultAttributes

def (const self)

Returns the attributes used by default created messages of the contexte as a hash.

Network.JsonRpc.Client.getEndpoint

def (const self)

Returns the underling end point object. This method calls the Network.AsynchronousChannel.getEndpoint method of the underling channel.

Network.JsonRpc.Client.getEvents

def (const self)

Returns the events expected by the context as mask of values from the Network.Scheduler.PollEvent enum. This method calls the Network.AsynchronousChannel.getEvents method of the underling channel.

Network.JsonRpc.Client.getSocket

def (const self)

Returns the context's socket as a number. This method calls the Network.AsynchronousChannel.getSocket method of the underling channel.

Network.JsonRpc.Client.getState

def (const self)

Returns the current state of the context as a value of Network.EndPoint.State. This method calls the Network.AsynchronousChannel.getState method of the underling channel.

Network.JsonRpc.Client.isNonBlocking

def (const self)

Returns true if the channel performs I/O operations asynchronously (i.e. read or write data without blocking other channels); otherwise returns false. This method calls the Network.AsynchronousChannel.isNonBlocking method of the underling channel.

Network.JsonRpc.Client.new

def (self, endpoint, Channel = Network.AsynchronousChannel)

Creates a new client context for the given endpoint server. The endpoint parameter must implement the Network.EndPoint interface.

The Channel parameter can provide a class that will be used to create the underling channel.

Network.JsonRpc.Client.notifyClosed

def (self)

Notifies the channel that the connection was closed by the peer. This method calls the Network.AsynchronousChannel.notifyClosed method of the underling channel.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.notifyError

def (self)

Notifies the channel that the underling end point has received an error. This method calls the Network.AsynchronousChannel.notifyClosed method of the underling channel and an instance of Exception.SocketError is raised.

Network.JsonRpc.Client.notifyReadable

def (self)

Notifies the context that the underling channel is readable. This method calls the Network.AsynchronousChannel.notifyReadable method of the underling channel.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.notifyWritable

def (self)

Notifies the channel that the underling end point is writable. This method calls the Network.AsynchronousChannel.notifyWritable method of the underling channel.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.onClose

def (self, client)

This method can be rebinded to handle close events. The client parameter is the context that received the event. This can be used to cleanup a context or try to reconnect when the connection was closed by the peer.

Network.JsonRpc.Client.onMessage

def (self, client)

This method can be rebinded to handle message events. The client parameter is the context that received the event. The messages can be accessed using the read method.

[!NOTE] This method can be called for one or more messages and will not be called until the underling end point receive more data. The read method should then be called by this method until none is returned.

Network.JsonRpc.Client.onOpen

def (self, client)

This method can be rebinded to handle connection success events. The client parameter is the context that received the event. This method can be used to begin exchanges with the peer.

Network.JsonRpc.Client.onState

def (self, client, % state)

This method can be rebinded to handle state change events. The client parameter is the context that received the event and the state parameter is the state that will be applied to the underling channel. The previous state can still be accessed with getState until the end of the method.

[!WARNING] Calling Network.EndPoint.setState in this method can result in an infinite loop.

Network.JsonRpc.Client.read

def (self)

Returns the next message object in the reply queue or none if no more message is available. This method calls the Network.AsynchronousChannel.read method of the underling channel.

Network.JsonRpc.Client.removeDefaultAttribute

def (self, name)

Removes the attribute name used by default created messages. The remaining attributes will be passed to the Network.JsonRpc.Message.setAttribute of the default created messages.

Network.JsonRpc.Client.setDefaultAttribute

def (self, name, value)

Sets the attribute name used by default created messages to value. The attributes will be passed to the Network.JsonRpc.Message.setAttribute of the default created messages.

Network.JsonRpc.Client.setDefaultAttributes

def (self, attributes)

Sets the attributes used by default created messages to attributes. The attributes will be passed to the Network.JsonRpc.Message.setAttribute of the default created messages.

Network.JsonRpc.Client.setNonBlocking

def (self, enabled)

Sets the non blocking mode of the channel to enabled. This method calls the Network.AsynchronousChannel.setNonBlocking method of the underling channel. Returns true if the mode was successfully changed; otherwise returns false.

[!WARNING] Disable the non blocking mode on a context can slow down any network I/O operations of the application. Other channels will not be able to perform I/O operations until the current operation's acknowledgment by the peer.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.unwatch

def (self)

Removes the channel from the Network.Scheduler object. This method calls the Network.Scheduler.remove method.

Network.JsonRpc.Client.watch

def (self)

Adds the channel to the Network.Scheduler object. This method calls the Network.Scheduler.watch method.

An instance of Exception.SocketError is raised on error.

Network.JsonRpc.Client.write

def (self, data)

Pushes the message object described by data to the request queue. This method calls the Network.AsynchronousChannel.write method of the underling channel.

The data parameter can be an instance of Network.JsonRpc.Message; otherwise an instance will be created depending on the type of the parameter using Network.JsonRpc.Message.fromString for a string or Network.JsonRpc.Message.new for a hash. Attributes can be added to default created messages using setDefaultAttributes.