mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2026-05-23 20:33:46 -07:00
add urn:xmpp:time; now response jabber GetInfo
This commit is contained in:
+16
-7
@@ -19,14 +19,23 @@ func (c *Client) SendVersion(id, toServer, fromU string) error {
|
||||
}
|
||||
|
||||
func (c *Client) SendIQLast(id, toServer, fromU string) error {
|
||||
_, err := fmt.Fprintf(c.conn, "<iq type='result' from='%s' to='%s'"+
|
||||
"id='%s' type='result'>\n", xmlEscape(fromU),
|
||||
xmlEscape(toServer), xmlEscape(id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ss := fmt.Sprintf("<iq type='result' from='%s' to='%s'"+
|
||||
" id='%s'>\n", xmlEscape(fromU), xmlEscape(toServer), xmlEscape(id))
|
||||
tt := time.Now().Sub(c.loginTime)
|
||||
_, err = fmt.Fprintf(c.conn, "<query xmlns='jabber:iq:last' "+
|
||||
ss += fmt.Sprintf("<query xmlns='jabber:iq:last' "+
|
||||
"seconds='%d'>Working</query>\n</iq>", int(tt.Seconds()))
|
||||
_, err := fmt.Fprint(c.conn, ss)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) SendIQtime(id, toServer, fromU string) error {
|
||||
ss := fmt.Sprintf("<iq type='result' from='%s' to='%s'"+
|
||||
" id='%s'>\n", xmlEscape(fromU), xmlEscape(toServer), xmlEscape(id))
|
||||
tt := time.Now()
|
||||
zoneN, _ := tt.Zone()
|
||||
ss += fmt.Sprintf("<time xmlns='urn:xmpp:time'>\n<tzo>%s</tzo>"+
|
||||
"<utc>%s</utc></time>\n</iq>", zoneN,
|
||||
tt.UTC().Format("2006-01-02T15:03:04Z"))
|
||||
_, err := fmt.Fprint(c.conn, ss)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user