equal
deleted
inserted
replaced
76 // The roster filter updates the Client's representation of the |
76 // The roster filter updates the Client's representation of the |
77 // roster, but it lets the relevant stanzas through. |
77 // roster, but it lets the relevant stanzas through. |
78 func (cl *Client) startRosterFilter() { |
78 func (cl *Client) startRosterFilter() { |
79 out := make(chan Stanza) |
79 out := make(chan Stanza) |
80 in := cl.AddFilter(out) |
80 in := cl.AddFilter(out) |
81 go func(inSave <-chan Stanza, outSave chan<- Stanza) { |
81 go func(in <-chan Stanza, out chan<- Stanza) { |
82 defer close(out) |
82 defer close(out) |
83 in := inSave |
83 for st := range(in) { |
84 var out chan<- Stanza |
84 cl.maybeUpdateRoster(st) |
85 var st Stanza |
85 out <- st |
86 var ok bool |
|
87 for { |
|
88 select { |
|
89 case st, ok = <- in: |
|
90 if !ok { |
|
91 break |
|
92 } |
|
93 cl.maybeUpdateRoster(st) |
|
94 in = nil |
|
95 out = outSave |
|
96 case out <- st: |
|
97 out = nil |
|
98 in = inSave |
|
99 } |
|
100 } |
86 } |
101 }(in, out) |
87 }(in, out) |
102 } |
88 } |
103 |
89 |
104 // BUG(cjyar) This isn't actually thread safe, though it's unlikely it |
90 // BUG(cjyar) This isn't actually thread safe, though it's unlikely it |