Mtproto constructor
Mtproto({
- String? pathTdl,
- Map? clientOption,
- bool is_cli = false,
- String event_invoke = "invoke",
- String event_update = "update",
- EventEmitter? eventEmitter,
- Duration? delayUpdate,
- double timeOutUpdate = 1.0,
- Duration? delayInvoke,
- Duration? invokeTimeOut,
- bool isAutoGetChat = false,
- FutureOr<
String> on_generate_extra_invoke()?, - FutureOr<
Map> on_get_invoke_data()?, - FutureOr<
void> on_receive_update(- dynamic update,
- Mtproto Mtproto
TelegramClientUncompleDocumentation
Implementation
Mtproto({
String? pathTdl,
Map? clientOption,
this.is_cli = false,
this.event_invoke = "invoke",
this.event_update = "update",
EventEmitter? eventEmitter,
Duration? delayUpdate,
this.timeOutUpdate = 1.0,
Duration? delayInvoke,
Duration? invokeTimeOut,
bool isAutoGetChat = false,
this.on_generate_extra_invoke,
this.on_get_invoke_data,
this.on_receive_update,
}) {
pathTdl ??= "Mtproto.${getFormatLibrary}";
path_tdlib = pathTdl;
is_auto_get_chat = isAutoGetChat;
invokeTimeOut ??= Duration(minutes: 5);
invoke_time_out = invokeTimeOut;
if (eventEmitter != null) {
event_emitter = eventEmitter;
}
if (clientOption != null) {
client_option.addAll(clientOption);
if (clientOption["is_android"] == true) {
is_android = true;
}
}
receivePort.listen((update) async {
if (on_receive_update != null) {
await on_receive_update!(update, this);
} else if (update is MtprotoIsolateReceiveData) {
} else if (update is MtprotoIsolateReceiveDataError) {
MtprotoIsolateReceiveDataError tdlibIsolateReceiveDataError = update;
try {
MtprotoClient? tdlibClient = clients.getClientById(
tdlibIsolateReceiveDataError.clientId,
);
if (tdlibClient != null) {
tdlibClient.close();
}
} catch (e) {}
}
});
}