diff options
author | eugue <eug.sun@gmail.com> | 2011-01-25 15:22:24 -0500 |
---|---|---|
committer | eugue <eug.sun@gmail.com> | 2011-01-25 15:22:24 -0500 |
commit | 82f99fc4583ca3cc9861a9fe30990a4a9ef162c4 (patch) | |
tree | d568b2284d79df8568201fbcb186bfe070a46684 /inputs | |
parent | 00e836cfa4e2652d724972585d661143142af002 (diff) |
working version of IconMover
Diffstat (limited to 'inputs')
-rw-r--r-- | inputs/TCPInput.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/inputs/TCPInput.py b/inputs/TCPInput.py index e5475c1..513b853 100644 --- a/inputs/TCPInput.py +++ b/inputs/TCPInput.py @@ -21,28 +21,27 @@ class TCPInput(Input): def sensingLoop(self): data = self.conn.recv(self.BUFFER_SIZE) main_log.debug('Incoming data', data) - if not data or 'end' in data or data == '': # data end, close socket + if not data or 'end' in data: # data end, close socket main_log.debug('End in data') print 'end of stream' self.IS_RESPONDING = 0 self.conn.close() self.sock.close() - - if self.IS_RESPONDING == 1: # if 'responding', respond to the received data - dataDict = json.loads(data) - self.respond(dataDict) - #try: - # for datagroup in data.split('\n'): - # if datagroup != None and datagroup != '': - # dataDict = json.loads(datagroup) - # self.respond(dataDict) - # socketDict = {'data':dataDict, 'address':self.address} + if self.IS_RESPONDING == 1: # if 'responding', respond to the received data + #dataDict = json.loads(data) + try: + for datagroup in data.split('\n'): + if datagroup != None and datagroup != '': + dataDict = json.loads(datagroup) + #print dataDict + self.respond(dataDict) + #socketDict = {'data':dataDict, 'address':self.address} #socketDict = {Strings.LOCATION: (dataDict['x'], dataDict['y'])} # like PygameInput #print 'input' #self.respond(socketDict) - #except Exception as exp: - # print str(exp) + except Exception as exp: + print str(exp) else: # if not 'responding', don't respond to data and restart socket # * an incomplete hack for now. will be changed if same-type-multi-Input is implemented. |