Skip to content

Instantly share code, notes, and snippets.

@aurynn
Created April 8, 2014 01:33
Show Gist options
  • Save aurynn/10081067 to your computer and use it in GitHub Desktop.
Save aurynn/10081067 to your computer and use it in GitHub Desktop.
stdio protocol
class StdioProtocol(LineReceiver):
from os import linesep as delimiter
def connectionMade(self):
self.connected = True
def __init__(self, wire):
self.chat = wire
wire.output = self
def lineReceived(self, line):
try:
self.chat.sendMessage(line)
except NotConnectedError as e:
self.metaMessage(e)
def sendMessage(self, line):
if not self.connected:
raise NotConnectedError("Not connected")
self.sendLine(str("<{from}> {message}".format(**line) ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment