The XMPP api provides an interface for accessing XMPP status information, sending XMPP messages, and parsing XMPP responses.
Methods
Classes and Modules
- MODULE AppEngine::XMPP::Proto
- MODULE AppEngine::XMPP::Status
- CLASS AppEngine::XMPP::Message
- CLASS AppEngine::XMPP::Presence
- CLASS AppEngine::XMPP::XMPPError
Class Public methods
Get the presence for a JID.
Args:
- jid: The JID of the contact whose presence is requested.
- from_jid: Optional custom sender JID.
The default is <appid>@appspot.com. Custom JIDs can be of the form <anything>@<appid>.appspotchat.com.
Returns:
- A Presence object.
Source: show
# File lib/appengine-apis/xmpp.rb, line 178 def get_presence(jid, from_jid=nil) raise ArgumentError, 'Jabber ID cannot be nil' if jid.nil? request = Proto::PresenceRequest.new request.set_jid(jid) request.set_from_jid(from_jid) if from_jid response = make_sync_call('GetPresence', request, Proto::PresenceResponse) Presence.new(response.isIsAvailable) rescue ApiProxy::ApplicationException => ex case Proto::ErrorCode.value_of(ex.application_error) when Proto::ErrorCode::INVALID_JID raise ArgumentError, "Invalid jabber ID: #{jid}" else raise XMPPError, 'Unknown error retrieving presence for jabber ID: ' + jid end end
Send a chat invitaion.
Args:
- jid: JID of the contact to invite.
- from_jid: Optional custom sender JID.
The default is <appid>@appspot.com. Custom JIDs can be of the form <anything>@<appid>.appspotchat.com.
Source: show
# File lib/appengine-apis/xmpp.rb, line 204 def send_invitation(jid, from_jid=nil) raise ArgumentError, 'Jabber ID cannot be nil' if jid.nil? request = Proto::XmppInviteRequest.new request.set_jid(jid) request.set_from_jid(from_jid) if from_jid make_sync_call('SendInvite', request, Proto::XmppInviteResponse) nil rescue ApiProxy::ApplicationException => ex case Proto::ErrorCode.value_of(ex.application_error) when Proto::ErrorCode::INVALID_JID raise ArgumentError, "Invalid jabber ID: #{jid}" else raise XMPPError, 'Unknown error sending invitation to jabber ID: ' + jid end end
Send a chat message.
Args:
Returns an Array Statuses, one for each JID, corresponding to the result of sending the message to that JID.
Source: show
# File lib/appengine-apis/xmpp.rb, line 236 def send_message(*args) if args[0].kind_of? Message message = args[0] else message = Message.new(*args) end request = message.send :to_proto response = make_sync_call('SendMessage', request, Proto::XmppMessageResponse) response.status_iterator.to_a rescue ApiProxy::ApplicationException => ex case Proto::ErrorCode.value_of(ex.application_error) when Proto::ErrorCode::INVALID_JID raise ArgumentError, "Invalid jabber ID" when Proto::ErrorCode::NO_BODY raise ArgumentError, "Missing message body" when Proto::ErrorCode::INVALID_XML raise ArgumentError, "Invalid XML body" when Proto::ErrorCode::INVALID_TYPE raise ArgumentError, "Invalid type #{message.type.inspect}" else raise XMPPError, 'Unknown error sending message' end end