roster.go
changeset 113 bee6cc131798
parent 111 36287f2cf06e
child 116 5c6d6d51d3ba
equal deleted inserted replaced
112:bd56fb741f69 113:bee6cc131798
    49 	rosterUpdate := rosterClients[client.Uid].rosterUpdate
    49 	rosterUpdate := rosterClients[client.Uid].rosterUpdate
    50 
    50 
    51 	iq := &Iq{Header: Header{From: client.Jid.String(), Type: "get",
    51 	iq := &Iq{Header: Header{From: client.Jid.String(), Type: "get",
    52 		Id: <-Id, Nested: []interface{}{RosterQuery{}}}}
    52 		Id: <-Id, Nested: []interface{}{RosterQuery{}}}}
    53 	ch := make(chan error)
    53 	ch := make(chan error)
    54 	f := func(v interface{}) bool {
    54 	f := func(v Stanza) bool {
    55 		defer close(ch)
    55 		defer close(ch)
    56 		iq, ok := v.(*Iq)
    56 		iq, ok := v.(*Iq)
    57 		if !ok {
    57 		if !ok {
    58 			ch <- fmt.Errorf("response to iq wasn't iq: %s", v)
    58 			ch <- fmt.Errorf("response to iq wasn't iq: %s", v)
    59 			return false
    59 			return false
    89 // The roster filter updates the Client's representation of the
    89 // The roster filter updates the Client's representation of the
    90 // roster, but it lets the relevant stanzas through. This also starts
    90 // roster, but it lets the relevant stanzas through. This also starts
    91 // the roster feeder, which is the goroutine that provides data on
    91 // the roster feeder, which is the goroutine that provides data on
    92 // client.Roster.
    92 // client.Roster.
    93 func startRosterFilter(client *Client) {
    93 func startRosterFilter(client *Client) {
    94 	out := make(chan interface{})
    94 	out := make(chan Stanza)
    95 	in := client.AddFilter(out)
    95 	in := client.AddFilter(out)
    96 	go func(in <-chan interface{}, out chan<- interface{}) {
    96 	go func(in <-chan Stanza, out chan<- Stanza) {
    97 		defer close(out)
    97 		defer close(out)
    98 		for st := range in {
    98 		for st := range in {
    99 			maybeUpdateRoster(client, st)
    99 			maybeUpdateRoster(client, st)
   100 			out <- st
   100 			out <- st
   101 		}
   101 		}