# evennia.server.amp_client

The Evennia Server service acts as an AMP-client when talking to the Portal. This module sets up the Client-side communication.

class `evennia.server.amp_client.``AMPClientFactory`(server)

  Bases: `twisted.internet.protocol.ReconnectingClientFactory`

  This factory creates an instance of an AMP client connection. This handles communication from the be the Evennia ‘Server’ service to the ‘Portal’. The client will try to auto-reconnect on a connection error.

  `initialDelay` = 1
  `factor` = 1.5
  `noisy` = False
  `__init__`(server)

    Initializes the client factory.

    Parameters

      server (server) – server instance.

  `maxDelay` = 1
  `startedConnecting`(connector)

    Called when starting to try to connect to the Portal AMP server.

    Parameters

      connector (Connector) – Twisted Connector instance representing this connection.

  `buildProtocol`(addr)

    Creates an AMPProtocol instance when connecting to the AMP server.

    Parameters

      addr (str) – Connection address. Not used.

  `clientConnectionLost`(connector, reason)

    Called when the AMP connection to the MUD server is lost.

    Parameters

      - connector (Connector) – Twisted Connector instance representing this connection.

      - reason (str) – Eventual text describing why connection was lost.

  `clientConnectionFailed`(connector, reason)

    Called when an AMP connection attempt to the MUD server fails.

    Parameters

      - connector (Connector) – Twisted Connector instance representing this connection.

      - reason (str) – Eventual text describing why connection failed.

class `evennia.server.amp_client.``AMPServerClientProtocol`(*args, **kwargs)

  Bases: `evennia.server.portal.amp.AMPMultiConnectionProtocol`

  This protocol describes the Server service (acting as an AMP-client)’s communication with the Portal (which acts as the AMP-server)

  `connectionMade`()

    Called when a new connection is established.

  `data_to_portal`(command, sessid, **kwargs)

    Send data across the wire to the Portal

    Parameters

      - command (AMP Command) – A protocol send command.

      - sessid (int) – A unique Session id.

      - kwargs (any) – Any data to pickle into the command.

    Returns

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

    Notes

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

  `send_MsgServer2Portal`(session, **kwargs)
    Access method - executed on the Server for sending data

      to Portal.

    Parameters

      - session (Session) – Unique Session.

      - kwargs (any, optiona) – Extra data.

  `send_AdminServer2Portal`(session, operation='', **kwargs)

    Administrative access method called by the Server to send an instruction to 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.

      - kwargs (dict, optional) – Data going into the adminstrative.

  `server_receive_status`(question)
  `server_receive_msgportal2server`()

    Helper decorator

  `server_receive_adminportal2server`()

    Helper decorator