Created
July 30, 2012 18:31
-
-
Save sznurek/3208990 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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