xmpp/roster.go
author Chris Jones <chris@cjones.org>
Sat, 09 Nov 2013 12:37:49 -0700
changeset 181 750bc33ccdda
parent 162 7b5586a5e109
permissions -rw-r--r--
Forgot to change the type of RosterItem.Jid to JID.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
     1
package xmpp
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
     2
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
     3
// This file contains support for roster management, RFC 3921, Section 7.
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
     4
36
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
     5
import (
98
c9cc4eda6dce Updated for Go 1.0 + upcoming XML fixes.
Chris Jones <chris@cjones.org>
parents: 72
diff changeset
     6
	"encoding/xml"
128
8342afcffc92 Use reflection instead of constructor functions to create extended stanza structures.
Chris Jones <christian.jones@sri.com>
parents: 126
diff changeset
     7
	"reflect"
36
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
     8
)
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
     9
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    10
// Roster query/result
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    11
type RosterQuery struct {
116
Chris Jones <christian.jones@sri.com>
parents: 113
diff changeset
    12
	XMLName xml.Name     `xml:"jabber:iq:roster query"`
98
c9cc4eda6dce Updated for Go 1.0 + upcoming XML fixes.
Chris Jones <chris@cjones.org>
parents: 72
diff changeset
    13
	Item    []RosterItem `xml:"item"`
36
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    14
}
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    15
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    16
// See RFC 3921, Section 7.1.
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    17
type RosterItem struct {
98
c9cc4eda6dce Updated for Go 1.0 + upcoming XML fixes.
Chris Jones <chris@cjones.org>
parents: 72
diff changeset
    18
	XMLName      xml.Name `xml:"jabber:iq:roster item"`
181
750bc33ccdda Forgot to change the type of RosterItem.Jid to JID.
Chris Jones <chris@cjones.org>
parents: 162
diff changeset
    19
	Jid          JID      `xml:"jid,attr"`
98
c9cc4eda6dce Updated for Go 1.0 + upcoming XML fixes.
Chris Jones <chris@cjones.org>
parents: 72
diff changeset
    20
	Subscription string   `xml:"subscription,attr"`
c9cc4eda6dce Updated for Go 1.0 + upcoming XML fixes.
Chris Jones <chris@cjones.org>
parents: 72
diff changeset
    21
	Name         string   `xml:"name,attr"`
72
Chris Jones <christian.jones@sri.com>
parents: 61
diff changeset
    22
	Group        []string
36
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    23
}
9fe022261dcc Added a capability to use extensions. There are still some bugs with
Chris Jones <chris@cjones.org>
parents:
diff changeset
    24
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    25
type Roster struct {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    26
	Extension
155
Chris Jones <christian.jones@sri.com>
parents: 153
diff changeset
    27
	get      chan []RosterItem
Chris Jones <christian.jones@sri.com>
parents: 153
diff changeset
    28
	toServer chan Stanza
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    29
}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    30
57
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    31
type rosterClient struct {
72
Chris Jones <christian.jones@sri.com>
parents: 61
diff changeset
    32
	rosterChan   <-chan []RosterItem
57
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    33
	rosterUpdate chan<- RosterItem
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    34
}
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    35
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    36
func (r *Roster) rosterMgr(upd <-chan Stanza) {
181
750bc33ccdda Forgot to change the type of RosterItem.Jid to JID.
Chris Jones <chris@cjones.org>
parents: 162
diff changeset
    37
	roster := make(map[JID]RosterItem)
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    38
	var snapshot []RosterItem
153
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
    39
	var get chan<- []RosterItem
57
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    40
	for {
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    41
		select {
153
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
    42
		case get <- snapshot:
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
    43
128
8342afcffc92 Use reflection instead of constructor functions to create extended stanza structures.
Chris Jones <christian.jones@sri.com>
parents: 126
diff changeset
    44
		case stan, ok := <-upd:
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    45
			if !ok {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    46
				return
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    47
			}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    48
			iq, ok := stan.(*Iq)
134
80b764fa2f08 Fixed some logic errors and initialized some things that needed to be initialized.
Chris Jones <christian.jones@sri.com>
parents: 128
diff changeset
    49
			if !ok {
80b764fa2f08 Fixed some logic errors and initialized some things that needed to be initialized.
Chris Jones <christian.jones@sri.com>
parents: 128
diff changeset
    50
				continue
80b764fa2f08 Fixed some logic errors and initialized some things that needed to be initialized.
Chris Jones <christian.jones@sri.com>
parents: 128
diff changeset
    51
			}
153
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
    52
			if iq.Type != "result" && iq.Type != "set" {
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    53
				continue
57
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    54
			}
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    55
			var rq *RosterQuery
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    56
			for _, ele := range iq.Nested {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    57
				if q, ok := ele.(*RosterQuery); ok {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    58
					rq = q
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    59
					break
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    60
				}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    61
			}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    62
			if rq == nil {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    63
				continue
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    64
			}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    65
			for _, item := range rq.Item {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    66
				roster[item.Jid] = item
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    67
			}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    68
			snapshot = []RosterItem{}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    69
			for _, ri := range roster {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    70
				snapshot = append(snapshot, ri)
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    71
			}
153
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
    72
			get = r.get
57
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    73
		}
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    74
	}
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    75
}
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
    76
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    77
func (r *Roster) makeFilters() (Filter, Filter) {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    78
	rosterUpdate := make(chan Stanza)
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    79
	go r.rosterMgr(rosterUpdate)
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    80
	recv := func(in <-chan Stanza, out chan<- Stanza) {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    81
		defer close(out)
162
7b5586a5e109 Added a Close() function and fixed a couple of shutdown bugs.
Chris Jones <chris@cjones.org>
parents: 158
diff changeset
    82
		defer close(rosterUpdate)
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    83
		for stan := range in {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    84
			rosterUpdate <- stan
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    85
			out <- stan
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    86
		}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    87
	}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    88
	send := func(in <-chan Stanza, out chan<- Stanza) {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    89
		defer close(out)
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    90
		for {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    91
			select {
128
8342afcffc92 Use reflection instead of constructor functions to create extended stanza structures.
Chris Jones <christian.jones@sri.com>
parents: 126
diff changeset
    92
			case stan, ok := <-in:
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    93
				if !ok {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    94
					return
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    95
				}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    96
				out <- stan
128
8342afcffc92 Use reflection instead of constructor functions to create extended stanza structures.
Chris Jones <christian.jones@sri.com>
parents: 126
diff changeset
    97
			case stan := <-r.toServer:
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    98
				out <- stan
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
    99
			}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   100
		}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   101
	}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   102
	return recv, send
57
e6cb3f049137 Revamped how the roster works. We're now using a channel to transmit snapshots
Chris Jones <chris@cjones.org>
parents: 55
diff changeset
   103
}
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   104
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   105
func newRosterExt() *Roster {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   106
	r := Roster{}
158
2d948fcbb5d7 Renamed Extension.StanzaHandlers to StanzaTypes, and updated the doc comment.
Chris Jones <chris@cjones.org>
parents: 155
diff changeset
   107
	r.StanzaTypes = make(map[xml.Name]reflect.Type)
128
8342afcffc92 Use reflection instead of constructor functions to create extended stanza structures.
Chris Jones <christian.jones@sri.com>
parents: 126
diff changeset
   108
	rName := xml.Name{Space: NsRoster, Local: "query"}
158
2d948fcbb5d7 Renamed Extension.StanzaHandlers to StanzaTypes, and updated the doc comment.
Chris Jones <chris@cjones.org>
parents: 155
diff changeset
   109
	r.StanzaTypes[rName] = reflect.TypeOf(RosterQuery{})
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   110
	r.RecvFilter, r.SendFilter = r.makeFilters()
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   111
	r.get = make(chan []RosterItem)
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   112
	r.toServer = make(chan Stanza)
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   113
	return &r
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   114
}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   115
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   116
// Return the most recent snapshot of the roster status. This is
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   117
// updated automatically as roster updates are received from the
153
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
   118
