forked from jshiffer/go-xmpp
commit
b5c8af17a7
21
xmpp.go
21
xmpp.go
@ -30,6 +30,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -531,6 +532,7 @@ type Chat struct {
|
|||||||
Text string
|
Text string
|
||||||
Roster Roster
|
Roster Roster
|
||||||
Other []string
|
Other []string
|
||||||
|
Stamp time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type Roster []Contact
|
type Roster []Contact
|
||||||
@ -559,7 +561,18 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
|||||||
}
|
}
|
||||||
switch v := val.(type) {
|
switch v := val.(type) {
|
||||||
case *clientMessage:
|
case *clientMessage:
|
||||||
return Chat{Remote: v.From, Type: v.Type, Text: v.Body, Other: v.Other}, nil
|
stamp, _ := time.Parse(
|
||||||
|
"2006-01-02T15:04:05Z",
|
||||||
|
v.Delay.Stamp,
|
||||||
|
)
|
||||||
|
chat := Chat{
|
||||||
|
Remote: v.From,
|
||||||
|
Type: v.Type,
|
||||||
|
Text: v.Body,
|
||||||
|
Other: v.Other,
|
||||||
|
Stamp: stamp,
|
||||||
|
}
|
||||||
|
return chat, nil
|
||||||
case *clientQuery:
|
case *clientQuery:
|
||||||
var r Roster
|
var r Roster
|
||||||
for _, item := range v.Item {
|
for _, item := range v.Item {
|
||||||
@ -679,6 +692,12 @@ type clientMessage struct {
|
|||||||
|
|
||||||
// Any hasn't matched element
|
// Any hasn't matched element
|
||||||
Other []string `xml:",any"`
|
Other []string `xml:",any"`
|
||||||
|
|
||||||
|
Delay Delay `xml:"delay"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Delay struct {
|
||||||
|
Stamp string `xml:"stamp,attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientText struct {
|
type clientText struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user