evennia.server.portal.mccp

MCCP - Mud Client Compression Protocol

This implements the MCCP v2 telnet protocol as per http://tintin.sourceforge.net/mccp/. MCCP allows for the server to compress data when sending to supporting clients, reducing bandwidth by 70-90%.. The compression is done using Python’s builtin zlib library. If the client doesn’t support MCCP, server sends uncompressed as normal. Note: On modern hardware you are not likely to notice the effect of MCCP unless you have extremely heavy traffic or sits on a terribly slow connection.

This protocol is implemented by the telnet protocol importing mccp_compress and calling it from its write methods.

evennia.server.portal.mccp.mccp_compress(protocol, data)[source]

Handles zlib compression, if applicable.

Parameters

data (str) – Incoming data to compress.

Returns

stream (binary) – Zlib-compressed data.

class evennia.server.portal.mccp.Mccp(protocol)[source]

Bases: object

Implements the MCCP protocol. Add this to a variable on the telnet protocol to set it up.

__init__(protocol)[source]

initialize MCCP by storing protocol on ourselves and calling the client to see if it supports MCCP. Sets callbacks to start zlib compression in that case.

Parameters

protocol (Protocol) – The active protocol instance.

no_mccp(option)[source]

Called if client doesn’t support mccp or chooses to turn it off.

Parameters

option (Option) – Option dict (not used).

do_mccp(option)[source]

The client supports MCCP. Set things up by creating a zlib compression stream.

Parameters

option (Option) – Option dict (not used).