// server. This function may block immediately after the XMPP
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
   119
// connection has been established, until the first roster update is
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
   120
// received from the server.
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   121
func (r *Roster) Get() []RosterItem {
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   122
	return <-r.get
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   123
}
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   124
153
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
   125
// Asynchronously fetch this entity's roster from the server.
bbd4166df95d Simplified the API: There's only one constructor, and it does everything necessary to initiate the stream. StartSession() and Roster.Update() have both been eliminated.
Chris Jones <christian.jones@sri.com>
parents: 142
diff changeset
   126
func (r *Roster) update() {
124
34e917ca6a11 Updated the example to match the new API, and fixed the roster Update to not require a reference to the client.
Chris Jones <christian.jones@sri.com>
parents: 121
diff changeset
   127
	iq := &Iq{Header: Header{Type: "get", Id: NextId(),
34e917ca6a11 Updated the example to match the new API, and fixed the roster Update to not require a reference to the client.
Chris Jones <christian.jones@sri.com>
parents: 121
diff changeset
   128
		Nested: []interface{}{RosterQuery{}}}}
121
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   129
	r.toServer <- iq
ebb86cbdd218 Changed the way filters work. They're now symmetrical, consisting of a paired send filter and receive filter.
Chris Jones <christian.jones@sri.com>
parents: 118
diff changeset
   130
}