【问题标题】:Xmpp4r Google Talk Unable To Set PresenceXmpp4r Google Talk 无法设置状态
【发布时间】:2012-06-12 05:45:45
【问题描述】:

我希望能够通过 ruby​​ 脚本为我的 google talk 设置我的状态(即状态和可用性)。我似乎无法使用 xmpp4r 使其工作。我认为可能是 google talk 不再通过此 xml 协议设置存在(即存在标记),和/或我需要使用 xmpp4r 中包含的 pubsub 库。非常感谢您的帮助!到目前为止我的代码:

class Simplified
  require 'xmpp4r'
  include Jabber

  def initialize(usr, pwd, host, rsrc='', port=5222)
    @usr = usr
    @pwd = pwd
    @host = host
    @rsrc = rsrc
    @port = port

    @cl = Client.new(JID.new("#{@usr}/#{@rsrc}"))
    @cl.connect(host, port)
    @cl.auth(pwd)
  end

  # :chat, nil, :dnd, :away, :xa, :unavailable, :error
  def status(presence, msg)
    @presence = presence
    @stat_msg = msg
    stat_msg = Presence.new.set_show(:chat)
    # stat_msg = Presence.new(@presence, @status_message, 24)
    send stat_msg
  end

  def send(msg)
    @cl.send(msg)
  end
end

usr = 'joeuser@gmail.com'
pwd = 'password'
host = 'talk.google.com'
rsrc = 'test'

me = Simplified.new(usr, pwd, host, rsrc)
me.status(:dnd,'new status')

【问题讨论】:

  • 你知道如何处理这个问题了吗?

标签: ruby gmail google-talk xmpp4r


【解决方案1】:

如果您使用的是常规 xmpp4r 库:

您的客户必须发送一个“存在”节:

@cl.send(Jabber::Presence.new.set_type(':available'))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    • 2013-06-19
    • 2019-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多