Package google.golang.org/appengine/xmpp (v1.6.8)

Package xmpp provides the means to send and receive instant messages to and from users of XMPP-compatible services.

To send a message,

 m 
  
 := 
  
& xmpp 
 . 
 Message 
 { 
  
 To 
 : 
  
 [] 
 string 
 { 
 "kaylee@example.com" 
 } 
 , 
  
 Body 
 : 
  
 `Hi! How's the carrot?` 
 , 
 } 
 err 
  
 := 
  
 m 
 . 
 Send 
 ( 
 c 
 ) 

To receive messages,

 func 
  
 init 
 () 
  
 { 
  
 xmpp 
 . 
 Handle 
 ( 
 handleChat 
 ) 
 } 
 func 
  
 handleChat 
 ( 
 c 
  
 context 
 . 
 Context 
 , 
  
 m 
  
 * 
 xmpp 
 . 
 Message 
 ) 
  
 { 
  
 // 
  
 ... 
 } 

Variables

ErrPresenceUnavailable, ErrInvalidJID

  var 
  
 ( 
  
 ErrPresenceUnavailable 
  
 = 
  
  errors 
 
 . 
  New 
 
 ( 
 "xmpp: presence unavailable" 
 ) 
  
 ErrInvalidJID 
  
 = 
  
  errors 
 
 . 
  New 
 
 ( 
 "xmpp: invalid JID" 
 ) 
 ) 
 

Functions

func GetPresence

  func 
  
 GetPresence 
 ( 
 c 
  
  context 
 
 . 
  Context 
 
 , 
  
 to 
  
  string 
 
 , 
  
 from 
  
  string 
 
 ) 
  
 ( 
  string 
 
 , 
  
  error 
 
 ) 
 

GetPresence retrieves a user's presence. If the from address is an empty string the default (yourapp@appspot.com/bot) will be used. Possible return values are "", "away", "dnd", "chat", "xa". ErrPresenceUnavailable is returned if the presence is unavailable.

func GetPresenceMulti

  func 
  
 GetPresenceMulti 
 ( 
 c 
  
  context 
 
 . 
  Context 
 
 , 
  
 to 
  
 [] 
  string 
 
 , 
  
 from 
  
  string 
 
 ) 
  
 ([] 
  string 
 
 , 
  
  error 
 
 ) 
 

GetPresenceMulti retrieves multiple users' presence. If the from address is an empty string the default (yourapp@appspot.com/bot) will be used. Possible return values are "", "away", "dnd", "chat", "xa". If any presence is unavailable, an appengine.MultiError is returned

func Handle

  func 
  
 Handle 
 ( 
 f 
  
 func 
 ( 
 c 
  
  context 
 
 . 
  Context 
 
 , 
  
 m 
  
 * 
  Message 
 
 )) 
 

Handle arranges for f to be called for incoming XMPP messages. Only messages of type "chat" or "normal" will be handled.

func Invite

  func 
  
 Invite 
 ( 
 c 
  
  context 
 
 . 
  Context 
 
 , 
  
 to 
 , 
  
 from 
  
  string 
 
 ) 
  
  error 
 
 

Invite sends an invitation. If the from address is an empty string the default (yourapp@appspot.com/bot) will be used.

Message

  type 
  
 Message 
  
 struct 
  
 { 
  
 // Sender is the JID of the sender. 
  
 // Optional for outgoing messages. 
  
 Sender 
  
  string 
 
  
 // To is the intended recipients of the message. 
  
 // Incoming messages will have exactly one element. 
  
 To 
  
 [] 
  string 
 
  
 // Body is the body of the message. 
  
 Body 
  
  string 
 
  
 // Type is the message type, per RFC 3921. 
  
 // It defaults to "chat". 
  
 Type 
  
  string 
 
  
 // RawXML is whether the body contains raw XML. 
  
 RawXML 
  
  bool 
 
 } 
 

Message represents an incoming chat message.

func (*Message) Send

  func 
  
 ( 
 m 
  
 * 
  Message 
 
 ) 
  
 Send 
 ( 
 c 
  
  context 
 
 . 
  Context 
 
 ) 
  
  error 
 
 

Send sends a message. If any failures occur with specific recipients, the error will be an appengine.MultiError.

Presence

  type 
  
 Presence 
  
 struct 
  
 { 
  
 // Sender is the JID (optional). 
  
 Sender 
  
  string 
 
  
 // The intended recipient of the presence update. 
  
 To 
  
  string 
 
  
 // Type, per RFC 3921 (optional). Defaults to "available". 
  
 Type 
  
  string 
 
  
 // State of presence (optional). 
  
 // Valid values: "away", "chat", "xa", "dnd" (RFC 3921). 
  
 State 
  
  string 
 
  
 // Free text status message (optional). 
  
 Status 
  
  string 
 
 } 
 

Presence represents an outgoing presence update.

func (*Presence) Send

Send sends a presence update.

Create a Mobile Website
View Site in Mobile | Classic
Share by: