TdlibBase constructor
TdlibBase({
- String? pathTdl,
- TelegramClientLibraryTdlibOptionParameter? clientOption,
- int taskMaxCount = 10000,
- int taskMinCooldown = 10,
- String event_invoke = "invoke",
- String event_update = "update",
- EventEmitter? eventEmitter,
- Duration? delayUpdate,
- double timeOutUpdate = 1.0,
- Duration? delayInvoke,
- Duration? invokeTimeOut,
- bool isAutoGetChat = false,
- bool isInvokeThrowOnError = true,
- TdlibOnGenerateExtraInvoke? onGenerateExtraInvoke,
- TdlibOnGetInvokeData? onGetInvokeData,
- TdlibOnReceiveUpdate? onReceiveUpdate,
TelegramClientUncompleDocumentation
Implementation
TdlibBase({
String? pathTdl,
TelegramClientLibraryTdlibOptionParameter? clientOption,
this.taskMaxCount = 10000,
this.taskMinCooldown = 10,
this.event_invoke = "invoke",
this.event_update = "update",
EventEmitter? eventEmitter,
Duration? delayUpdate,
this.timeOutUpdate = 1.0,
Duration? delayInvoke,
Duration? invokeTimeOut,
bool isAutoGetChat = false,
bool isInvokeThrowOnError = true,
this.onGenerateExtraInvoke,
this.onGetInvokeData,
this.onReceiveUpdate,
}) : eventEmitter = eventEmitter ?? EventEmitter() {
if (delayInvoke != null) {
delay_invoke = delayInvoke;
}
delay_update = delayUpdate;
is_invoke_throw_on_error = isInvokeThrowOnError;
pathTdl ??= "libtdjson.${getFormatLibrary}";
path_tdlib = pathTdl;
// opentdLib(pathTdlib: path_tdlib);
is_auto_get_chat = isAutoGetChat;
invokeTimeOut ??= Duration(minutes: 5);
invoke_time_out = invokeTimeOut;
if (clientOption != null) {
client_option.rawData.addAll(clientOption.rawData);
}
client_option.rawData.remove("@type");
receivePort.listen((update) async {
if (update is SendPort) {
// sendPort = update;
// is_init_send_port = true;
return;
}
final onReceiveUpdate = this.onReceiveUpdate;
if (onReceiveUpdate != null) {
await onReceiveUpdate(update, this);
} else if (update is TdlibIsolateReceiveData) {
TdlibIsolateReceiveData tdlibIsolateReceiveData = update;
try {
if (tdlibIsolateReceiveData.updateData["@extra"] is String) {
this.eventEmitter.emit(
eventName: event_invoke,
value: tdlibIsolateReceiveData,
);
} else {
this.eventEmitter.emit(
eventName: event_update,
value: tdlibIsolateReceiveData,
);
}
} catch (e) {
this.eventEmitter.emit(
eventName: event_update,
value: tdlibIsolateReceiveData,
);
}
} else if (update is TdlibIsolateReceiveDataError) {
is_init_isolate = false;
isolate.kill();
await ensureInitialized();
}
});
if (client_option['new_verbosity_level'] is int == false) {
client_option['new_verbosity_level'] = 0;
}
}