summaryrefslogtreecommitdiff
path: root/python/server
blob: 4204bc85151ec0031e134c2223a566719e48efa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
from qpid import spec
from qpid.connection import Connection, listen
from qpid.delegate import Delegate
from qpid.peer import Peer

class Server(Delegate):

  def connection_open(self, ch, msg):
    msg.open_ok()

  def channel_open(self, ch, msg):
    print "channel %s open" % ch.id
    msg.open_ok()

  def message_transfer(self, ch, msg):
    print msg.body
    msg.ok()


spec = spec.load("../specs/amqp.0-9.xml")

for io in listen("0.0.0.0", 5672):
  c = Connection(io, spec)
  p = Peer(c, Server())
  c.tini()
  p.start()
  ch = p.channel(0)
  ch.connection_start()
  ch.connection_tune()