evennia.server.portal.amp_server

The Evennia Portal service acts as an AMP-server, handling AMP communication to the AMP clients connecting to it (by default these are the Evennia Server and the evennia launcher).

evennia.server.portal.amp_server.getenv()[source]

Get current environment and add PYTHONPATH.

Returns

env (dict) – Environment global dict.

class evennia.server.portal.amp_server.AMPServerFactory(portal)[source]

Bases: twisted.internet.protocol.ServerFactory

This factory creates AMP Server connection. This acts as the ‘Portal’-side communication to the ‘Server’ process.

noisy = False
logPrefix()[source]

How this is named in logs

__init__(portal)[source]

Initialize the factory. This is called as the Portal service starts.

Parameters
  • portal (Portal) – The Evennia Portal service instance.

  • protocol (Protocol) – The protocol the factory creates instances of.

buildProtocol(addr)[source]

Start a new connection, and store it on the service object.

Parameters

addr (str) – Connection address. Not used.

Returns

protocol (Protocol) – The created protocol.

class evennia.server.portal.amp_server.AMPServerProtocol(*args, **kwargs)[source]

Bases: evennia.server.portal.amp.AMPMultiConnectionProtocol

Protocol subclass for the AMP-server run by the Portal.

connectionLost(reason)[source]

Set up a simple callback mechanism to let the amp-server wait for a connection to close.

get_status()[source]

Return status for the Evennia infrastructure.

Returns

status (tuple)

The portal/server status and pids

(portal_live, server_live, portal_PID, server_PID).

data_to_server(command, sessid, **kwargs)[source]

Send data across the wire to the Server.

Parameters
  • command (AMP Command) – A protocol send command.

  • sessid (int) – A unique Session id.

  • kwargs (any) – Data to send. This will be pickled.

Returns

deferred (deferred or None) – A deferred with an errback.

Notes

Data will be sent across the wire pickled as a tuple (sessid, kwargs).

start_server(server_twistd_cmd)[source]

(Re-)Launch the Evennia server.

Parameters

server_twisted_cmd (list) – The server start instruction to pass to POpen to start the server.

wait_for_disconnect(callback, *args, **kwargs)[source]

Add a callback for when this connection is lost.

Parameters

callback (callable) – Will be called with *args, **kwargs once this protocol is disconnected.

wait_for_server_connect(callback, *args, **kwargs)[source]

Add a callback for when the Server is sure to have connected.

Parameters

callback (callable) – Will be called with *args, **kwargs once the Server handshake with Portal is complete.

stop_server(mode='shutdown')[source]

Shut down server in one or more modes.

Parameters

mode (str) – One of ‘shutdown’, ‘reload’ or ‘reset’.

send_Status2Launcher()[source]

Send a status stanza to the launcher.

send_MsgPortal2Server(session, **kwargs)[source]

Access method called by the Portal and executed on the Portal.

Parameters
  • session (session) – Session

  • kwargs (any, optional) – Optional data.

Returns

deferred (Deferred) – Asynchronous return.

send_AdminPortal2Server(session, operation='', **kwargs)[source]

Send Admin instructions from the Portal to the Server. Executed on the Portal.

Parameters
  • session (Session) – Session.

  • operation (char, optional) – Identifier for the server operation, as defined by the global variables in evennia/server/amp.py.

  • data (str or dict, optional) – Data used in the administrative operation.

portal_receive_status()

Helper decorator

portal_receive_launcher2portal()

Helper decorator

portal_receive_server2portal()

Helper decorator

portal_receive_adminserver2portal()

Helper decorator