python+xmpp+openfire

python+xmpp+openfire

用openfire建了一个JABBER的服务器测试,用xmpppy连接,可以连接,且可以通过服务器给客户端下发消息,但是为什么不能客户端互相发消息呢?

[Copy to clipboard] [ - ]
CODE:
import xmpp

def process_msg(conn, msg):
    text = msg.getBody()
    user = msg.getFrom()
    if text :
        print user , ':' , text
    conn.send(xmpp.Message(user, text))

def StepOn(conn):
    try:
        conn.Process(1)
    except KeyboardInterrupt: return 0
    return 1

def GoOn(conn):
    while StepOn(conn): pass

conn = xmpp.Client('server', debug=[])
conn.connect()
conn.RegisterHandler('message', process_msg)
conn.auth('xxx', 'xxx', 'xxx')
conn.sendInitPresence()
conn.Roster.Subscribe('test')
conn.send(xmpp.Message('xx', 'Test'))
conn.TCPsocket.pending_data()
GoOn(conn)

自己搞定了。。。。。