From 6e2f1649c8c28e400bf212a3cba541395fc1b58a Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sat, 14 Apr 2012 23:47:55 -0400 Subject: [PATCH] Change our approach to gtpsocket a bit... --- lib/gtpsocket.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/gtpsocket.py b/lib/gtpsocket.py index a086427..01fd8cf 100644 --- a/lib/gtpsocket.py +++ b/lib/gtpsocket.py @@ -1,24 +1,12 @@ -# A socket class for communicating in Go Text Protocol +# A class for communicating in Go Text Protocol # -# A simple connect method is defined, and everything else is -# suffixed with _gtp, so that this can be subclassed easily, -# e.g. for communicating with a server - -import socket +# An already-connected socket should be passed in, then this class +# can be used to handle GTP simply class GTPSocket: - def __init__(self, info): - self.info = info + def __init__(self, socket): self.socket = None - - - def connect(self): - try: - self.socket = socket.create_connection(info) - return True - except: - return False - + self.id = None def get_gtp(self): msg = None