Package lyntin :: Module net :: Class SocketCommunicator
[show private | hide private]
[frames | no frames]

Class SocketCommunicator


The SocketCommunicator handles all incoming and outgoing data from and to the mud, telnet control codes, and some data transformations.
Method Summary
  __init__(self, e, ses, host, port)
  __repr__(self)
  connect(self, host, port, sessionname)
Takes in a host and a port and connects the socket.
  handleData(self, data)
Handles incoming data from the mud.
string handleNego(self, data)
Removes telnet negotiation stuff from the stream and handles it.
  logControl(self, str)
  run(self)
While the connection hasn't been shut down, we spin through this loop retrieving data from the mud,
  setSessionName(self, name)
Sets the session name.
  shutdown(self)
Shuts down the thread polling the socket connection and the socket as well.
  write(self, data, convert)
Writes data to the mud after passing it through net_write_data_filter.
Regexp object _buildPromptRegex(self, prompt)
Builds the prompt regex.
  _filterIncomingData(self, data)
run the data through the net_read_data_filter hook which allows things like compressors and other data transformation mechanisms to do their thing.
  _pollForData(self)
Polls the socket for data.

Method Details

connect(self, host, port, sessionname)

Takes in a host and a port and connects the socket.
Parameters:
host - the host to connect to
           (type=string)
port - the port to connect at
           (type=int)
sessionname - the name of the new session
           (type=string)

handleData(self, data)

Handles incoming data from the mud. We wrap it in a MudEvent and toss it on the queue.
Parameters:
data - the incoming data from the mud
           (type=string)

handleNego(self, data)

Removes telnet negotiation stuff from the stream and handles it.
Parameters:
data - the incoming data from the mud that we need to parse for telnet control code stuff
           (type=string)
Returns:
the data without the telnet control codes
           (type=string)

run(self)

While the connection hasn't been shut down, we spin through this loop retrieving data from the mud,

setSessionName(self, name)

Sets the session name.
Parameters:
name - the new session name
           (type=string)

shutdown(self)

Shuts down the thread polling the socket connection and the socket as well.

write(self, data, convert=1)

Writes data to the mud after passing it through net_write_data_filter.
Parameters:
data - the data to write to the socket
           (type=string)
convert - whether (1) or not (0) we should convert eol stuff to CRLF and IAC to IAC IAC.
           (type=boolean)
Raises:
Exception - if we have problems sending the data over the socket

_buildPromptRegex(self, prompt='')

Builds the prompt regex. A prompt is IAC+GA or IAC+TELOPT_EOR or any string prompt. Note that prompts eat up the characters. So if the prompt is ">> " those characters will disappear from the stream.

Note: the prompt is NOT escaped before it is added to the regexp. It's up to you to re.escape the bits that need escaping.
Parameters:
prompt - the text prompt to use (if any)
           (type=string)
Returns:
the compiled regular expression for prompt detection
           (type=Regexp object)

_filterIncomingData(self, data)

run the data through the net_read_data_filter hook which allows things like compressors and other data transformation mechanisms to do their thing.

_pollForData(self)

Polls the socket for data.

Generated by Epydoc 2.1 on Mon Aug 9 09:17:42 2004 http://epydoc.sf.net