Added NAWS negotiation to telnet protocol, for negotiating the client width/height. Use session.get_client_size() to get a tuple of (width, height) for the current output window. Not currently supported by the webclient. Also added options settings.CLIENT_DEFAULT_WIDTH and -HEIGHT for having a fallback. Note that none of Evennia's default systems currently use this width information.
This commit is contained in:
parent
699a6ded43
commit
9af3b44e1c
3 changed files with 25 additions and 2 deletions
|
|
@ -10,7 +10,7 @@ sessions etc.
|
||||||
import re
|
import re
|
||||||
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE, GA
|
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol, IAC, LINEMODE, GA
|
||||||
from src.server.session import Session
|
from src.server.session import Session
|
||||||
from src.server.portal import ttype, mssp, msdp
|
from src.server.portal import ttype, mssp, msdp, naws
|
||||||
from src.server.portal.mccp import Mccp, mccp_compress, MCCP
|
from src.server.portal.mccp import Mccp, mccp_compress, MCCP
|
||||||
from src.utils import utils, ansi, logger
|
from src.utils import utils, ansi, logger
|
||||||
|
|
||||||
|
|
@ -30,9 +30,14 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
"""
|
"""
|
||||||
# initialize the session
|
# initialize the session
|
||||||
self.iaw_mode = False
|
self.iaw_mode = False
|
||||||
self.handshakes = 4 # ttype, mccp, mssp, msdp
|
|
||||||
client_address = self.transport.client
|
client_address = self.transport.client
|
||||||
|
# this number is counted down for every handshake that completes.
|
||||||
|
# when it reaches 0 the portal/server syncs their data
|
||||||
|
self.handshakes = 5 # naws, ttype, mccp, mssp, msdp
|
||||||
self.init_session("telnet", client_address, self.factory.sessionhandler)
|
self.init_session("telnet", client_address, self.factory.sessionhandler)
|
||||||
|
|
||||||
|
# negotiate client size
|
||||||
|
self.naws = naws.Naws(self)
|
||||||
# negotiate ttype (client info)
|
# negotiate ttype (client info)
|
||||||
# Obs: mudlet ttype does not seem to work if we start mccp before ttype. /Griatch
|
# Obs: mudlet ttype does not seem to work if we start mccp before ttype. /Griatch
|
||||||
self.ttype = ttype.Ttype(self)
|
self.ttype = ttype.Ttype(self)
|
||||||
|
|
@ -71,8 +76,10 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
||||||
"""
|
"""
|
||||||
This sets up the remote-activated options we allow for this protocol.
|
This sets up the remote-activated options we allow for this protocol.
|
||||||
"""
|
"""
|
||||||
|
pass
|
||||||
return (option == LINEMODE or
|
return (option == LINEMODE or
|
||||||
option == ttype.TTYPE or
|
option == ttype.TTYPE or
|
||||||
|
option == naws.NAWS or
|
||||||
option == MCCP or
|
option == MCCP or
|
||||||
option == mssp.MSSP)
|
option == mssp.MSSP)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,17 @@ class ServerSession(Session):
|
||||||
pass
|
pass
|
||||||
logger.log_infomsg(message)
|
logger.log_infomsg(message)
|
||||||
|
|
||||||
|
def get_client_size(self):
|
||||||
|
"""
|
||||||
|
Return eventual eventual width and height reported by the
|
||||||
|
client. Note that this currently only deals with a single
|
||||||
|
client window (windowID==0) as in traditional telnet session
|
||||||
|
"""
|
||||||
|
flags = self.protocol_flags
|
||||||
|
width = flags.get('SCREENWIDTH', {}).get(0, settings.CLIENT_DEFAULT_WIDTH)
|
||||||
|
height = flags.get('SCREENHEIGHT', {}).get(0, settings.CLIENT_DEFAULT_HEIGHT)
|
||||||
|
return width, height
|
||||||
|
|
||||||
def update_session_counters(self, idle=False):
|
def update_session_counters(self, idle=False):
|
||||||
"""
|
"""
|
||||||
Hit this when the user enters a command in order to update idle timers
|
Hit this when the user enters a command in order to update idle timers
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,11 @@ PERMISSION_HIERARCHY = ["Guests", # note-only used if GUEST_ENABLED=True
|
||||||
"Immortals"]
|
"Immortals"]
|
||||||
# The default permission given to all new players
|
# The default permission given to all new players
|
||||||
PERMISSION_PLAYER_DEFAULT = "Players"
|
PERMISSION_PLAYER_DEFAULT = "Players"
|
||||||
|
# Default sizes for client window (in number of characters), if client
|
||||||
|
# is not supplying this on its own
|
||||||
|
CLIENT_DEFAULT_WIDTH = 78
|
||||||
|
CLIENT_DEFAULT_HEIGHT = 45 # telnet standard is 24 but does anyone use such
|
||||||
|
# low-res displays anymore?
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Guest accounts
|
# Guest accounts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue