Created
July 22, 2010 00:48
-
-
Save bcoe/485413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@cherrypy.expose | |
def publish(self, access_token="", ip="", payload=""): | |
""" | |
""" | |
# Make sure the access token matches the IP. | |
user_check = hackwars.get_cache().get(ip) | |
if user_check == access_token: | |
conn = amqp.Connection(host=SETTINGS['rabbit_host'] + ":5672", userid="guest", password="guest", virtual_host="/", insist=False) | |
chan = conn.channel() | |
msg = amqp.Message(payload) | |
msg.properties["delivery_mode"] = 2 | |
chan.basic_publish(msg,exchange='client',routing_key=access_token) | |
chan.close() | |
conn.close() | |
return json.dumps(payload) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inbound messages are dispatched to RabbitMQ via a CherryPy controller.