Skip to content

Instantly share code, notes, and snippets.

@sznurek
Created July 30, 2012 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sznurek/3208990 to your computer and use it in GitHub Desktop.
Save sznurek/3208990 to your computer and use it in GitHub Desktop.
class ReadAction(Action):
def __init__(self, name):
super().__init__()
self.name = name
def run(self, socket, vars):
data = socket.recv(MAGIC_CONSTANT)
vars[self.name] = data
class WriteAction(Action):
def __init__(self, data):
super().__init__()
self.data = data
def run(self, socket, vars):
if isinstance(self.data, str):
to_send = self.data
else:
to_send = self.data(vars)
socket.send(to_send)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment