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

Class SAMPHubServer

object --+
         |
        SAMPHubServer

SAMP Hub Server implementation (Standard Profile v1.0)

Instance Methods
 
__init__(self, secret=None, addr=None, port=0, lockfile=None, timeout=0, client_timeout=0, log=None, mode='single', label='', owner='', owner_group='', auth_file=None, access_restrict=None, admin='admin', https=False, keyfile=None, certfile=None, cert_reqs=0, ca_certs=None, ssl_version=2, web_profile=False)
SAMP Hub server constructor.
 
__del__(self)
 
start(self, wait=False)
Start the current SAMP Hub instance and create the lock file.
 
stop(self)
Stop the current SAMP Hub instance and delete the lock file.
boolean
isRunning(self)
Return an information concerning the Hub running status.
 
_notify_(self, sender_private_key, recipient_public_id, message)
 
_call_(self, sender_private_key, sender_public_id, recipient_public_id, msg_id, message)
 
_callAll_(self, sender_private_key, sender_public_id, msg_tag, message)
 
_reply_(self, responder_private_key, msg_id, response)

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

Static Methods
 
checkRunningHub(lockfilename)
Test whether a Hub identified by lockfilename is running or not.
list
getMTypeSubtypes(mtype)
Return a list containing all the possible wildcarded subtypes of MType.
Properties

Inherited from object: __class__

Method Details

__init__(self, secret=None, addr=None, port=0, lockfile=None, timeout=0, client_timeout=0, log=None, mode='single', label='', owner='', owner_group='', auth_file=None, access_restrict=None, admin='admin', https=False, keyfile=None, certfile=None, cert_reqs=0, ca_certs=None, ssl_version=2, web_profile=False)
(Constructor)

 

SAMP Hub server constructor. The SSL parameters are usable only if Python has been compiled with SSL support and/or ssl module is installed (available by default since Python 2.6).

Parameters:
  • secret (string) - Secret code.
  • addr (string) - Listening address (or IP)
  • port (int) - Listening port number.
  • lockfile - Custom lockfile name.
  • timeout (int) - Hub inactivity timeout. If timeout > 0 then the Hub automatically stops after an inactivity period longer than timeout seconds. By default timeout is set to 0 (Hub never expires).
  • client_timeout (int) - Client inactivity timeout. If client_timeout > 0 then the Hub automatically unregisters the clients which result inactive for a period longer than client_timeout seconds. By default client_timeout is set to 0 (clients never expire).
  • log (SAMPLog) - a SAMPLog instance for the Hub logging. If missing then a standard SAMPLog instance is used.
  • mode (string) - Defines the Hub running mode. If mode is 'single' then the Hub runs using the standard {.samp} lock-file, having a single instance for user desktop session. Otherwise, if mode is 'multiple', then the Hub runs using a non-standard lock-file, placed in .samp-1 directory, of the form samp-hub-<PID>-<ID>, where <PID> is the process id and <ID> is a general sub-id (integer number).
  • label (string) - A string used to label the Hub with a human readable name. This string is written in the lock-file assigned to the hub.label token.
  • owner (string) - General purpose Hub owner name. This value is written in the lock-file and assigned to the hub.owner.name token.
  • owner_group (string) - General purpose Hub owner group name. This value is written in the lock-file and assigned to the hub.owner.group token.
  • auth_file (string) - Authentication file path used for Basic Authentication. The authentication file must be a Berkeley DB file in Hash format containing a set of <user name>=md5(<password>)<group 1>,<group 2>,<group 3>,...) key/value pairs.
  • access_restrict (string) - Define whether the Hub access must be restricted to the Hub owner, to a certain owner group or not restricted at all. Values accepted: SAMP_RESTRICT_OWNER, SAMP_RESTRICT_GROUP, None
  • admin (string) - Define the name of the administrator user in case of restricted access. The administrator user can always access the hub instance even if it is running with SAMP_RESTRICT_OWNER policy. The administrator must be declared in the authentication file.
  • https (boolean) - set the Hub running on a Secure Sockets Layer connection (HTTPS). By default SSL is desabled.
  • keyfile (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.
  • certfile (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 client 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 certificates passed from the client 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_SSLv23. This version provides the most compatibility with other versions client side. Other SSL protocol versions are: ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3 and ssl.PROTOCOL_TLSv1.
  • web_profile - The web_profile option enables/disables the Web Profile support.
Overrides: object.__init__

start(self, wait=False)

 

Start the current SAMP Hub instance and create the lock file. Hub start-up can be blocking or non blocking depending on the wait parameter.

Parameters:
  • wait (boolean) - if True then the Hub process is joined with the caller, blocking the code flow. Usually True option is used to run a stand-alone Hub in an executable script. If False (default), then the Hub process runs in a separated thread. False is usually used in a Python shell.

checkRunningHub(lockfilename)
Static Method

 

Test whether a Hub identified by lockfilename is running or not.

Parameters:
  • lockfilename (string) - lock-file name (path + file name) of the Hub to be tested.

isRunning(self)

 

Return an information concerning the Hub running status.

Returns: boolean
True if the hub is running, False otherwise

getMTypeSubtypes(mtype)
Static Method

 

Return a list containing all the possible wildcarded subtypes of MType. Example:

>>> import sampy
>>> sampy.SAMPHubServer.getMTypeSubtypes("samp.app.ping")
['samp.app.ping', 'samp.app.*', 'samp.*', '*']
Parameters:
  • mtype (string) - the MType to be parsed
Returns: list
a list of subtypes