0

アプリ エンジンの xmpp クライアントにメッセージを送信するときに、xmpppy クライアントの使用に問題があるようです。エラーは発生しません。そこにメッセージが届かないだけです。アプリ エンジンのクライアントから sl4a クライアントへのメッセージの送信は機能します。Google トークのクライアントと sl4a クライアントの間でメッセージを送受信することも同様に機能します。

どんな助けでも大歓迎です。

ここにpythonコードがあります

import xmpp
import time

_SERVER = 'talk.google.com', 5223
commandByXMPP()

def commandByXMPP():
  global xmppUsername
  xmppUsername = 'garrowsbot@gmail.com'  
  global xmppPassword
  xmppPassword = 'obscured'  
  global xmppClient
  global operator
  operator = "cellbotmote@appspot.com"

  jid = xmpp.protocol.JID(xmppUsername)
  xmppClient = xmpp.Client(jid.getDomain(), debug=[])
  xmppClient.connect(server=_SERVER)
  try:
    xmppClient.RegisterHandler('message', XMPP_message_cb)
  except:
    exitCellbot('XMPP error. You sure the phone has an internet connection?')
  if not xmppClient:
    exitCellbot('XMPP Connection failed!')
    return
  auth = xmppClient.auth(jid.getNode(), xmppPassword, 'botty')
  if not auth:
    exitCellbot('XMPP Authentication failed!')
    return
  xmppClient.sendInitPresence()
  print "XMPP username for the robot is:\n" + xmppUsername

  start=time.time()
  i=0
  try:
    outputToOperator("starting")
    while time.time()-start<15:
      print "tick"
      xmppClient.Process(1)
      i = i +1
      if i % 10 == 0:
        outputToOperator("hello")
    outputToOperator("exiting")
  except KeyboardInterrupt:
    pass


def XMPP_message_cb(session, message):
  jid = xmpp.protocol.JID(message.getFrom())
  global operator
  command = message.getBody()
  print command

def outputToOperator(msg):
  print "Outputting "+msg+" to " + operator
  xmppClient.send(xmpp.Message(operator, msg))
4

1 に答える 1

4

1)garrowsbot@gmail.comがcellbotmote@appspot.comの名簿に登録されていることを確認します。GTalkは不明なユーザーからのメッセージを配信しません。2)チャットタイプのメッセージを送信します。

xmppClient.send(xmpp.Message(operator, msg, typ='chat'))

type一部のクライアントは、属性を持たない「通常の」メッセージの受信にうまく反応しません。

于 2011-01-06T21:57:16.213 に答える