29 lines
759 B
Swift
29 lines
759 B
Swift
import Foundation
|
|
|
|
final class RosterModule: XmppModule {
|
|
let id = "Roseter module"
|
|
|
|
func reduce(oldState: ClientState, with _: Event) -> ClientState {
|
|
oldState
|
|
}
|
|
|
|
func process(state: ClientState, with event: Event) async -> Event? {
|
|
switch event {
|
|
case .streamReady:
|
|
return .requestRoster
|
|
|
|
case .requestRoster:
|
|
// TODO: check version!
|
|
let req = Stanza.iqGet(jid: state.jid.full, payload: XMLElement(name: "query", xmlns: "jabber:iq:roster", attributes: [:], content: nil, nodes: []))
|
|
if let req {
|
|
return .stanzaOutbound(req)
|
|
} else {
|
|
return nil
|
|
}
|
|
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
}
|