SippoClient
This section explains how to create and register a SippoClient
First step needed is configure client with backend url
SippoClient.configure(with: SippoClient.Options(
serverUrl: "serverUrl",
xmppHost: "xmppHost",
xmppPort: "xmppPort"
))
At this point we need Sessions class to authenticate an User, we can use token, basic or anonymous authenticate method, and as response receives a task with a Bool or ClientError
SippoClient.client.sessions.connect(authentication: .basic(username: "username", password: "password")) { result in
switch result {
case .success:
print("Login successfully")
case let .failure(error):
print("Login failure: \(error)")
}
}
SippoClient.client.sessions.connect(authentication: .token(token: "aToken", provider: "aProvider")) { result in
switch result {
case .success:
print("Login successfully")
case let .failure(error):
print("Login failure: \(error)")
}
}
To receive state changes in SippoClient
we need to set a delegate SessionDelegate
class SessionsStateDelegate: SessionDelegate {
func sippoClient(didChangeSippoState sippoState: SippoServerState, didChangeStackState stackState: StackState) {
print("New state: \(sippoState) \(stackState)")
}
}
let delegate = SessionsStateDelegate()
SippoClient.sessions.delegate = delegate
To close SippoClient session send logout action with Auth class
SippoClient.client.sessions.disconnect { _ in
// Actions on disconnect
}
SippoClient.configure creates a new client accesible from SippoClient.client, but other clients still alive, so SippoClient.client.sessions.disconnect is required to clean a Session