tokenLogin method
Uses the provided config
to send a token login message to the Telnyx backend.
If successful, the gateway registration process will start.
May return a TelnyxSocketError in the case of an authentication error
Implementation
@Deprecated('Use connectWithToken(..) instead')
void tokenLogin(TokenConfig config) {
storedTokenConfig = config;
final uuid = const Uuid().v4();
final token = config.sipToken;
final fcmToken = config.notificationToken;
ringBackpath = config.ringbackPath ?? '';
ringtonePath = config.ringTonePath ?? '';
_debug = config.debug;
UserVariables? notificationParams;
_autoReconnectLogin = config.autoReconnect ?? true;
if (defaultTargetPlatform == TargetPlatform.android) {
notificationParams = UserVariables(
pushDeviceToken: fcmToken,
pushNotificationProvider: 'android',
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
notificationParams = UserVariables(
pushDeviceToken: fcmToken,
pushNotificationProvider: 'ios',
);
}
final loginParams = LoginParams(
loginToken: token,
loginParams: [],
userVariables: notificationParams,
sessionId: sessid,
attachCall: 'true',
);
final loginMessage = LoginMessage(
id: uuid,
method: SocketMethod.login,
params: loginParams,
jsonrpc: JsonRPCConstant.jsonrpc,
);
final String jsonLoginMessage = jsonEncode(loginMessage);
_logger.i('Token Login Message $jsonLoginMessage');
if (isConnected()) {
txSocket.send(jsonLoginMessage);
} else {
_connectWithCallBack(null, () {
txSocket.send(jsonLoginMessage);
});
}
}