diff --git a/GNUmakefile b/GNUmakefile index 00b2b5c..25808b9 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -20,7 +20,7 @@ MAKEFILE=GNUmakefile all: bin/example @[ -d bin ] || exit -bin/example: _example/example.go xmpp.go +bin/example: _example/example.go xmpp.go xmpp_version.go @[ -d bin ] || mkdir bin go build -o $@ _example/example.go @strip $@ || echo "example OK" diff --git a/xmpp.go b/xmpp.go index bb0b454..a2e6956 100644 --- a/xmpp.go +++ b/xmpp.go @@ -677,6 +677,10 @@ func (c *Client) Recv() (stanza interface{}, err error) { if err := c.SendIQLast(v.ID, v.From, v.To); err != nil { return Chat{}, err } + case "urn:xmpp:time": + if err := c.SendIQtime(v.ID, v.From, v.To); err != nil { + return Chat{}, err + } case "jabber:iq:roster": var item rosterItem var r Roster diff --git a/xmpp_version.go b/xmpp_version.go index b13f74e..05108ef 100644 --- a/xmpp_version.go +++ b/xmpp_version.go @@ -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, "\n", xmlEscape(fromU), - xmlEscape(toServer), xmlEscape(id)) - if err != nil { - return err - } + ss := fmt.Sprintf("\n", xmlEscape(fromU), xmlEscape(toServer), xmlEscape(id)) tt := time.Now().Sub(c.loginTime) - _, err = fmt.Fprintf(c.conn, "Working\n", int(tt.Seconds())) + _, err := fmt.Fprint(c.conn, ss) + return err +} + +func (c *Client) SendIQtime(id, toServer, fromU string) error { + ss := fmt.Sprintf("\n", xmlEscape(fromU), xmlEscape(toServer), xmlEscape(id)) + tt := time.Now() + zoneN, _ := tt.Zone() + ss += fmt.Sprintf("\n", zoneN, + tt.UTC().Format("2006-01-02T15:03:04Z")) + _, err := fmt.Fprint(c.conn, ss) return err }