Bases: object
Utility class which provides facilities to create and manage a SAMP compliant XML-RPC server that acts as SAMP callable client application.
Parameters: | hub : SAMPHubProxy
name : str, optional
description : str, optional
metadata : dict, optional
addr : str, optional
port : int, optional
https : bool, optional
key_file : str, optional
cert_file : str, optional
cert_reqs : int, optional
ca_certs : str, optional
ssl_version : int, optional
callable : bool, optional
|
---|
Attributes Summary
is_registered | Whether the client is currently registered. |
is_running | Whether the client is currently running. |
Methods Summary
bind_receive_call(mtype, function[, ...]) | Bind a specific MType call to a function or class method. |
bind_receive_message(mtype, function[, ...]) | Bind a specific MType to a function or class method, being intended for a call or a notification. |
bind_receive_notification(mtype, function[, ...]) | Bind a specific MType notification to a function or class method. |
bind_receive_response(msg_tag, function) | Bind a specific msg-tag response to a function or class method. |
declare_metadata([metadata]) | Declare the client application metadata supported. |
declare_subscriptions([subscriptions]) | Declares the MTypes the client wishes to subscribe to, implicitly defined with the MType binding methods bind_receive_notification() and bind_receive_call(). |
get_private_key() | Return the client private key used for the Standard Profile communications obtained at registration time (samp.private-key). |
get_public_id() | Return public client ID obtained at registration time (samp.self-id). |
receive_call(private_key, sender_id, msg_id, ...) | Standard callable client receive_call method. |
receive_notification(private_key, sender_id, ...) | Standard callable client receive_notification method. |
receive_response(private_key, responder_id, ...) | Standard callable client receive_response method. |
register() | Register the client to the SAMP Hub. |
start() | Start the client in a separate thread (non-blocking). |
stop([timeout]) | Stop the client. |
unbind_receive_call(mtype[, declare]) | Remove from the calls binding table the specified MType and unsubscribe the client from it (if required). |
unbind_receive_notification(mtype[, declare]) | Remove from the notifications binding table the specified MType and unsubscribe the client from it (if required). |
unbind_receive_response(msg_tag) | Remove from the responses binding table the specified message-tag. |
unregister() | Unregister the client from the SAMP Hub. |
Attributes Documentation
Whether the client is currently registered.
Whether the client is currently running.
Methods Documentation
Bind a specific MType call to a function or class method.
The function must be of the form:
def my_function_or_method(<self,> private_key, sender_id, msg_id,
mtype, params, extra)
where private_key is the client private-key, sender_id is the notification sender ID, msg_id is the Hub message-id, mtype is the message MType, params is the message parameter set (content of "samp.params") and extra is a dictionary containing any extra message map entry. The client is automatically declared subscribed to the MType by default.
Parameters: | mtype : str
function : callable
declare : bool, optional
metadata : dict, optional
|
---|
Bind a specific MType to a function or class method, being intended for a call or a notification.
The function must be of the form:
def my_function_or_method(<self,> private_key, sender_id, msg_id,
mtype, params, extra)
where private_key is the client private-key, sender_id is the notification sender ID, msg_id is the Hub message-id (calls only, otherwise is None), mtype is the message MType, params is the message parameter set (content of "samp.params") and extra is a dictionary containing any extra message map entry. The client is automatically declared subscribed to the MType by default.
Parameters: | mtype : str
function : callable
declare : bool, optional
metadata : dict, optional
|
---|
Bind a specific MType notification to a function or class method.
The function must be of the form:
def my_function_or_method(<self,> private_key, sender_id, mtype,
params, extra)
where private_key is the client private-key, sender_id is the notification sender ID, mtype is the message MType, params is the notified message parameter set (content of "samp.params") and extra is a dictionary containing any extra message map entry. The client is automatically declared subscribed to the MType by default.
Parameters: | mtype : str
function : callable
declare : bool, optional
metadata : dict, optional
|
---|
Bind a specific msg-tag response to a function or class method.
The function must be of the form:
def my_function_or_method(<self,> private_key, responder_id,
msg_tag, response)
where private_key is the client private-key, responder_id is the message responder ID, msg_tag is the message-tag provided at call time and response is the response received.
Parameters: | msg_tag : str
function : callable
|
---|
Declare the client application metadata supported.
Parameters: | metadata : dict, optional
|
---|
Declares the MTypes the client wishes to subscribe to, implicitly defined with the MType binding methods bind_receive_notification() and bind_receive_call().
An optional subscriptions map can be added to the final map passed to the declare_subscriptions() method.
Parameters: | subscriptions : dict, optional
|
---|
Return the client private key used for the Standard Profile communications obtained at registration time (samp.private-key).
Returns: | key : str
|
---|
Return public client ID obtained at registration time (samp.self-id).
Returns: | id : str
|
---|
Standard callable client receive_call method.
This method is automatically handled when the bind_receive_call() method is used to bind distinct operations to MTypes. In case of a customized callable client implementation that inherits from the SAMPClient class this method should be overwritten.
Note
When overwritten, this method must always return a string result (even empty).
Parameters: | private_key : str
sender_id : str
msg_id : str
message : dict
|
---|---|
Returns: | confimation : str
|
Standard callable client receive_notification method.
This method is automatically handled when the bind_receive_notification() method is used to bind distinct operations to MTypes. In case of a customized callable client implementation that inherits from the SAMPClient class this method should be overwritten.
Note
When overwritten, this method must always return a string result (even empty).
Parameters: | private_key : str
sender_id : str
message : dict
|
---|---|
Returns: | confirmation : str
|
Standard callable client receive_response method.
This method is automatically handled when the bind_receive_response() method is used to bind distinct operations to MTypes. In case of a customized callable client implementation that inherits from the SAMPClient class this method should be overwritten.
Note
When overwritten, this method must always return a string result (even empty).
Parameters: | private_key : str
responder_id : str
msg_tag : str
response : dict
|
---|---|
Returns: | confirmation : str
|
Register the client to the SAMP Hub.
Start the client in a separate thread (non-blocking).
This only has an effect if callable was set to True when initializing the client.
Stop the client.
Parameters: | timeout : float
|
---|
Remove from the calls binding table the specified MType and unsubscribe the client from it (if required).
Parameters: | mtype : str
declare : bool
|
---|
Remove from the notifications binding table the specified MType and unsubscribe the client from it (if required).
Parameters: | mtype : str
declare : bool
|
---|
Remove from the responses binding table the specified message-tag.
Parameters: | msg_tag : str
|
---|
Unregister the client from the SAMP Hub.