login method
@detail api
@author hanchenchen.c
@brief Log in to call sendUserMessageOutsideRoom{@link #RTCEngine#sendUserMessageOutsideRoom} and sendServerMessage{@link #RTCEngine#sendServerMessage} to send P2P messages or send messages to a server without joining the RTC room.
To log out, call logout{@link #RTCEngine#logout}.
@param token
Token is required during login for authentication.
This Token is different from that required by calling joinRoom. You can assign any value even null to roomId to generate a login token. During developing and testing, you can use temporary tokens generated on the console. Deploy the token generating application on your server.
@param uid
User ID
User ID is unique within one appid.
@return
- 0: Success.
- <0: Failure. See ReturnStatus{@link #ReturnStatus} for specific reasons.
@note You will receive onLoginResult{@link #IRTCEngineEventHandler#onLoginResult} after calling this API and log in successfully. But remote users will not receive notification about that.
Implementation
Future<int?> login({required string token, required string uid}) async {
$a() => ($instance as $p_a.RTCEngine).login(token, uid);
$i() => ($instance as $p_i.ByteRTCEngine).login(token, uid);
if (Platform.isAndroid) {
return $a();
} else if (Platform.isIOS) {
return $i();
} else {
throw UnsupportedError(
'Not Support Platform ${Platform.operatingSystem}');
}
}