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)[源代码]

Handles zlib compression, if applicable.

参数

data (str) – Incoming data to compress.

返回

stream (binary) – Zlib-compressed data.

class evennia.server.portal.mccp.Mccp(protocol)[源代码]

基类:object

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

__init__(protocol)[源代码]

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.

参数

protocol (Protocol) – The active protocol instance.

no_mccp(option)[源代码]

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

参数

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

do_mccp(option)[源代码]

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

参数

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