Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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)
@bcoe
Copy link
Author

bcoe commented Jul 22, 2010

Inbound messages are dispatched to RabbitMQ via a CherryPy controller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment