Jsonrpc.Server¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal is emitted when a new client has been accepted. |
|
This signal is emitted when a new client has been lost. |
|
This method is emitted when the client requests a method call. |
|
This signal is emitted when the client has sent a notification to us. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Jsonrpc.Server(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A server for JSON-RPC communication
The
Jsonrpc.Server
class can help you implement a JSON-RPC server. You can accept connections and then communicate with clients using the [class`Client`] API.- classmethod new()¶
- Returns:
A newly created
Jsonrpc.Server
instance.- Return type:
Creates a new
Jsonrpc.Server
.New in version 3.26.
- accept_io_stream(io_stream)¶
- Parameters:
io_stream (
Gio.IOStream
) – AGio.IOStream
This function accepts io_stream as a new client to the
Jsonrpc.Server
by wrapping it in aJsonrpc.Client
and starting the message accept loop.New in version 3.26.
- add_handler(method, handler, *handler_data)¶
- Parameters:
method (
str
) – A method to handlehandler (
Jsonrpc.ServerHandler
) – A handler to execute when an incoming method matches methods
- Returns:
A handler id that can be used to remove the handler with [method`Server`.remove_handler].
- Return type:
Adds a new handler that will be dispatched when a matching method arrives.
New in version 3.26.
- foreach(foreach_func, *user_data)¶
- Parameters:
Calls foreach_func for every client connected.
New in version 3.28.
- remove_handler(handler_id)¶
- Parameters:
handler_id (
int
) – A handler returned from [method`Server`.add_handler]
Removes a handler that was previously registered with [method`Server`.add_handler].
New in version 3.26.
- do_client_accepted(client) virtual¶
- Parameters:
client (
Jsonrpc.Client
) –
- do_client_closed(client) virtual¶
- Parameters:
client (
Jsonrpc.Client
) –
- do_handle_call(client, method, id, params) virtual¶
- Parameters:
client (
Jsonrpc.Client
) –method (
str
) –id (
GLib.Variant
) –params (
GLib.Variant
) –
- Return type:
- do_notification(client, method, params) virtual¶
- Parameters:
client (
Jsonrpc.Client
) –method (
str
) –params (
GLib.Variant
) –
Signal Details¶
- Jsonrpc.Server.signals.client_accepted(server, client)¶
- Signal Name:
client-accepted
- Flags:
- Parameters:
server (
Jsonrpc.Server
) – The object which received the signalclient (
Jsonrpc.Client
) – AJsonrpc.Client
This signal is emitted when a new client has been accepted.
New in version 3.28.
- Jsonrpc.Server.signals.client_closed(server, client)¶
- Signal Name:
client-closed
- Flags:
- Parameters:
server (
Jsonrpc.Server
) – The object which received the signalclient (
Jsonrpc.Client
) – AJsonrpc.Client
This signal is emitted when a new client has been lost.
New in version 3.30.
- Jsonrpc.Server.signals.handle_call(server, client, method, id, params)¶
- Signal Name:
handle-call
- Flags:
- Parameters:
server (
Jsonrpc.Server
) – The object which received the signalclient (
Jsonrpc.Client
) – AJsonrpc.Client
method (
str
) – The method that was calledid (
GLib.Variant
) – The identifier of the method callparams (
GLib.Variant
) – The parameters of the method call
- Returns:
True
if the request was handled.- Return type:
This method is emitted when the client requests a method call.
If you return
True
from this function, you should reply to it (even upon failure), using [method`Client`.reply] or [method`Client`.reply_async].New in version 3.26.
- Jsonrpc.Server.signals.notification(server, client, method, id)¶
- Signal Name:
notification
- Flags:
- Parameters:
server (
Jsonrpc.Server
) – The object which received the signalclient (
Jsonrpc.Client
) – AJsonrpc.Client
method (
str
) – The notification nameid (
GLib.Variant
) – The params for the notification
This signal is emitted when the client has sent a notification to us.
New in version 3.26.