コード例 #1
0
ファイル: dispatcher.py プロジェクト: esh/invaders
def dispatch(env, start_response):
	path = env['PATH_INFO']

	if path == "/comet/meta":
		start_response('200 OK', [('Content-Type', 'text/plain')])
		body = env['wsgi.input'].read()
		msg = json.loads(body)
		if msg["type"] == "login":
			return [client.login(msg)]
		elif msg["type"] == "chat":
			chat.broadcast(msg)
		elif msg["type"] == "universe":
			msg["user"] = client.resolve(msg["uid"])
			del msg["uid"]
			chan.basic_publish(mq.msg(msg), exchange="ex", routing_key="universe")
		else:
			# push it into the right queue
			raise Exception("not yet implemented")

		return [""]	
	elif path.startswith("/comet/client/"):
		start_response('200 OK', [('Content-Type', 'text/plain')])
		return [client.handle(env)]
	else:
		return ["401"]
コード例 #2
0
ファイル: chat.py プロジェクト: esh/invaders
def broadcast(msg):
	msg["payload"]["user"] = client.resolve(msg["uid"])
	del msg["uid"]
	chan.basic_publish(mq.msg(msg), exchange="ex", routing_key="chat")
コード例 #3
0
ファイル: chat.py プロジェクト: stonko/farmerjoe
def broadcast(req, msg):
	msg["user"] = client.resolve(msg["uid"])
	del msg["uid"]
	chan.basic_publish(mq.msg(msg), exchange="ex", routing_key="chat")
	
	req.write("")