94 rosterClients[client.Uid] = rosterClient{rosterChan: rosterCh, |
94 rosterClients[client.Uid] = rosterClient{rosterChan: rosterCh, |
95 rosterUpdate: rosterUpdate} |
95 rosterUpdate: rosterUpdate} |
96 go feedRoster(rosterCh, rosterUpdate) |
96 go feedRoster(rosterCh, rosterUpdate) |
97 } |
97 } |
98 |
98 |
99 // BUG(cjyar) RFC 3921, Section 7.4 says we need to reply. |
|
100 func maybeUpdateRoster(client *Client, st Stanza) { |
99 func maybeUpdateRoster(client *Client, st Stanza) { |
101 rosterUpdate := rosterClients[client.Uid].rosterUpdate |
100 rosterUpdate := rosterClients[client.Uid].rosterUpdate |
102 |
101 |
103 rq, ok := st.GetNested().(*RosterQuery) |
102 rq, ok := st.GetNested().(*RosterQuery) |
104 if st.GetName() == "iq" && st.GetType() == "set" && ok { |
103 if st.GetName() == "iq" && st.GetType() == "set" && ok { |
105 for _, item := range(rq.Item) { |
104 for _, item := range(rq.Item) { |
106 rosterUpdate <- item |
105 rosterUpdate <- item |
107 } |
106 } |
|
107 // Send a reply. |
|
108 iq := &Iq{To: st.GetFrom(), Id: st.GetId(), Type: |
|
109 "result"} |
|
110 client.Out <- iq |
108 } |
111 } |
109 } |
112 } |
110 |
113 |
111 func feedRoster(rosterCh chan<- []RosterItem, rosterUpdate <-chan RosterItem) { |
114 func feedRoster(rosterCh chan<- []RosterItem, rosterUpdate <-chan RosterItem) { |
112 roster := make(map[string] RosterItem) |
115 roster := make(map[string] RosterItem) |