Changeset 45 for tabled.tac
- Timestamp:
- 02/08/08 19:24:35 (4 years ago)
- Files:
-
- 1 modified
-
tabled.tac (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tabled.tac
r43 r45 1 1 """ 2 2 """ 3 import sys4 from random import randint5 3 from holdemtable import holdemtable 6 4 import protocol 7 import getopt8 #import cjson9 5 import simplejson 10 6 from twisted.internet.protocol import Factory 11 from twisted.internet import reactor12 7 from twisted.protocols.basic import NetstringReceiver 13 8 from twisted.internet import defer 14 from twisted.application import internet, service , strports15 from twisted.web2 import http, resource, channel, s tream, server, static, http_headers, responsecode9 from twisted.application import internet, service 10 from twisted.web2 import http, resource, channel, server, static 16 11 from path import path 17 import cometd 18 19 20 encodejson = simplejson.dumps 21 decodejson = simplejson.loads 12 import ucomet 13 from ucomet import encodejson,decodejson 14 15 22 16 tables = {} 23 17 class BasePokerTableHandler: … … 85 79 clientChannels = [ r"\/poker" ] 86 80 87 class PokerSubscription( cometd.ClientSubscription,BasePokerTableHandler):88 def __init__(self, channel ):81 class PokerSubscription(ucomet.ClientSubscription, BasePokerTableHandler): 82 def __init__(self, channel, sendMessageCallback): 89 83 BasePokerTableHandler.__init__(self) 90 cometd.ClientSubscription.__init__(self, channel)84 ucomet.ClientSubscription.__init__(self, channel, sendMessageCallback) 91 85 92 86 def messageReceived(self,message): … … 95 89 def sendMessageViaTransport(self,data): 96 90 self.sendMessage(data) 97 98 class WebClient(cometd.Client):99 100 def generateSubscription(self, channel):101 return PokerSubscription( channel )102 103 def subscribe(self, channel):104 #we only want poker channels105 print "SUB ---------------- CHAN " + channel106 if channel == "/poker":107 return cometd.Client.subscribe(self,channel)108 else: return False109 110 91 111 92 … … 194 175 195 176 """ 196 #cometd.verbose = False197 177 class CometdRunner(resource.Resource): 198 # blah, hacky class. Wish we didn't need it199 178 addSlash = True 200 179 child_web = static.File(path("web").abspath()) 201 child_cometd = cometd.cometd()202 child_cometd.ClientType = WebClient203 #child_cometd180 child_cometd = ucomet.ucomet() 181 # child_cometd.ClientType = WebClient 182 child_cometd.ClientSubscriptionType = PokerSubscription 204 183 def render(self, ctx): 205 184 return http.Response( stream="hi") … … 227 206 print "Listening on localhost:%d(tcp) %d(http)" % (port, port2) 228 207 229 # vim:filetype=python 208
