Skip to content

Instantly share code, notes, and snippets.

@bcoe
Created July 22, 2010 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcoe/485413 to your computer and use it in GitHub Desktop.
Save bcoe/485413 to your computer and use it in GitHub Desktop.
@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