login method

Future<void> login(
  1. String userId,
  2. String pwdOrToken,
  3. [bool isPassword = true]
)

Logs in to the chat server with a password or token.

Param userId The user ID.

Param pwdOrToken The password or token.

Param isPassword Whether to log in with a password or a token. (Default) true: A password is used. false: A token is used.

Throws A description of the exception. See ChatError.

Implementation

Future<void> login(String userId, String pwdOrToken,
    [bool isPassword = true]) async {
  EMLog.v('login: $userId : $pwdOrToken, isPassword: $isPassword');
  Map req = {
    'username': userId,
    'pwdOrToken': pwdOrToken,
    'isPassword': isPassword
  };
  Map result = await ClientChannel.invokeMethod(ChatMethodKeys.login, req);
  try {
    ChatError.hasErrorFromResult(result);
    _currentUserId = userId;
  } on ChatError catch (e) {
    throw e;
  }
}