Module sampy :: Class SAMPHubProxy
[frames] | no frames]

Class SAMPHubProxy

object --+
         |
        SAMPHubProxy

Proxy class useful to simplify the client interaction with a SAMP Hub.

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
boolean
isConnected(self)
Testing method to verify the proxy connection with a running Hub.
 
connect(self, hub_params=None, user=None, password=None, key_file=None, cert_file=None, cert_reqs=0, ca_certs=None, ssl_version=1)
Connect to the current SAMP Hub.
 
disconnect(self)
Disconnect from the current SAMP Hub.
 
ping(self)
Proxy to ping SAMP Hub method (Standard Profile only)
 
setXmlrpcCallback(self, private_key, xmlrpc_addr)
Proxy to setXmlrpcCallback SAMP Hub method (Standard Profile only)
 
register(self, secret)
Proxy to register SAMP Hub method
 
unregister(self, private_key)
Proxy to unregister SAMP Hub method
 
declareMetadata(self, private_key, metadata)
Proxy to declareMetadata SAMP Hub method
 
getMetadata(self, private_key, client_id)
Proxy to getMetadata SAMP Hub method
 
declareSubscriptions(self, private_key, subscriptions)
Proxy to declareSubscriptions SAMP Hub method
 
getSubscriptions(self, private_key, client_id)
Proxy to getSubscriptions SAMP Hub method
 
getRegisteredClients(self, private_key)
Proxy to getRegisteredClients SAMP Hub method
 
getSubscribedClients(self, private_key, mtype)
Proxy to getSubscribedClients SAMP Hub method
 
notify(self, private_key, recipient_id, message)
Proxy to notify SAMP Hub method
 
notifyAll(self, private_key, message)
Proxy to notifyAll SAMP Hub method
 
call(self, private_key, recipient_id, msg_tag, message)
Proxy to call SAMP Hub method
 
callAll(self, private_key, msg_tag, message)
Proxy to callAll SAMP Hub method
 
callAndWait(self, private_key, recipient_id, message, timeout)
Proxy to callAndWait SAMP Hub method.
 
reply(self, private_key, msg_id, response)
Proxy to reply SAMP Hub method

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
dictionary
getRunningHubs()
Return a dictionary containing the lock-file contents of all the currently running hubs (single and/or multiple mode).
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

isConnected(self)

 

Testing method to verify the proxy connection with a running Hub.

Returns: boolean
return True if the proxy is connected to a Hub, False otherwise

getRunningHubs()
Static Method

 

Return a dictionary containing the lock-file contents of all the currently running hubs (single and/or multiple mode). The dictionary format is:

{<lock-file>: {<token-name>: <token-string>, ...}, ...}

where <lock-file> is the lock-file name, <token-name> and <token-string> are the lock-file tokens (name and content).

Returns: dictionary
the lock-file contents of all the currently running hubs.

connect(self, hub_params=None, user=None, password=None, key_file=None, cert_file=None, cert_reqs=0, ca_certs=None, ssl_version=1)

 

Connect to the current SAMP Hub. If a SAMP Hub is not running or refuses the connection, then a SAMPHubError is raised.

Parameters:
  • hub_params (dictionary) - Optional dictionary containig the lock-file content of the Hub with which to connect. This dictionary has the form {<token-name>: <token-string>, ...}.
  • user (string) - In case of Basic Authenticated connections, user specifies the user name.
  • password (string) - In case of Basic Authenticated connections, password specifies the user password.
  • key_file (string) - Set the file containing the private key for SSL connections. If the certificate file (certfile) contains the private key, then keyfile can be omitted.
  • cert_file (string) - Specify the file which contains a certificate to be used to identify the local side of the secure connection.
  • cert_reqs (int) - The parameter cert_reqs specifies whether a certificate is required from the server side of the connection, and whether it will be validated if provided. It must be one of the three values ssl.CERT_NONE (certificates ignored), ssl.CERT_OPTIONAL (not required, but validated if provided), or ssl.CERT_REQUIRED (required and validated). If the value of this parameter is not ssl.CERT_NONE, then the ca_certs parameter must point to a file of CA certificates.
  • ca_certs (string) - The ca_certs file contains a set of concatenated "Certification Authority" certificates, which are used to validate the certificate passed from the server end of the connection.
  • ssl_version (int) - The ssl_version option specifies which version of the SSL protocol to use. Typically, the server chooses a particular protocol version, and the client must adapt to the server's choice. Most of the versions are not interoperable with the other versions. If not specified the default SSL version is ssl.PROTOCOL_SSLv3. This version provides the most compatibility with other versions server side. Other SSL protocol versions are: ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23 and ssl.PROTOCOL_TLSv1.

callAndWait(self, private_key, recipient_id, message, timeout)

 

Proxy to callAndWait SAMP Hub method. If timeout expires a SAMPProxyError instance is raised.