Legend:
- Unmodified
- Added
- Removed
-
client.py
r11 r12 11 11 from twisted.internet import defer 12 12 from pprint import PrettyPrinter 13 from string import split 13 14 14 15 pprinter = PrettyPrinter().pprint 15 16 16 def dealWithData(data): 17 pprinter(data) 17 def makeAction( action, value): 18 msg = { "method":"action", 19 "action":action, 20 "value":value } 18 21 19 22 class PokerClientProtocol(NetstringReceiver): 23 def dealWithData(self,data): 24 print "---------------" 25 pprinter(data) 26 if data["you"]["required_action"]: 27 print "---------------" 28 print "We need some input. Possible actions:" 29 p_acts = data["you"]["possible_actions"] 30 vals = [None,None] 31 while not vals[0] in p_acts: 32 pprinter(p_acts) 33 str = raw_input('Action? format: <action> OR <action>,<value>:\n') 34 vals = split(str,",") 35 vals.append(None) 36 self.sendString( cjson.encode(makeAction(vals[0], vals[1]))) 37 20 38 def __init__(self,table_name, user_id, client_id ): 21 39 self.table_name = table_name … … 33 51 34 52 decoded = cjson.decode(line) 35 dealWithData(decoded)53 self.dealWithData(decoded) 36 54 37 55 def connectionLost(self, reason):
